Compare commits

2 Commits

Author SHA1 Message Date
e8a01163fd updated doc string for how to use 2026-01-22 16:09:39 +05:30
9bccd7a82c removed ADS 2026-01-22 16:09:28 +05:30
6 changed files with 14 additions and 20 deletions

View File

@@ -92,13 +92,11 @@ def build(
@cli.command() @cli.command()
@click.option("--mcp", is_flag=True, help="Serve MCP documentation") @click.option("--mcp", is_flag=True, help="Serve MCP documentation")
@click.option("--mkdocs", is_flag=True, help="Serve MkDocs site") @click.option("--mkdocs", is_flag=True, help="Serve MkDocs site")
@click.option("--module", help="Python module to serve")
@click.option("--mkdocs-yml", type=click.Path(path_type=Path), default=Path("mkdocs.yml"), help="MkDocs config path") @click.option("--mkdocs-yml", type=click.Path(path_type=Path), default=Path("mkdocs.yml"), help="MkDocs config path")
@click.option("--out-dir", type=click.Path(path_type=Path), default=Path("mcp_docs"), help="MCP root directory") @click.option("--out-dir", type=click.Path(path_type=Path), default=Path("mcp_docs"), help="MCP root directory")
def serve( def serve(
mcp: bool, mcp: bool,
mkdocs: bool, mkdocs: bool,
module: Optional[str],
mkdocs_yml: Path, mkdocs_yml: Path,
out_dir: Path, out_dir: Path,
) -> None: ) -> None:
@@ -108,7 +106,6 @@ def serve(
Args: Args:
mcp: Serve MCP resources via an MCP server. mcp: Serve MCP resources via an MCP server.
mkdocs: Serve the MkDocs site using the built-in development server. mkdocs: Serve the MkDocs site using the built-in development server.
module: The dotted path of the module to serve.
mkdocs_yml: (MkDocs) Path to the mkdocs.yml configuration. mkdocs_yml: (MkDocs) Path to the mkdocs.yml configuration.
out_dir: (MCP) Path to the mcp_docs/ directory. out_dir: (MCP) Path to the mcp_docs/ directory.
""" """
@@ -116,38 +113,37 @@ def serve(
raise click.UsageError("Cannot specify both --mcp and --mkdocs") raise click.UsageError("Cannot specify both --mcp and --mkdocs")
if not mcp and not mkdocs: if not mcp and not mkdocs:
raise click.UsageError("Must specify either --mcp or --mkdocs") raise click.UsageError("Must specify either --mcp or --mkdocs")
if mcp and not module:
raise click.UsageError("--module is required for MCP serve")
if mkdocs: if mkdocs:
mkdocs_utils.serve(mkdocs_yml) mkdocs_utils.serve(mkdocs_yml)
elif mcp: elif mcp:
mcp_utils.serve(module, out_dir) mcp_utils.serve(out_dir)
@cli.command() @cli.command()
@click.option( @click.option(
"--module", "--modules",
multiple=True,
required=True, required=True,
help="Python module import path to introspect", help="Python module import paths to introspect",
) )
@click.option( @click.option(
"--project-name", "--project-name",
help="Project name (defaults to specified module)", help="Project name (defaults to first module)",
) )
def tree( def tree(
module: str, modules: Sequence[str],
project_name: Optional[str], project_name: Optional[str],
) -> None: ) -> None:
""" """
Visualize the project structure in the terminal. Visualize the project structure in the terminal.
Args: Args:
module: The module import path to recursively introspect. modules: List of module import paths to recursively introspect.
project_name: Optional override for the project name shown at the root. project_name: Optional override for the project name shown at the root.
""" """
loader = GriffeLoader() loader = GriffeLoader()
project = loader.load_project([module], project_name) project = loader.load_project(list(modules), project_name)
click.echo(project.name) click.echo(project.name)

View File

@@ -20,13 +20,12 @@ def build(
def serve( def serve(
mcp: bool, mcp: bool,
mkdocs: bool, mkdocs: bool,
module: Optional[str],
mkdocs_yml: Path, mkdocs_yml: Path,
out_dir: Path, out_dir: Path,
) -> None: ... ) -> None: ...
def tree( def tree(
module: str, modules: Sequence[str],
project_name: Optional[str], project_name: Optional[str],
) -> None: ... ) -> None: ...

View File

@@ -20,12 +20,11 @@ def generate_resources(module: str, project_name: str | None, out_dir: Path) ->
renderer = MCPRenderer() renderer = MCPRenderer()
renderer.generate_sources(project, out_dir) renderer.generate_sources(project, out_dir)
def serve(module: str, mcp_root: Path) -> None: def serve(mcp_root: Path) -> None:
""" """
Serve MCP documentation from a pre-built bundle. Serve MCP documentation from a pre-built bundle.
Args: Args:
module: The dotted path of the primary module to serve.
mcp_root: Path to the directory containing index.json, nav.json, and modules/. mcp_root: Path to the directory containing index.json, nav.json, and modules/.
""" """
if not mcp_root.exists(): if not mcp_root.exists():
@@ -43,6 +42,6 @@ def serve(module: str, mcp_root: Path) -> None:
server = MCPServer( server = MCPServer(
mcp_root=mcp_root, mcp_root=mcp_root,
name=f"{module}-mcp", name="doc-forge-mcp",
) )
server.run() server.run()

View File

@@ -1,4 +1,4 @@
from pathlib import Path from pathlib import Path
def generate_resources(module: str, project_name: str | None, out_dir: Path) -> None: ... def generate_resources(module: str, project_name: str | None, out_dir: Path) -> None: ...
def serve(module: str, mcp_root: Path) -> None: ... def serve(mcp_root: Path) -> None: ...

View File

@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "doc-forge" name = "doc-forge"
version = "0.0.4" version = "0.0.3"
description = "A renderer-agnostic Python documentation compiler" description = "A renderer-agnostic Python documentation compiler"
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"

View File

@@ -10,7 +10,7 @@ def test_mcp_serve(
result = cli_runner.invoke( result = cli_runner.invoke(
cli, cli,
["serve", "--mcp", "--module", "fake_module", "--out-dir", str(fake_mcp_docs)], ["serve", "--mcp", "--out-dir", str(fake_mcp_docs)],
) )
assert result.exit_code == 0 assert result.exit_code == 0