Conversation
- Add `mq modules` subcommand listing all standard modules with their public functions, parameter signatures, and doc comments - Add `--format` / `-F` option supporting `text` (default, colored), `markdown` (GFM table), and `table` (rounded ASCII table) output - Add `FunctionInfo` and `ParamInfo` structs to `mq-lang` for structured module introspection extracted from AST (`Expr::Def` params) and source-level `#` doc comments - Improve `NotDefined` error help to suggest `mq modules` when a function is not found - Update CLI `--help` after_help with `modules` and `-m` usage examples
There was a problem hiding this comment.
Pull request overview
Adds a new mq modules CLI subcommand to discover built-in (standard) modules and list their public functions, signatures, and doc comments by introspecting mq-lang module sources.
Changes:
- Introduce
mq modulessubcommand with--format/-Foutput modes (text,markdown,table). - Add module introspection utilities in
mq-runthat parse standard module AST + extract#doc comments via CST parsing. - Expose standard-module loading hooks from
mq-langand enable thecstfeature inmq-runto support doc extraction.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mq-run/src/module_info.rs | New module introspection code (AST signatures + CST doc extraction) used by mq modules. |
| crates/mq-run/src/cli.rs | Wires modules subcommand, formatting logic, and adds a basic test. |
| crates/mq-run/src/lib.rs | Registers the new module_info module. |
| crates/mq-run/Cargo.toml | Enables mq-lang’s cst feature and adds rustc-hash dependency. |
| crates/mq-lang/src/module.rs | Adds load_standard_module helper for loading one embedded standard module. |
| crates/mq-lang/src/lib.rs | Re-exports STANDARD_MODULES and load_standard_module from mq-lang. |
| Cargo.lock | Locks the new dependency set (rustc-hash for mq-run). |
| .filter_map(|(mod_name, content_fn)| { | ||
| let content = content_fn(); | ||
| let doc_map = extract_doc_comments(content); | ||
| let module = mq_lang::load_standard_module(mod_name.as_str())?; | ||
|
|
There was a problem hiding this comment.
standard_module_functions() currently uses filter_map with load_standard_module(..)?, so any parse/load error will silently drop that module from the listing. That can make mq modules output incomplete without explanation. Consider returning a Result (and surfacing a miette diagnostic in the CLI), or at least including the module name with an error marker/empty function list instead of omitting it.
| let sig = Self::format_function_signature(func); | ||
| let desc = func.doc.as_deref().and_then(|d| d.lines().next()).unwrap_or(""); | ||
| println!("| {} | `{}` | {} |", name, sig, desc); |
There was a problem hiding this comment.
print_modules_markdown writes raw module names, signatures, and doc text into a GFM table without escaping. If any value contains |, backticks, or newlines (doc comments often can), the generated table will be malformed. Consider escaping | (e.g. \|), replacing newlines with <br>, and/or wrapping/escaping description text consistently.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mq modulessubcommand listing all standard modules with their public functions, parameter signatures, and doc comments--format/-Foption supportingtext(default, colored),markdown(GFM table), andtable(rounded ASCII table) outputFunctionInfoandParamInfostructs tomq-langfor structured module introspection extracted from AST (Expr::Defparams) and source-level#doc commentsNotDefinederror help to suggestmq moduleswhen a function is not found--helpafter_help withmodulesand-musage examples