Skip to content

docs: add CLI reference page and remove CLI from API docs (#704)#852

Open
planetf1 wants to merge 7 commits intogenerative-computing:mainfrom
planetf1:cs/issue-704
Open

docs: add CLI reference page and remove CLI from API docs (#704)#852
planetf1 wants to merge 7 commits intogenerative-computing:mainfrom
planetf1:cs/issue-704

Conversation

@planetf1
Copy link
Copy Markdown
Contributor

@planetf1 planetf1 commented Apr 14, 2026

Type of PR

  • Bug Fix
  • New Feature
  • Documentation
  • Other

Description

Objective

The cli/ package was included in the generated API reference docs, which is wrong — it's a user-facing tool, not a public Python API. Simultaneously, there was no single CLI reference; coverage was scattered across guide pages. This PR removes CLI internals from the API docs and adds a proper, auto-generated CLI reference page.

What the CLI reference looks like

A single page at Docs > Reference > CLI Reference documenting all m subcommands (serve, alora, decompose, eval, fix). Each command section includes:

  • Summary and extended description
  • Prerequisites (as a bulleted callout)
  • Usage synopsis
  • Arguments and options tables (flag, type, default, description)
  • Output (what the command produces)
  • A one-liner example
  • Cross-links to the relevant guide page

All content is sourced from the Python source code — Typer metadata (help= strings, types, defaults) plus structured docstring sections (Prerequisites:, Output:, Examples:, See Also:). Output is standard Markdown, portable across doc frameworks.

Screenshot 2026-04-14 at 12 18 16

CLI Reference - Mellea.pdf

  • note the print format isn't clean, but that's a general mintlify-> edge->apple printing issue. Raise separate issue if seen as a problem.

How it is built and validated

Generation pipeline:

  • New script tooling/docs-autogen/generate_cli_reference.py imports the Typer app, converts it to its underlying Click model via typer.main.get_command(), walks the command tree, and emits docs/docs/reference/cli.md.
  • Integrated into build.py as Step 4, runs with --strict flag.
  • --strict validates before writing — fails the build if any command is missing a summary, Prerequisites:, Output: section, or has options without help= text. No incomplete output is produced.
  • Available standalone via uv run poe clidocs.

CI enforcement:

  • docs-publish.yml runs build.py which now includes strict CLI reference generation.
  • New CI step runs the 21 CLI reference unit tests covering Typer introspection, docstring parsing, generated output structure, and strict validation.
  • markdownlint covers the generated page (it lands in docs/docs/reference/).

SEO: 17 Mintlify redirects for old /api/cli/* URLs (all submodules including serve/ and fix/).

Changes

Area What
Remove cli from API docs generate-ast.py PACKAGES, audit_coverage.py discovery/quality scope, dead discover_cli_commands() removed
New generator generate_cli_reference.py — Typer introspection, --strict validation, proper title-cased See Also links, --help filtered from output, friendly error on missing extras
Tests test_cli_reference.py — 21 tests
Build integration build.py Step 4, pyproject.toml poe tasks, .gitignore
CI docs-publish.yml — CLI reference test step
Docstring enrichment All CLI commands: Prerequisites:, Output:, Examples:, See Also:
Cross-links 5 guide pages link back to CLI reference
Redirects 17 old /api/cli/* URLs → /reference/cli
Guidelines CONTRIBUTING.md CLI docstring convention (including Examples:), AGENTS.md coding standards
Docs-autogen README Prerequisites, pipeline overview, file structure updated
Glossary Removed dead m decompose entry (CLI reference now covers it)

Testing

  • 21 unit tests added (tooling/docs-autogen/test_cli_reference.py)
  • Strict validation passes (--strict flag)
  • markdownlint clean on generated output
  • All pre-commit hooks pass (ruff, mypy, codespell, markdownlint, MDX validation)
  • Local Mintlify preview verified
  • Ensure existing tests and GitHub automation passes (a maintainer will kick off the GitHub automation when the rest of the PR is populated)

How to test locally

Full details in tooling/docs-autogen/README.md.

# Install (same as CI)
uv sync --all-extras --group dev

# Generate the CLI reference page (with strict validation)
uv run poe clidocs

# Or generate everything (API docs + CLI reference) via the full pipeline
uv run poe apidocs

# Run the CLI reference tests
uv run pytest tooling/docs-autogen/test_cli_reference.py -v

# Preview locally (requires Node.js LTS, v22 or earlier)
cd docs/docs && npx mintlify dev
# Open http://localhost:3000/reference/cli

Key pages to verify:

  • CLI Reference: /reference/cli — all commands, flags, examples, cross-links
  • API Reference tab: no cli entries should remain
  • Cross-links from guide pages (See Also footers): /guide/m-decompose, /integrations/m-serve, /advanced/lora-and-alora-adapters, /evaluation-and-observability/evaluate-with-llm-as-a-judge, /how-to/refactor-prompts-with-cli
  • Redirects: /api/cli/m should redirect to /reference/cli

Questions for reviewers

  1. Content layout — Is the single-page format with all commands right for the CLI's size, or should individual commands have their own pages?
  2. Navigation — The CLI reference sits under Docs > Reference (alongside the glossary). The API Reference has its own top-level tab. Is this placement correct, or should the CLI reference live elsewhere?
  3. Maintenance process — The page is auto-generated from Typer metadata and docstrings, with --strict CI enforcement. Does this approach make sense for keeping docs in sync with minimal overhead?
  4. Docstring quality — Do the enriched CLI command docstrings (Prerequisites, Output, Examples, See Also) look reasonable? Any commands where the descriptions should be expanded or clarified?
  5. CLI redirects — which of the cli redirects do we need to keep? @abrahamdaniels (noticed you'd mentioned this on some new issues) ?

…-computing#704)

Remove cli/ from the generated API reference (it's a user tool, not a
public Python API) and replace it with an auto-generated CLI Reference
page under docs/docs/reference/cli.md.

The new generate_cli_reference.py script introspects the Typer app at
build time, extracting flags, types, defaults, help strings, and
structured docstring sections (Prerequisites, Output, Examples, See
Also). Strict mode (--strict) fails the build if any command has
incomplete documentation.

- Remove "cli" from PACKAGES in generate-ast.py
- Remove cli from audit_coverage.py discovery and quality scope
- Add generate_cli_reference.py with strict validation
- Integrate into build.py (Step 4, --strict) and CI workflow
- Add 21 unit tests for the generator (test_cli_reference.py)
- Wire docs-autogen tests into docs-publish CI workflow
- Enrich all CLI command docstrings with Prerequisites, Output,
  Examples, and See Also sections
- Add cross-links from 5 guide pages back to CLI reference
- Add 12 Mintlify redirects for old /api/cli/* URLs
- Remove dead m decompose glossary entry
- Add CLI docstring convention to CONTRIBUTING.md and AGENTS.md
- Add clidocs/clidocs-clean poe tasks
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

The full tooling/docs-autogen/ test suite has 13 pre-existing failures
in test_validate.py, test_escape_mdx.py, and test_anchor_collisions.py.
Scope the CI step to test_cli_reference.py to avoid blocking on
unrelated failures.
@planetf1 planetf1 marked this pull request as ready for review April 14, 2026 11:35
@planetf1 planetf1 requested a review from a team as a code owner April 14, 2026 11:35
- Fix wrong filename in module docstring (hyphens -> underscores)
- Validate before writing file (fail early with --strict)
- Add missing redirects for serve/ and fix/ old API pages
- Add Examples: section to CONTRIBUTING.md template and rules
- Convert See Also link text from URL slugs to human-readable titles
  with proper capitalisation (3/3 reviewer consensus)
- Remove dead discover_cli_commands() from audit_coverage.py
- Switch flag formatting from double to single backticks
- Filter --help param from synopsis, options tables, and strict validator
- Apply _rst_to_md to root intro text
- Simplify test_rst_backticks test now double backticks are gone
- Add clidocs/clidocs-clean to quick start
- Add Step 4 (generate_cli_reference.py) to pipeline overview
- Add generate_cli_reference.py and test file to file structure
- Remove cli/ from generated docs tree, add reference/cli.md
- Remove stale Makefile shim reference
- Fix make -> poe reference in validate step
Document the install command (matching CI) and Node.js requirement
for local doc builds and previews.
generate_cli_reference.py now catches ImportError during CLI app import
and prints the required install command instead of a raw traceback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add CLI reference and remove CLI internals from generated API docs

1 participant