Flatten MkDocs Structure + --module-is-source Support (#4)
# Merge Request: Flatten MkDocs Structure + `--module-is-source` Support ## Summary This MR introduces structural improvements to the MkDocs generation pipeline to: 1. Ensure a root `docs/index.md` always exists 2. Flatten documentation structure (remove `docs/<module>/` nesting by default) 3. Add support for `--module-is-source` to treat the module as the documentation root 4. Align navigation (`docforge.nav.yml`) with the new flat layout 5. Regenerate MCP artifacts to reflect updated signatures and docstrings This resolves static hosting issues (e.g., Nginx 403 due to missing `site/index.html`) and makes each generated MkDocs site deployable as a standalone static website. --- ## Motivation Previously, documentation was generated under: ``` docs/<module>/... ``` Which resulted in: ``` site/<module>/index.html ``` When deployed at `/libs/<project>/`, this caused: * Missing `site/index.html` * Nginx returning 403 for root access * Inconsistent static hosting behavior This MR corrects the architecture so each MkDocs build is a valid static site with a root entry point. --- ## Key Changes ### 1️⃣ Flattened Docs Structure **Before** ``` docs/docforge/index.md ``` **After** ``` docs/index.md ``` All documentation paths were updated accordingly: * `docs/docforge/cli/...` → `docs/cli/...` * `docs/docforge/models/...` → `docs/models/...` * `docs/docforge/renderers/...` → `docs/renderers/...` Navigation updated to match the flat layout. --- ### 2️⃣ Root Index Enforcement `MkDocsRenderer` now guarantees: * `docs/index.md` is always created * Parent `index.md` files are auto-generated if missing * Parent indexes link to child modules (idempotent behavior) This ensures: ``` site/index.html ``` Always exists after `mkdocs build`. --- ### 3️⃣ New CLI Flag: `--module-is-source` Added option: ``` --module-is-source ``` Behavior: * Treats the provided module as the documentation root * Removes the top-level module folder from generated paths * Prevents redundant nesting when the module corresponds to the source root Updated components: * `cli.commands.build` * `mkdocs_utils.generate_sources` * `MkDocsRenderer.generate_sources` * Stub files (`.pyi`) * MCP JSON artifacts --- ### 4️⃣ Navigation Spec Update `docforge.nav.yml` updated: **Before** ```yaml home: docforge/index.md ``` **After** ```yaml home: index.md ``` All group paths adjusted to remove `docforge/` prefix. --- ### 5️⃣ MkDocs Config Update `mkdocs.yml` updated to: * Move `site_name` below theme/plugins * Use flat navigation paths * Point Home to `index.md` --- ### 6️⃣ MCP Artifact Regeneration Updated: * Function signatures (new parameter) * Docstrings (reflect `module_is_source`) * Renderer metadata * Line numbers Ensures MCP output matches updated API. --- ## Architectural Outcome Each project now produces a **valid standalone static site**: ``` site/ index.html assets/ search/ ``` Safe for deployment under: ``` /libs/<project>/ ``` No Nginx rewrites required. No directory-index issues. No nested-site ambiguity. --- ## Backward Compatibility * Existing CLI usage remains valid * `--module-is-source` is optional * Navigation spec format unchanged (only paths adjusted) --- ## Deployment Impact After merge: * Each library can be deployed independently * Sites can be merged under a shared root without internal conflicts * Static hosting is predictable and production-safe --- ## Testing * Verified MkDocs build produces `site/index.html` * Verified navigation renders correctly * Verified parent index generation is idempotent * Regenerated MCP docs and validated schema consistency --- ## Result The documentation compiler now: * Produces structurally correct static sites * Supports flat and source-root modes * Eliminates 403 root issues * Scales cleanly across multiple repositories This aligns doc-forge with proper static-site architectural invariants. Reviewed-on: #4 Co-authored-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com> Co-committed-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
"kind": "function",
|
||||
"path": "docforge.renderers.MkDocsRenderer.generate_sources",
|
||||
"signature": "<bound method Alias.signature of Alias('generate_sources', 'docforge.renderers.mkdocs_renderer.MkDocsRenderer.generate_sources')>",
|
||||
"docstring": "Produce a set of Markdown files in the output directory based on the\nprovided Project models.\n\nArgs:\n project: The project models to render.\n out_dir: Target directory for documentation files."
|
||||
"docstring": "Produce a set of Markdown files in the output directory based on the\nprovided Project models.\n\nArgs:\n project: The project models to render.\n out_dir: Target directory for documentation files.\n module_is_source: Module is the source folder and to be treated as the root folder."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -409,7 +409,7 @@
|
||||
"kind": "module",
|
||||
"path": "docforge.renderers.mkdocs_renderer",
|
||||
"signature": null,
|
||||
"docstring": "This module implements the MkDocsRenderer, which generates Markdown source files\ncompatible with the MkDocs 'material' theme and 'mkdocstrings' extension.",
|
||||
"docstring": "MkDocsRenderer\n\nGenerates Markdown source files compatible with MkDocs Material\nand mkdocstrings, ensuring:\n\n- Root index.md always exists\n- Parent package indexes are created automatically\n- Child modules are linked in parent index files",
|
||||
"members": {
|
||||
"Path": {
|
||||
"name": "Path",
|
||||
@@ -469,36 +469,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"MkDocsRenderer": {
|
||||
"name": "MkDocsRenderer",
|
||||
"kind": "class",
|
||||
"path": "docforge.renderers.mkdocs_renderer.MkDocsRenderer",
|
||||
"signature": "<bound method Class.signature of Class('MkDocsRenderer', 11, 91)>",
|
||||
"docstring": "Renderer that generates Markdown source files formatted for the MkDocs\n'mkdocstrings' plugin.",
|
||||
"members": {
|
||||
"name": {
|
||||
"name": "name",
|
||||
"kind": "attribute",
|
||||
"path": "docforge.renderers.mkdocs_renderer.MkDocsRenderer.name",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"generate_sources": {
|
||||
"name": "generate_sources",
|
||||
"kind": "function",
|
||||
"path": "docforge.renderers.mkdocs_renderer.MkDocsRenderer.generate_sources",
|
||||
"signature": "<bound method Function.signature of Function('generate_sources', 19, 38)>",
|
||||
"docstring": "Produce a set of Markdown files in the output directory based on the\nprovided Project models.\n\nArgs:\n project: The project models to render.\n out_dir: Target directory for documentation files."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Set": {
|
||||
"name": "Set",
|
||||
"kind": "alias",
|
||||
"path": "docforge.renderers.mkdocs_renderer.Set",
|
||||
"signature": "<bound method Alias.signature of Alias('Set', 'typing.Set')>",
|
||||
"docstring": null
|
||||
},
|
||||
"Module": {
|
||||
"name": "Module",
|
||||
"kind": "class",
|
||||
@@ -549,6 +519,29 @@
|
||||
"docstring": "Get all top-level objects in the module.\n\nReturns:\n An iterable of DocObject instances."
|
||||
}
|
||||
}
|
||||
},
|
||||
"MkDocsRenderer": {
|
||||
"name": "MkDocsRenderer",
|
||||
"kind": "class",
|
||||
"path": "docforge.renderers.mkdocs_renderer.MkDocsRenderer",
|
||||
"signature": "<bound method Class.signature of Class('MkDocsRenderer', 16, 168)>",
|
||||
"docstring": "Renderer that generates Markdown source files formatted for the MkDocs\n'mkdocstrings' plugin.",
|
||||
"members": {
|
||||
"name": {
|
||||
"name": "name",
|
||||
"kind": "attribute",
|
||||
"path": "docforge.renderers.mkdocs_renderer.MkDocsRenderer.name",
|
||||
"signature": null,
|
||||
"docstring": null
|
||||
},
|
||||
"generate_sources": {
|
||||
"name": "generate_sources",
|
||||
"kind": "function",
|
||||
"path": "docforge.renderers.mkdocs_renderer.MkDocsRenderer.generate_sources",
|
||||
"signature": "<bound method Function.signature of Function('generate_sources', 27, 60)>",
|
||||
"docstring": "Produce a set of Markdown files in the output directory based on the\nprovided Project models.\n\nArgs:\n project: The project models to render.\n out_dir: Target directory for documentation files.\n module_is_source: Module is the source folder and to be treated as the root folder."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user