- Consolidated CLI commands into [build](cci:1://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/mkdocs/logic.py:48:0-58:46) and [serve](cci:1://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/commands.py:70:0-92:32) using `--mkdocs` and `--mcp` flags. - Separated CLI orchestration logic into [docforge/cli/mkdocs/logic.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/mkdocs/logic.py:0:0-0:0) and [docforge/cli/mcp/logic.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/mcp/logic.py:0:0-0:0). - Moved command definitions to [docforge/cli/commands.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/commands.py:0:0-0:0), making [main.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/main.py:0:0-0:0) a thin entry point. - Aligned [.pyi](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/docforge/cli/main.pyi:0:0-0:0) type stubs with [.py](cci:7://file:///c:/Users/vishe/WorkSpace/code/aetos/doc-forge/tests/conftest.py:0:0-0:0) implementations across the package. - Added missing docstrings to internal helper functions and core classes. - Restructured tests into `tests/mkdocs/` and `tests/mcp/`. - Updated navigation specification to reflect the new project structure.
doc-forge
A renderer-agnostic Python documentation compiler that converts Python source code and docstrings into a structured, semantic documentation model and emits multiple downstream representations.
Features
- Single Source of Truth: Python source code and docstrings are the only authoritative input
- Renderer Agnosticism: MkDocs, Sphinx, MCP, or future renderers don't influence the core model
- Deterministic Output: Given the same codebase, outputs are reproducible
- AI-Native Documentation: Structured, queryable, and machine-consumable
- Library-First Design: All functionality accessible as a Python API
Installation
pip install doc-forge
Optional Dependencies
# For MkDocs rendering
pip install doc-forge[mkdocs]
# For Sphinx rendering
pip install doc-forge[sphinx]
# For MCP support
pip install doc-forge[mcp]
# For development
pip install doc-forge[dev]
Quick Start
Command Line Interface
# Generate MkDocs documentation
doc-forge generate --renderer mkdocs mypackage
# Build final HTML documentation
doc-forge build --renderer mkdocs mypackage
# Serve documentation locally
doc-forge serve --renderer mkdocs mypackage
# Export to MCP format
doc-forge export mypackage
# Start live MCP server
doc-forge server mypackage
Python API
from docforge.loaders import GriffeLoader
from docforge.renderers import MkDocsRenderer
from pathlib import Path
# Load your project
loader = GriffeLoader()
project = loader.load_project(["mypackage", "mypackage.utils"])
# Generate MkDocs sources
renderer = MkDocsRenderer()
renderer.generate_sources(project, Path("docs"))
# Build final documentation
from docforge.renderers.base import RendererConfig
config = RendererConfig(Path("docs"), project)
renderer.build(config)
Architecture
doc-forge follows this high-level architecture:
Python Source Code
↓
Introspection Layer (Griffe)
↓
Documentation Model (doc-forge core)
↓
Renderer / Exporter Layer
├── MkDocs
├── Sphinx
├── MCP (static JSON)
└── MCP Server (live)
Core Components
Documentation Model
- Project: Root container for all documentation
- Module: Represents Python modules
- DocObject: Base class for classes, functions, variables, etc.
- Navigation: Hierarchical structure for browsing
Renderers
- MkDocs Renderer: Generates Markdown with mkdocstrings directives
- Sphinx Renderer: Generates reStructuredText with autodoc directives
Exporters
- MCP Exporter: Creates static JSON bundles for machine consumption
- MCP Server: Live server for real-time documentation access
CLI Commands
generate
Generate renderer-specific source files without building final artifacts.
doc-forge generate --renderer mkdocs --out-dir docs mypackage
build
Build final documentation artifacts (HTML, etc.).
doc-forge build --renderer sphinx mypackage
serve
Start a local development server.
doc-forge serve --renderer mkdocs --port 9000 mypackage
export
Export to MCP format for machine consumption.
doc-forge export --out-dir mcp mypackage
server
Start live MCP server for real-time access.
doc-forge server --host 0.0.0.0 --port 8080 mypackage
Configuration
doc-forge is designed to work with minimal configuration. Most settings are derived automatically from your Python code structure.
MkDocs Configuration
The MkDocs renderer automatically generates mkdocs.yml with sensible defaults:
site_name: Your Project
plugins:
- mkdocstrings
theme:
name: material
Sphinx Configuration
The Sphinx renderer automatically generates conf.py with standard extensions:
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
]
MCP Integration
doc-forge provides two ways to integrate with MCP (Model Context Protocol):
Static Export
doc-forge export mypackage
Creates a static JSON bundle in mcp/ directory that can be loaded by MCP clients.
Live Server
doc-forge server mypackage
Starts a live MCP server providing real-time access to documentation resources:
docs://index- Project metadatadocs://nav- Navigation structuredocs://module/{module}- Individual module data
Development
Setup
git clone https://github.com/doc-forge/doc-forge
cd doc-forge
pip install -e ".[dev]"
Running Tests
pytest
Code Quality
black docforge/
ruff check docforge/
mypy docforge/
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Philosophy
doc-forge is built on these core principles:
- Single Source of Truth: Python source code and docstrings are the only authoritative input
- Renderer Agnosticism: The core model contains no renderer-specific logic
- Deterministic Output: Same input always produces same output
- AI-Native Documentation: Documentation must be structured, queryable, and machine-consumable
- Library-First: All functionality must be accessible as a Python API
doc-forge turns Python code into structured knowledge and emits it through multiple human and machine interfaces.