# 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>
141 lines
7.5 KiB
JSON
141 lines
7.5 KiB
JSON
{
|
|
"module": "docforge.renderers.mkdocs_renderer",
|
|
"content": {
|
|
"path": "docforge.renderers.mkdocs_renderer",
|
|
"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",
|
|
"objects": {
|
|
"Path": {
|
|
"name": "Path",
|
|
"kind": "alias",
|
|
"path": "docforge.renderers.mkdocs_renderer.Path",
|
|
"signature": "<bound method Alias.signature of Alias('Path', 'pathlib.Path')>",
|
|
"docstring": null
|
|
},
|
|
"Project": {
|
|
"name": "Project",
|
|
"kind": "class",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project",
|
|
"signature": "<bound method Alias.signature of Alias('Project', 'docforge.models.Project')>",
|
|
"docstring": "Represents a documentation project, serving as a container for modules.\n\nAttributes:\n name: Name of the project.\n modules: Dictionary mapping module paths to Module instances.",
|
|
"members": {
|
|
"name": {
|
|
"name": "name",
|
|
"kind": "attribute",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project.name",
|
|
"signature": "<bound method Alias.signature of Alias('name', 'docforge.models.project.Project.name')>",
|
|
"docstring": null
|
|
},
|
|
"modules": {
|
|
"name": "modules",
|
|
"kind": "attribute",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project.modules",
|
|
"signature": "<bound method Alias.signature of Alias('modules', 'docforge.models.project.Project.modules')>",
|
|
"docstring": null
|
|
},
|
|
"add_module": {
|
|
"name": "add_module",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project.add_module",
|
|
"signature": "<bound method Alias.signature of Alias('add_module', 'docforge.models.project.Project.add_module')>",
|
|
"docstring": "Add a module to the project.\n\nArgs:\n module: The module to add."
|
|
},
|
|
"get_module": {
|
|
"name": "get_module",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project.get_module",
|
|
"signature": "<bound method Alias.signature of Alias('get_module', 'docforge.models.project.Project.get_module')>",
|
|
"docstring": "Retrieve a module by its dotted path.\n\nArgs:\n path: The dotted path of the module (e.g., 'pkg.mod').\n\nReturns:\n The requested Module."
|
|
},
|
|
"get_all_modules": {
|
|
"name": "get_all_modules",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project.get_all_modules",
|
|
"signature": "<bound method Alias.signature of Alias('get_all_modules', 'docforge.models.project.Project.get_all_modules')>",
|
|
"docstring": "Get all modules in the project.\n\nReturns:\n An iterable of Module objects."
|
|
},
|
|
"get_module_list": {
|
|
"name": "get_module_list",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Project.get_module_list",
|
|
"signature": "<bound method Alias.signature of Alias('get_module_list', 'docforge.models.project.Project.get_module_list')>",
|
|
"docstring": "Get the list of all module dotted paths.\n\nReturns:\n A list of module paths."
|
|
}
|
|
}
|
|
},
|
|
"Module": {
|
|
"name": "Module",
|
|
"kind": "class",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module",
|
|
"signature": "<bound method Alias.signature of Alias('Module', 'docforge.models.Module')>",
|
|
"docstring": "Represents a documented Python module or package.\n\nAttributes:\n path: Dotted import path of the module.\n docstring: Module-level docstring content.\n members: Dictionary mapping object names to their DocObject representations.",
|
|
"members": {
|
|
"path": {
|
|
"name": "path",
|
|
"kind": "attribute",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module.path",
|
|
"signature": "<bound method Alias.signature of Alias('path', 'docforge.models.module.Module.path')>",
|
|
"docstring": null
|
|
},
|
|
"docstring": {
|
|
"name": "docstring",
|
|
"kind": "attribute",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module.docstring",
|
|
"signature": "<bound method Alias.signature of Alias('docstring', 'docforge.models.module.Module.docstring')>",
|
|
"docstring": null
|
|
},
|
|
"members": {
|
|
"name": "members",
|
|
"kind": "attribute",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module.members",
|
|
"signature": "<bound method Alias.signature of Alias('members', 'docforge.models.module.Module.members')>",
|
|
"docstring": null
|
|
},
|
|
"add_object": {
|
|
"name": "add_object",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module.add_object",
|
|
"signature": "<bound method Alias.signature of Alias('add_object', 'docforge.models.module.Module.add_object')>",
|
|
"docstring": "Add a documented object to the module.\n\nArgs:\n obj: The object to add."
|
|
},
|
|
"get_object": {
|
|
"name": "get_object",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module.get_object",
|
|
"signature": "<bound method Alias.signature of Alias('get_object', 'docforge.models.module.Module.get_object')>",
|
|
"docstring": "Retrieve a member object by name.\n\nArgs:\n name: The name of the object.\n\nReturns:\n The requested DocObject."
|
|
},
|
|
"get_all_objects": {
|
|
"name": "get_all_objects",
|
|
"kind": "function",
|
|
"path": "docforge.renderers.mkdocs_renderer.Module.get_all_objects",
|
|
"signature": "<bound method Alias.signature of Alias('get_all_objects', 'docforge.models.module.Module.get_all_objects')>",
|
|
"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."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |