docs: output generated sources under docs/lib and docs/mcp

This commit is contained in:
2026-09-10 21:11:30 +05:30
parent d4b79cf95a
commit a1c5f046d4
6 changed files with 26 additions and 16 deletions

View File

@@ -4,6 +4,7 @@
Utilities for working with MkDocs in the doc-forge CLI.
"""
import os
from importlib import resources
from pathlib import Path
@@ -20,6 +21,7 @@ def generate_sources(
docs_dir: Path,
project_name: str | None = None,
module_is_source: bool | None = None,
readme_dir: Path | None = None,
) -> None:
"""
Generate MkDocs Markdown sources for a Python module.
@@ -42,6 +44,10 @@ def generate_sources(
module_is_source (Optional[bool]):
If True, treat the specified module directory as the project root
rather than a nested module.
readme_dir (Optional[Path]):
Directory where the generated README.md should be written. If not
provided, defaults to the parent of ``docs_dir``.
"""
loader = GriffeLoader()
discovered_paths = discover_module_paths(module)
@@ -58,6 +64,7 @@ def generate_sources(
project,
docs_dir,
module_is_source,
readme_dir,
)
@@ -117,6 +124,7 @@ def generate_config(
data = yaml.safe_load(text)
data["site_name"] = site_name
data["docs_dir"] = Path(os.path.relpath(docs_dir, out.parent)).as_posix()
data["nav"] = nav_block
out.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8")