✨ feat(table): add to_csv function and update docs#1296
Conversation
harehare
commented
Feb 18, 2026
- Add to_csv function to table.mq for CSV export
- Update builtins.html to document new table functions
- Update update_doc.sh to include table module in docs generation
- Add to_csv function to table.mq for CSV export - Update builtins.html to document new table functions - Update update_doc.sh to include table module in docs generation
There was a problem hiding this comment.
Pull request overview
This PR adds a new to_csv function to the table module for CSV export functionality and updates the documentation generation process to include the table module.
Changes:
- Added
to_csvfunction totable.mqmodule with CSV export capability - Updated
update_doc.shscript to include-M tableflag for documentation generation - Regenerated
builtins.htmldocumentation with table module functions
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
scripts/update_doc.sh |
Added -M table flag to include table module in documentation generation |
crates/mq-lang/modules/table.mq |
Added to_csv function and imported csv module |
docs/books/src/builtins.html |
Regenerated documentation showing table module with 10 functions (count) but only 9 listed |
| let header = table[:header] | ||
| | let rows = table[:rows] | ||
| | csv::csv_stringify([header] + rows, delimiter) |
There was a problem hiding this comment.
The to_csv function passes markdown table cell nodes directly to csv_stringify, but csv_stringify expects arrays of simple values (strings/numbers). Table cells are markdown nodes with a 'values' field containing text.
The header and rows need to be converted from markdown table cell nodes to their text values before passing to csv_stringify. You should map over the header and rows to extract the text from each cell, likely using the to_text builtin function or by accessing the cell values directly.
| let header = table[:header] | |
| | let rows = table[:rows] | |
| | csv::csv_stringify([header] + rows, delimiter) | |
| let header_text = map(table[:header], to_text) | |
| | let rows_text = map(table[:rows], fn(row): map(row, to_text);) | |
| | csv::csv_stringify([header_text] + rows_text, delimiter) |