✨ feat: extract mq-check and mq-docs into standalone crates#1262
✨ feat: extract mq-check and mq-docs into standalone crates#1262
Conversation
Extract the `check` and `docs` subcommands from mq-run into dedicated crates (mq-check and mq-docs) for better modularity and independent usage. The mq-docs crate also adds HTML output format with sidebar navigation and search filtering.
There was a problem hiding this comment.
Pull request overview
Extracts the check and docs subcommands from mq-run into standalone crates (mq-check and mq-docs) and updates workspace wiring accordingly.
Changes:
- Removed
Docs/Checksubcommands (and related logic/tests) fromcrates/mq-run. - Added new
mq-checkandmq-docscrates with binaries and reusable library functions. - Updated workspace members/dependencies and enabled additional
mq-langfeatures formq-hir.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mq-run/src/cli.rs | Removes in-CLI docs/check implementations and their unit tests. |
| crates/mq-hir/Cargo.toml | Enables mq-lang file-io feature (likely to support file-backed parsing/URLs). |
| crates/mq-docs/src/main.rs | Adds mq-docs CLI entrypoint (parsing args, reading files, printing output). |
| crates/mq-docs/src/lib.rs | Implements docs generation in Markdown/Text/HTML formats. |
| crates/mq-docs/Cargo.toml | Introduces the mq-docs crate and binary target. |
| crates/mq-check/src/main.rs | Adds mq-check CLI entrypoint. |
| crates/mq-check/src/lib.rs | Implements file checking logic previously in mq-run. |
| crates/mq-check/Cargo.toml | Introduces the mq-check crate and binary target. |
| Cargo.toml | Adds new crates to the workspace and workspace dependencies. |
| for (filename, content) in file_contents { | ||
| let mut hir = mq_hir::Hir::default(); | ||
| hir.builtin.disabled = true; | ||
| let url = Url::parse(&format!("file:///{filename}")).ok(); |
There was a problem hiding this comment.
Building a file URL via string formatting + Url::parse is not robust (e.g., Windows paths, backslashes, spaces/non-ASCII requiring percent-encoding). This may cause URL parsing to fail and silently drop file context (url becomes None). Prefer Url::from_file_path(...) (and consider passing PathBuf through the API instead of a pre-rendered String).
| let url = Url::parse(&format!("file:///{filename}")).ok(); | |
| let url = Url::from_file_path(filename).ok(); |
Co-authored-by: Copilot <[email protected]>
| use mq_lang::DefaultEngine; | ||
| use rayon::prelude::*; | ||
| use std::collections::VecDeque; | ||
| use std::io::BufRead; |
There was a problem hiding this comment.
The unused import std::collections::VecDeque was removed on line 8, but line 9 now shows use std::io::BufRead; which may also be unused after removing the check and docs commands. Verify that BufRead is still used elsewhere in the file.
| use std::io::BufRead; |
| for (filename, content) in file_contents { | ||
| let mut hir = mq_hir::Hir::default(); | ||
| hir.builtin.disabled = true; | ||
| let url = Url::parse(&format!("file:///{filename}")).ok(); |
There was a problem hiding this comment.
The URL construction uses three slashes (file:///) which is valid for absolute paths but may fail for relative paths or paths on Windows. Consider using Url::from_file_path for proper cross-platform file URL construction, or handle the error case instead of silently converting to None with .ok().
| \x20 <td>{name_html}</td>\n\ | ||
| \x20 <td>{desc_html}</td>\n\ | ||
| \x20 <td>{args_html}</td>\n\ | ||
| \x20 <td><code>{example_html}</code></td>\n\ | ||
| \x20 </tr>" |
There was a problem hiding this comment.
The HTML generation uses raw string concatenation with \x20 escape sequences for spaces. Consider using a templating library like askama or extracting the HTML template to a separate file for better maintainability and readability.
| - [TOML functions](reference/toml_functions.md) | ||
| - [YAML functions](reference/yaml_functions.md) | ||
| - [XML functions](reference/xml_functions.md) | ||
| - [Builtin selectors and functions](builtins.html) |
There was a problem hiding this comment.
The link references builtins.html but there's no indication that this file will be generated or exists. Ensure this HTML file is created as part of the documentation build process or update the link to point to the correct location.
| - [Builtin selectors and functions](builtins.html) | |
| - [Builtin selectors and functions](reference/builtins.md) |
Extract the
checkanddocssubcommands from mq-run into dedicated crates (mq-check and mq-docs).