Skip to content

Commands

docforge.cli.commands

Summary

Command definitions for the doc-forge CLI.

Provides the CLI structure using Click, including build, serve, and tree commands.


Notes
  • The build command validates requested modes before generating anything.
  • --mkdocs, --api, and --wiki share a single MkDocs build; --mcp generates a machine-readable bundle independently.

Classes

Functions

build

build(
    mcp: bool,
    mkdocs: bool,
    api: bool,
    wiki: bool,
    module_is_source: bool,
    module: str | None,
    openapi_spec: Path | None,
    project_name: str | None,
    site_name: str | None,
    docs_dir: Path,
    wiki_dir: Path,
    nav_file: Path,
    template: Path | None,
    mkdocs_yml: Path,
    out_dir: Path,
) -> None

Build documentation artifacts.

This command runs the full documentation pipeline: it loads Python modules, generates renderer-specific documentation sources, and optionally builds or serves the final output.

Depending on the selected options, the build can target:

  • MkDocs static documentation sites for library reference docs
  • Swagger-enabled API docs generated from an OpenAPI spec
  • Hand-written wiki pages included in the MkDocs site
  • MCP structured documentation resources
Notes
  • At least one of --mcp, --mkdocs, --wiki, or --api must be provided.
  • --mkdocs, --api, and --wiki are combined into a single MkDocs build, while --mcp emits a machine-readable bundle.

Parameters:

Name Type Description Default
mcp bool

Enable MCP documentation generation.

required
mkdocs bool

Enable MkDocs library documentation generation.

required
api bool

Enable API documentation generation from an OpenAPI spec.

required
wiki bool

Include a hand-written wiki directory in the MkDocs site.

required
module_is_source bool

Treat the specified module directory as the project root.

required
module str | None

Python module import path to document.

required
openapi_spec Path | None

Path to the OpenAPI JSON specification used for API docs.

required
project_name str | None

Optional override for the project name.

required
site_name str | None

Display name for the MkDocs site.

required
docs_dir Path

Shared documentation root used as the MkDocs docs_dir.

required
wiki_dir Path

Directory containing hand-written wiki markdown files.

required
nav_file Path

Path to the navigation specification file.

required
template Path | None

Optional custom MkDocs configuration template.

required
mkdocs_yml Path

Output path for the generated MkDocs configuration.

required
out_dir Path

Output directory for generated MCP resources.

required

Raises:

Type Description
UsageError

If required options are missing or conflicting.

serve

1
2
3
4
5
6
7
serve(
    mcp: bool,
    mkdocs: bool,
    module: str | None,
    mkdocs_yml: Path,
    out_dir: Path,
) -> None

Serve generated documentation locally.

Depending on the selected mode, this command starts either:

  • A MkDocs development server for browsing documentation
  • An MCP server exposing structured documentation resources

Parameters:

Name Type Description Default
mcp bool

Serve documentation using the MCP server.

required
mkdocs bool

Serve the MkDocs development site.

required
module str | None

Python module import path to serve via MCP.

required
mkdocs_yml Path

Path to the MkDocs configuration file.

required
out_dir Path

Root directory containing MCP documentation resources.

required

Raises:

Type Description
UsageError

If invalid or conflicting options are provided.

tree

tree(module: str, project_name: str | None) -> None

Display the documentation object tree for a module.

This command introspects the specified module and prints a hierarchical representation of the discovered documentation objects, including modules, classes, functions, and members.

Parameters:

Name Type Description Default
module str

Python module import path to introspect.

required
project_name str | None

Optional name to display as the project root.

required