diff --git a/README.md b/README.md index 8fccfd1..fdbec80 100644 --- a/README.md +++ b/README.md @@ -9,78 +9,95 @@ outputs without executing user code. --- -## Installation +# Installation Install using pip: - pip install doc-forge +```bash +pip install doc-forge +``` --- -## Quick start +# CLI usage -Generate a MkDocs site from a Python package: +## Generate an MkDocs site from a Python package: - doc-forge build --mkdocs --module my_package +```bash +doc-forge build --mkdocs --module my_package +``` -Generate MCP JSON documentation: +## Generate MCP JSON documentation: - doc-forge build --mcp --module my_package +```bash +doc-forge build --mcp --module my_package +``` -Serve documentation locally: - doc-forge serve --mkdocs --module my_package +## Generate MkDocs site and MCP JSON documentation: + +```bash +doc-forge build --mcp --mkdocs --module my_package +``` + +## Serve MkDocs locally: + +```bash +doc-forge serve --mkdocs --module my_package +``` + +## Serve MCP locally: + +```bash +doc-forge serve --mcp --module my_package +``` --- -## Core concepts - -**Loader** +# Core concepts +## Loader Extracts symbols, signatures, and docstrings using static analysis. -**Semantic model** - +## Semantic model Structured, renderer-agnostic representation of the API. -**Renderer** - +## Renderer Converts the semantic model into output formats such as MkDocs or MCP JSON. -**Symbol** +## Symbol +Any documentable object -Any documentable object: - - - module - - class - - function - - method - - property - - attribute +- module +- class +- function +- method +- property +- attribute --- -## Architecture +# Architecture `doc-forge` follows a compiler architecture: -Front-end: +## Front-end: - Static analysis of modules, classes, functions, type hints, and docstrings. +Static analysis of modules, classes, functions, type hints, and docstrings. -Middle-end: +## Middle-end: - Builds a semantic model describing symbols and relationships. +Builds a semantic model describing symbols and relationships. -Back-end: +## Back-end: - Renders documentation using interchangeable renderers. +Renders documentation using interchangeable renderers. This architecture ensures deterministic documentation generation. --- -## Rendering pipeline +# Rendering pipeline Typical flow: @@ -96,44 +113,6 @@ Typical flow: --- -## CLI usage - -Build MkDocs documentation: - - doc-forge build --mkdocs --module my_package - -Build MCP documentation: - - doc-forge build --mcp --module my_package - -Serve MkDocs locally: - - doc-forge serve --module my_package - ---- - -## Public API - -Loaders: - - GriffeLoader - discover_module_paths - -Renderers: - - MkDocsRenderer - MCPRenderer - -CLI: - - main - -Models: - - models - ---- - # Google-Styled Doc-Forge Convention (GSDFC) GSDFC defines how docstrings must be written so they render correctly in MkDocs and remain machine-parsable by doc-forge and AI tooling. @@ -149,299 +128,12 @@ GSDFC defines how docstrings must be written so they render correctly in MkDocs - Use **Markdown headings** at package and module level. - Use **Google-style structured sections** at class, function, and method level. -- Indent section contents using four spaces. - Use type hints in signatures instead of duplicating types in prose. - Write summaries in imperative form. - Sections are separated by ```---``` --- -## Package docstrings - -- Package docstrings act as the documentation home page. - -Recommended sections: - - ## Summary - ## Installation - ## Quick start - ## Core concepts - ## Architecture - ## Rendering pipeline - ## CLI usage - ## Public API - ## Examples - ## Notes - -Example: - Package Doc String: - - ''' - Foo-bar processing framework. - - Provides tools for defining Foo objects and executing Bar pipelines. - - --- - - # Installation - - pip install foo-bar - - --- - - # Quick start - - from foobar import Foo, BarEngine - - foo = Foo("example") - engine = BarEngine([foo]) - - result = engine.run() - - --- - - # Public API - - Foo - Bar - BarEngine - - --- - ''' - ---- - -## Module docstrings - -- Module docstrings describe a subsystem. - -Recommended sections: - - ## Summary - ## Examples - ## Notes - ## Public API - -Example: - Module Doc String: - - ''' - Foo execution subsystem. - - Provides utilities for executing Foo objects through Bar stages. - - --- - - Example: - - from foobar.engine import BarEngine - from foobar.foo import Foo - - foo = Foo("example") - - engine = BarEngine([foo]) - engine.run() - - --- - ''' - ---- - -## Class docstrings - -- Class docstrings define object responsibility, lifecycle, and attributes. - -Recommended sections: - - Attributes: - Notes: - Example: - Raises: - -Example: - Simple Foo: - - class Foo: - ''' - Represents a unit of work. - - Attributes: - name (str): - Identifier of the foo instance. - - value (int): - Numeric value associated with foo. - - Notes: - Guarantees: - - - instances are immutable after creation - - Lifecycle: - - - create instance - - pass to processing engine - - Example: - Create and inspect a Foo: - - foo = Foo("example", value=42) - print(foo.name) - ''' - - Complex Bar: - - class BarEngine: - ''' - Executes Foo objects through Bar stages. - - Attributes: - foos (tuple[Foo, ...]): - Foo instances managed by the engine. - - Notes: - Guarantees: - - - deterministic execution order - - Example: - Run engine: - - foo1 = Foo("a") - foo2 = Foo("b") - - engine = BarEngine([foo1, foo2]) - engine.run() - ''' - ---- - -## Function and method docstrings - -- Function docstrings define API contracts. - -Recommended sections: - - Args: - Returns: - Raises: - Yields: - Notes: - Example: - -Example: - Simple process method: - - def process(foo: Foo, multiplier: int) -> int: - ''' - Process a Foo instance. - - Args: - foo (Foo): - Foo instance to process. - - multiplier (int): - Value used to scale foo. - - Returns: - int: - Processed result. - - Raises: - ValueError: - If multiplier is negative. - - Notes: - Guarantees: - - - foo is not modified - - Example: - Process foo: - - foo = Foo("example", value=10) - - result = process(foo, multiplier=2) - print(result) - ''' - - Multiple Examples: - - def combine(foo_a: Foo, foo_b: Foo) -> Foo: - ''' - Combine two Foo instances. - - Args: - foo_a (Foo): - First foo. - - foo_b (Foo): - Second foo. - - Returns: - Foo: - Combined foo. - - Example: - Basic usage: - - foo1 = Foo("a") - foo2 = Foo("b") - - combined = combine(foo1, foo2) - - Pipeline usage: - - engine = BarEngine([foo1, foo2]) - engine.run() - ''' - ---- - -## Property docstrings - -- Properties must document return values. - -Example: - Property Doc String: - - @property - def foos(self) -> tuple[Foo, ...]: - ''' - Return contained Foo instances. - - Returns: - tuple[Foo, ...]: - Stored foo objects. - - Example: - container = FooContainer() - - foos = container.foos - ''' - ---- - -## Attribute documentation - -- Document attributes in class docstrings using Attributes:. - -Example: - Attribute Doc String: - - ''' - Represents a processing stage. - - Attributes: - id (str): - Unique identifier. - - enabled (bool): - Whether the stage is active. - ''' - ---- - ## Notes subsection grouping - Group related information using labeled subsections. @@ -468,26 +160,33 @@ Example: ## Example formatting - Use indentation for examples. +- Use code blocks for example code. Example: Single example: Example: + ```python foo = Foo("example") process(foo, multiplier=2) + ``` Multiple examples: Example: Create foo: - foo = Foo("example") + ```python + foo = Foo("example") + ``` Run engine: - engine = BarEngine([foo]) - engine.run() + ```python + engine = BarEngine([foo]) + engine.run() + ``` Avoid fenced code blocks inside structured sections. @@ -496,8 +195,9 @@ Avoid fenced code blocks inside structured sections. ## Separator rules Use horizontal separators only at docstring root level to separate sections: - - --- +```markdown +--- +``` Allowed locations: @@ -509,6 +209,312 @@ Do not use separators inside code sections. --- +## Package docstrings + +- Package docstrings act as the documentation home page. + +Recommended sections: + + # Summary + # Installation + # Quick start + # CLI usage + # Core concepts + # Architecture + # Rendering pipeline + # Examples + # Notes + +Example: + Package Doc String: + + ''' + Foo-bar processing framework. + + Provides tools for defining Foo objects and executing Bar pipelines. + + --- + + # Installation + + ```bash + pip install foo-bar + ``` + + --- + + # Quick start + + ```python + from foobar import Foo, BarEngine + + foo = Foo("example") + engine = BarEngine([foo]) + + result = engine.run() + ``` + + --- + ''' + +--- + +## Module docstrings + +- Module docstrings describe a subsystem. + +Recommended sections: + + # Summary + # Examples + # Notes + +Example: + Module Doc String: + + ''' + Foo execution subsystem. + + Provides utilities for executing Foo objects through Bar stages. + + --- + + Example: + + ```python + from foobar.engine import BarEngine + from foobar.foo import Foo + + foo = Foo("example") + + engine = BarEngine([foo]) + engine.run() + ``` + + --- + ''' + +--- + +## Class docstrings + +- Class docstrings define object responsibility, lifecycle, and attributes. + +Recommended sections: + + Attributes: + Notes: + Example: + Raises: + +Example: + Simple Foo: + + ```python + class Foo: + ''' + Represents a unit of work. + + Attributes: + name (str): + Identifier of the foo instance. + + value (int): + Numeric value associated with foo. + + Notes: + Guarantees: + + - instances are immutable after creation + + Lifecycle: + + - create instance + - pass to processing engine + + Example: + Create and inspect a Foo: + + ```python + foo = Foo("example", value=42) + print(foo.name) + ``` + ''' + ``` + + Complex Bar: + + ```python + class BarEngine: + ''' + Executes Foo objects through Bar stages. + + Attributes: + foos (tuple[Foo, ...]): + Foo instances managed by the engine. + + Notes: + Guarantees: + + - deterministic execution order + + Example: + Run engine: + + ```python + foo1 = Foo("a") + foo2 = Foo("b") + + engine = BarEngine([foo1, foo2]) + engine.run() + ``` + ''' + ``` + +--- + +## Function and method docstrings + +- Function docstrings define API contracts. + +Recommended sections: + + Args: + Returns: + Raises: + Yields: + Notes: + Example: + +Example: + Simple process method: + + ```python + def process(foo: Foo, multiplier: int) -> int: + ''' + Process a Foo instance. + + Args: + foo (Foo): + Foo instance to process. + + multiplier (int): + Value used to scale foo. + + Returns: + int: + Processed result. + + Raises: + ValueError: + If multiplier is negative. + + Notes: + Guarantees: + + - foo is not modified + + Example: + Process foo: + + ```python + foo = Foo("example", value=10) + + result = process(foo, multiplier=2) + print(result) + ``` + ''' + ``` + + Multiple Examples: + + ```python + def combine(foo_a: Foo, foo_b: Foo) -> Foo: + ''' + Combine two Foo instances. + + Args: + foo_a (Foo): + First foo. + + foo_b (Foo): + Second foo. + + Returns: + Foo: + Combined foo. + + Example: + Basic usage: + + ```python + foo1 = Foo("a") + foo2 = Foo("b") + + combined = combine(foo1, foo2) + ``` + + Pipeline usage: + + ```python + engine = BarEngine([foo1, foo2]) + engine.run() + ``` + ''' + ``` + +--- + +## Property docstrings + +- Properties must document return values. + +Example: + Property Doc String: + + ```python + @property + def foos(self) -> tuple[Foo, ...]: + ''' + Return contained Foo instances. + + Returns: + tuple[Foo, ...]: + Stored foo objects. + + Example: + ```python + container = FooContainer() + + foos = container.foos + ``` + ''' + ``` + +--- + +## Attribute documentation + +- Document attributes in class docstrings using Attributes:. + +Example: + Attribute Doc String: + + ```python + ''' + Represents a processing stage. + + Attributes: + id (str): + Unique identifier. + + enabled (bool): + Whether the stage is active. + ''' + ``` + +--- + ## Parsing guarantees GSDFC ensures doc-forge can deterministically extract: diff --git a/docforge/__init__.py b/docforge/__init__.py index 751e492..549359b 100644 --- a/docforge/__init__.py +++ b/docforge/__init__.py @@ -8,78 +8,95 @@ outputs without executing user code. --- -## Installation +# Installation Install using pip: - pip install doc-forge +```bash +pip install doc-forge +``` --- -## Quick start +# CLI usage -Generate a MkDocs site from a Python package: +## Generate an MkDocs site from a Python package: - doc-forge build --mkdocs --module my_package +```bash +doc-forge build --mkdocs --module my_package +``` -Generate MCP JSON documentation: +## Generate MCP JSON documentation: - doc-forge build --mcp --module my_package +```bash +doc-forge build --mcp --module my_package +``` -Serve documentation locally: - doc-forge serve --mkdocs --module my_package +## Generate MkDocs site and MCP JSON documentation: + +```bash +doc-forge build --mcp --mkdocs --module my_package +``` + +## Serve MkDocs locally: + +```bash +doc-forge serve --mkdocs --module my_package +``` + +## Serve MCP locally: + +```bash +doc-forge serve --mcp --module my_package +``` --- -## Core concepts - -**Loader** +# Core concepts +## Loader Extracts symbols, signatures, and docstrings using static analysis. -**Semantic model** - +## Semantic model Structured, renderer-agnostic representation of the API. -**Renderer** - +## Renderer Converts the semantic model into output formats such as MkDocs or MCP JSON. -**Symbol** +## Symbol +Any documentable object -Any documentable object: - - - module - - class - - function - - method - - property - - attribute +- module +- class +- function +- method +- property +- attribute --- -## Architecture +# Architecture `doc-forge` follows a compiler architecture: -Front-end: +## Front-end: - Static analysis of modules, classes, functions, type hints, and docstrings. +Static analysis of modules, classes, functions, type hints, and docstrings. -Middle-end: +## Middle-end: - Builds a semantic model describing symbols and relationships. +Builds a semantic model describing symbols and relationships. -Back-end: +## Back-end: - Renders documentation using interchangeable renderers. +Renders documentation using interchangeable renderers. This architecture ensures deterministic documentation generation. --- -## Rendering pipeline +# Rendering pipeline Typical flow: @@ -95,44 +112,6 @@ Typical flow: --- -## CLI usage - -Build MkDocs documentation: - - doc-forge build --mkdocs --module my_package - -Build MCP documentation: - - doc-forge build --mcp --module my_package - -Serve MkDocs locally: - - doc-forge serve --module my_package - ---- - -## Public API - -Loaders: - - GriffeLoader - discover_module_paths - -Renderers: - - MkDocsRenderer - MCPRenderer - -CLI: - - main - -Models: - - models - ---- - # Google-Styled Doc-Forge Convention (GSDFC) GSDFC defines how docstrings must be written so they render correctly in MkDocs and remain machine-parsable by doc-forge and AI tooling. @@ -148,299 +127,12 @@ GSDFC defines how docstrings must be written so they render correctly in MkDocs - Use **Markdown headings** at package and module level. - Use **Google-style structured sections** at class, function, and method level. -- Indent section contents using four spaces. - Use type hints in signatures instead of duplicating types in prose. - Write summaries in imperative form. - Sections are separated by ```---``` --- -## Package docstrings - -- Package docstrings act as the documentation home page. - -Recommended sections: - - ## Summary - ## Installation - ## Quick start - ## Core concepts - ## Architecture - ## Rendering pipeline - ## CLI usage - ## Public API - ## Examples - ## Notes - -Example: - Package Doc String: - - ''' - Foo-bar processing framework. - - Provides tools for defining Foo objects and executing Bar pipelines. - - --- - - # Installation - - pip install foo-bar - - --- - - # Quick start - - from foobar import Foo, BarEngine - - foo = Foo("example") - engine = BarEngine([foo]) - - result = engine.run() - - --- - - # Public API - - Foo - Bar - BarEngine - - --- - ''' - ---- - -## Module docstrings - -- Module docstrings describe a subsystem. - -Recommended sections: - - ## Summary - ## Examples - ## Notes - ## Public API - -Example: - Module Doc String: - - ''' - Foo execution subsystem. - - Provides utilities for executing Foo objects through Bar stages. - - --- - - Example: - - from foobar.engine import BarEngine - from foobar.foo import Foo - - foo = Foo("example") - - engine = BarEngine([foo]) - engine.run() - - --- - ''' - ---- - -## Class docstrings - -- Class docstrings define object responsibility, lifecycle, and attributes. - -Recommended sections: - - Attributes: - Notes: - Example: - Raises: - -Example: - Simple Foo: - - class Foo: - ''' - Represents a unit of work. - - Attributes: - name (str): - Identifier of the foo instance. - - value (int): - Numeric value associated with foo. - - Notes: - Guarantees: - - - instances are immutable after creation - - Lifecycle: - - - create instance - - pass to processing engine - - Example: - Create and inspect a Foo: - - foo = Foo("example", value=42) - print(foo.name) - ''' - - Complex Bar: - - class BarEngine: - ''' - Executes Foo objects through Bar stages. - - Attributes: - foos (tuple[Foo, ...]): - Foo instances managed by the engine. - - Notes: - Guarantees: - - - deterministic execution order - - Example: - Run engine: - - foo1 = Foo("a") - foo2 = Foo("b") - - engine = BarEngine([foo1, foo2]) - engine.run() - ''' - ---- - -## Function and method docstrings - -- Function docstrings define API contracts. - -Recommended sections: - - Args: - Returns: - Raises: - Yields: - Notes: - Example: - -Example: - Simple process method: - - def process(foo: Foo, multiplier: int) -> int: - ''' - Process a Foo instance. - - Args: - foo (Foo): - Foo instance to process. - - multiplier (int): - Value used to scale foo. - - Returns: - int: - Processed result. - - Raises: - ValueError: - If multiplier is negative. - - Notes: - Guarantees: - - - foo is not modified - - Example: - Process foo: - - foo = Foo("example", value=10) - - result = process(foo, multiplier=2) - print(result) - ''' - - Multiple Examples: - - def combine(foo_a: Foo, foo_b: Foo) -> Foo: - ''' - Combine two Foo instances. - - Args: - foo_a (Foo): - First foo. - - foo_b (Foo): - Second foo. - - Returns: - Foo: - Combined foo. - - Example: - Basic usage: - - foo1 = Foo("a") - foo2 = Foo("b") - - combined = combine(foo1, foo2) - - Pipeline usage: - - engine = BarEngine([foo1, foo2]) - engine.run() - ''' - ---- - -## Property docstrings - -- Properties must document return values. - -Example: - Property Doc String: - - @property - def foos(self) -> tuple[Foo, ...]: - ''' - Return contained Foo instances. - - Returns: - tuple[Foo, ...]: - Stored foo objects. - - Example: - container = FooContainer() - - foos = container.foos - ''' - ---- - -## Attribute documentation - -- Document attributes in class docstrings using Attributes:. - -Example: - Attribute Doc String: - - ''' - Represents a processing stage. - - Attributes: - id (str): - Unique identifier. - - enabled (bool): - Whether the stage is active. - ''' - ---- - ## Notes subsection grouping - Group related information using labeled subsections. @@ -467,26 +159,33 @@ Example: ## Example formatting - Use indentation for examples. +- Use code blocks for example code. Example: Single example: Example: + ```python foo = Foo("example") process(foo, multiplier=2) + ``` Multiple examples: Example: Create foo: - foo = Foo("example") + ```python + foo = Foo("example") + ``` Run engine: - engine = BarEngine([foo]) - engine.run() + ```python + engine = BarEngine([foo]) + engine.run() + ``` Avoid fenced code blocks inside structured sections. @@ -495,8 +194,9 @@ Avoid fenced code blocks inside structured sections. ## Separator rules Use horizontal separators only at docstring root level to separate sections: - - --- +```markdown +--- +``` Allowed locations: @@ -508,6 +208,312 @@ Do not use separators inside code sections. --- +## Package docstrings + +- Package docstrings act as the documentation home page. + +Recommended sections: + + # Summary + # Installation + # Quick start + # CLI usage + # Core concepts + # Architecture + # Rendering pipeline + # Examples + # Notes + +Example: + Package Doc String: + + ''' + Foo-bar processing framework. + + Provides tools for defining Foo objects and executing Bar pipelines. + + --- + + # Installation + + ```bash + pip install foo-bar + ``` + + --- + + # Quick start + + ```python + from foobar import Foo, BarEngine + + foo = Foo("example") + engine = BarEngine([foo]) + + result = engine.run() + ``` + + --- + ''' + +--- + +## Module docstrings + +- Module docstrings describe a subsystem. + +Recommended sections: + + # Summary + # Examples + # Notes + +Example: + Module Doc String: + + ''' + Foo execution subsystem. + + Provides utilities for executing Foo objects through Bar stages. + + --- + + Example: + + ```python + from foobar.engine import BarEngine + from foobar.foo import Foo + + foo = Foo("example") + + engine = BarEngine([foo]) + engine.run() + ``` + + --- + ''' + +--- + +## Class docstrings + +- Class docstrings define object responsibility, lifecycle, and attributes. + +Recommended sections: + + Attributes: + Notes: + Example: + Raises: + +Example: + Simple Foo: + + ```python + class Foo: + ''' + Represents a unit of work. + + Attributes: + name (str): + Identifier of the foo instance. + + value (int): + Numeric value associated with foo. + + Notes: + Guarantees: + + - instances are immutable after creation + + Lifecycle: + + - create instance + - pass to processing engine + + Example: + Create and inspect a Foo: + + ```python + foo = Foo("example", value=42) + print(foo.name) + ``` + ''' + ``` + + Complex Bar: + + ```python + class BarEngine: + ''' + Executes Foo objects through Bar stages. + + Attributes: + foos (tuple[Foo, ...]): + Foo instances managed by the engine. + + Notes: + Guarantees: + + - deterministic execution order + + Example: + Run engine: + + ```python + foo1 = Foo("a") + foo2 = Foo("b") + + engine = BarEngine([foo1, foo2]) + engine.run() + ``` + ''' + ``` + +--- + +## Function and method docstrings + +- Function docstrings define API contracts. + +Recommended sections: + + Args: + Returns: + Raises: + Yields: + Notes: + Example: + +Example: + Simple process method: + + ```python + def process(foo: Foo, multiplier: int) -> int: + ''' + Process a Foo instance. + + Args: + foo (Foo): + Foo instance to process. + + multiplier (int): + Value used to scale foo. + + Returns: + int: + Processed result. + + Raises: + ValueError: + If multiplier is negative. + + Notes: + Guarantees: + + - foo is not modified + + Example: + Process foo: + + ```python + foo = Foo("example", value=10) + + result = process(foo, multiplier=2) + print(result) + ``` + ''' + ``` + + Multiple Examples: + + ```python + def combine(foo_a: Foo, foo_b: Foo) -> Foo: + ''' + Combine two Foo instances. + + Args: + foo_a (Foo): + First foo. + + foo_b (Foo): + Second foo. + + Returns: + Foo: + Combined foo. + + Example: + Basic usage: + + ```python + foo1 = Foo("a") + foo2 = Foo("b") + + combined = combine(foo1, foo2) + ``` + + Pipeline usage: + + ```python + engine = BarEngine([foo1, foo2]) + engine.run() + ``` + ''' + ``` + +--- + +## Property docstrings + +- Properties must document return values. + +Example: + Property Doc String: + + ```python + @property + def foos(self) -> tuple[Foo, ...]: + ''' + Return contained Foo instances. + + Returns: + tuple[Foo, ...]: + Stored foo objects. + + Example: + ```python + container = FooContainer() + + foos = container.foos + ``` + ''' + ``` + +--- + +## Attribute documentation + +- Document attributes in class docstrings using Attributes:. + +Example: + Attribute Doc String: + + ```python + ''' + Represents a processing stage. + + Attributes: + id (str): + Unique identifier. + + enabled (bool): + Whether the stage is active. + ''' + ``` + +--- + ## Parsing guarantees GSDFC ensures doc-forge can deterministically extract: diff --git a/mcp_docs/modules/docforge.json b/mcp_docs/modules/docforge.json index bfc37df..64675dc 100644 --- a/mcp_docs/modules/docforge.json +++ b/mcp_docs/modules/docforge.json @@ -2,7 +2,7 @@ "module": "docforge", "content": { "path": "docforge", - "docstring": "Renderer-agnostic Python documentation compiler that converts Python docstrings\ninto structured documentation for both humans (MkDocs) and machines (MCP / AI agents).\n\n`doc-forge` statically analyzes source code, builds a semantic model of modules,\nclasses, functions, and attributes, and renders that model into documentation\noutputs without executing user code.\n\n---\n\n## Installation\n\nInstall using pip:\n\n pip install doc-forge\n\n---\n\n## Quick start\n\nGenerate a MkDocs site from a Python package:\n\n doc-forge build --mkdocs --module my_package\n\nGenerate MCP JSON documentation:\n\n doc-forge build --mcp --module my_package\n\nServe documentation locally:\n\n doc-forge serve --mkdocs --module my_package\n\n---\n\n## Core concepts\n\n**Loader**\n\nExtracts symbols, signatures, and docstrings using static analysis.\n\n**Semantic model**\n\nStructured, renderer-agnostic representation of the API.\n\n**Renderer**\n\nConverts the semantic model into output formats such as MkDocs or MCP JSON.\n\n**Symbol**\n\nAny documentable object:\n\n - module\n - class\n - function\n - method\n - property\n - attribute\n\n---\n\n## Architecture\n\n`doc-forge` follows a compiler architecture:\n\nFront-end:\n\n Static analysis of modules, classes, functions, type hints, and docstrings.\n\nMiddle-end:\n\n Builds a semantic model describing symbols and relationships.\n\nBack-end:\n\n Renders documentation using interchangeable renderers.\n\nThis architecture ensures deterministic documentation generation.\n\n---\n\n## Rendering pipeline\n\nTypical flow:\n\n Python package\n ↓\n Loader (static analysis)\n ↓\n Semantic model\n ↓\n Renderer\n ↓\n MkDocs site or MCP JSON\n\n---\n\n## CLI usage\n\nBuild MkDocs documentation:\n\n doc-forge build --mkdocs --module my_package\n\nBuild MCP documentation:\n\n doc-forge build --mcp --module my_package\n\nServe MkDocs locally:\n\n doc-forge serve --module my_package\n\n---\n\n## Public API\n\nLoaders:\n\n GriffeLoader\n discover_module_paths\n\nRenderers:\n\n MkDocsRenderer\n MCPRenderer\n\nCLI:\n\n main\n\nModels:\n\n models\n\n---\n\n# Google-Styled Doc-Forge Convention (GSDFC)\n\nGSDFC defines how docstrings must be written so they render correctly in MkDocs and remain machine-parsable by doc-forge and AI tooling.\n\n- Docstrings are the single source of truth.\n- doc-forge compiles docstrings but does not generate documentation content.\n- Documentation follows the Python import hierarchy.\n- Every public symbol should have a complete and accurate docstring.\n\n---\n\n## General rules\n\n- Use **Markdown headings** at package and module level.\n- Use **Google-style structured sections** at class, function, and method level.\n- Indent section contents using four spaces.\n- Use type hints in signatures instead of duplicating types in prose.\n- Write summaries in imperative form.\n- Sections are separated by ```---```\n\n---\n\n## Package docstrings\n\n- Package docstrings act as the documentation home page.\n\nRecommended sections:\n\n ## Summary\n ## Installation\n ## Quick start\n ## Core concepts\n ## Architecture\n ## Rendering pipeline\n ## CLI usage\n ## Public API\n ## Examples\n ## Notes\n\nExample:\n Package Doc String:\n\n '''\n Foo-bar processing framework.\n\n Provides tools for defining Foo objects and executing Bar pipelines.\n\n ---\n\n # Installation\n\n pip install foo-bar\n\n ---\n\n # Quick start\n\n from foobar import Foo, BarEngine\n\n foo = Foo(\"example\")\n engine = BarEngine([foo])\n\n result = engine.run()\n\n ---\n\n # Public API\n\n Foo\n Bar\n BarEngine\n\n ---\n '''\n\n---\n\n## Module docstrings\n\n- Module docstrings describe a subsystem.\n\nRecommended sections:\n\n ## Summary\n ## Examples\n ## Notes\n ## Public API\n\nExample:\n Module Doc String:\n\n '''\n Foo execution subsystem.\n\n Provides utilities for executing Foo objects through Bar stages.\n\n ---\n\n Example:\n\n from foobar.engine import BarEngine\n from foobar.foo import Foo\n\n foo = Foo(\"example\")\n\n engine = BarEngine([foo])\n engine.run()\n\n ---\n '''\n\n---\n\n## Class docstrings\n\n- Class docstrings define object responsibility, lifecycle, and attributes.\n\nRecommended sections:\n\n Attributes:\n Notes:\n Example:\n Raises:\n\nExample:\n Simple Foo:\n\n class Foo:\n '''\n Represents a unit of work.\n\n Attributes:\n name (str):\n Identifier of the foo instance.\n\n value (int):\n Numeric value associated with foo.\n\n Notes:\n Guarantees:\n\n - instances are immutable after creation\n\n Lifecycle:\n\n - create instance\n - pass to processing engine\n\n Example:\n Create and inspect a Foo:\n\n foo = Foo(\"example\", value=42)\n print(foo.name)\n '''\n\n Complex Bar:\n\n class BarEngine:\n '''\n Executes Foo objects through Bar stages.\n\n Attributes:\n foos (tuple[Foo, ...]):\n Foo instances managed by the engine.\n\n Notes:\n Guarantees:\n\n - deterministic execution order\n\n Example:\n Run engine:\n\n foo1 = Foo(\"a\")\n foo2 = Foo(\"b\")\n\n engine = BarEngine([foo1, foo2])\n engine.run()\n '''\n\n---\n\n## Function and method docstrings\n\n- Function docstrings define API contracts.\n\nRecommended sections:\n\n Args:\n Returns:\n Raises:\n Yields:\n Notes:\n Example:\n\nExample:\n Simple process method:\n\n def process(foo: Foo, multiplier: int) -> int:\n '''\n Process a Foo instance.\n\n Args:\n foo (Foo):\n Foo instance to process.\n\n multiplier (int):\n Value used to scale foo.\n\n Returns:\n int:\n Processed result.\n\n Raises:\n ValueError:\n If multiplier is negative.\n\n Notes:\n Guarantees:\n\n - foo is not modified\n\n Example:\n Process foo:\n\n foo = Foo(\"example\", value=10)\n\n result = process(foo, multiplier=2)\n print(result)\n '''\n\n Multiple Examples:\n\n def combine(foo_a: Foo, foo_b: Foo) -> Foo:\n '''\n Combine two Foo instances.\n\n Args:\n foo_a (Foo):\n First foo.\n\n foo_b (Foo):\n Second foo.\n\n Returns:\n Foo:\n Combined foo.\n\n Example:\n Basic usage:\n\n foo1 = Foo(\"a\")\n foo2 = Foo(\"b\")\n\n combined = combine(foo1, foo2)\n\n Pipeline usage:\n\n engine = BarEngine([foo1, foo2])\n engine.run()\n '''\n\n---\n\n## Property docstrings\n\n- Properties must document return values.\n\nExample:\n Property Doc String:\n\n @property\n def foos(self) -> tuple[Foo, ...]:\n '''\n Return contained Foo instances.\n\n Returns:\n tuple[Foo, ...]:\n Stored foo objects.\n\n Example:\n container = FooContainer()\n\n foos = container.foos\n '''\n\n---\n\n## Attribute documentation\n\n- Document attributes in class docstrings using Attributes:.\n\nExample:\n Attribute Doc String:\n\n '''\n Represents a processing stage.\n\n Attributes:\n id (str):\n Unique identifier.\n\n enabled (bool):\n Whether the stage is active.\n '''\n\n---\n\n## Notes subsection grouping\n\n- Group related information using labeled subsections.\n\nExample:\n Notes Example:\n\n Notes:\n **Guarantees:**\n\n - deterministic behavior\n\n **Lifecycle:**\n\n - created during initialization\n - reused across executions\n\n **Thread safety:**\n\n - safe for concurrent reads\n\n---\n\n## Example formatting\n\n- Use indentation for examples.\n\nExample:\n Single example:\n\n Example:\n\n foo = Foo(\"example\")\n process(foo, multiplier=2)\n\n Multiple examples:\n\n Example:\n Create foo:\n\n foo = Foo(\"example\")\n\n Run engine:\n\n engine = BarEngine([foo])\n engine.run()\n\nAvoid fenced code blocks inside structured sections.\n\n---\n\n## Separator rules\n\nUse horizontal separators only at docstring root level to separate sections:\n\n ---\n\nAllowed locations:\n\n- package docstrings\n- module docstrings\n- major documentation sections\n\nDo not use separators inside code sections.\n\n---\n\n## Parsing guarantees\n\nGSDFC ensures doc-forge can deterministically extract:\n\n- symbol kind (module, class, function, property, attribute)\n- symbol name\n- parameters\n- return values\n- attributes\n- examples\n- structured Notes subsections\n\nThis enables:\n\n- reliable MkDocs rendering\n- deterministic MCP export\n- accurate AI semantic interpretation\n\n---\n\nNotes:\n - doc-forge never executes analyzed modules.\n - Documentation is generated entirely through static analysis.", + "docstring": "Renderer-agnostic Python documentation compiler that converts Python docstrings\ninto structured documentation for both humans (MkDocs) and machines (MCP / AI agents).\n\n`doc-forge` statically analyzes source code, builds a semantic model of modules,\nclasses, functions, and attributes, and renders that model into documentation\noutputs without executing user code.\n\n---\n\n# Installation\n\nInstall using pip:\n\n```bash\npip install doc-forge\n```\n\n---\n\n# CLI usage\n\n## Generate an MkDocs site from a Python package:\n\n```bash\ndoc-forge build --mkdocs --module my_package\n```\n\n## Generate MCP JSON documentation:\n\n```bash\ndoc-forge build --mcp --module my_package\n```\n\n\n## Generate MkDocs site and MCP JSON documentation:\n\n```bash\ndoc-forge build --mcp --mkdocs --module my_package\n```\n\n## Serve MkDocs locally:\n\n```bash\ndoc-forge serve --mkdocs --module my_package\n```\n\n## Serve MCP locally:\n\n```bash\ndoc-forge serve --mcp --module my_package\n```\n\n---\n\n# Core concepts\n\n## Loader\nExtracts symbols, signatures, and docstrings using static analysis.\n\n## Semantic model\nStructured, renderer-agnostic representation of the API.\n\n## Renderer\nConverts the semantic model into output formats such as MkDocs or MCP JSON.\n\n## Symbol\nAny documentable object\n\n- module\n- class\n- function\n- method\n- property\n- attribute\n\n---\n\n# Architecture\n\n`doc-forge` follows a compiler architecture:\n\n## Front-end:\n\nStatic analysis of modules, classes, functions, type hints, and docstrings.\n\n## Middle-end:\n\nBuilds a semantic model describing symbols and relationships.\n\n## Back-end:\n\nRenders documentation using interchangeable renderers.\n\nThis architecture ensures deterministic documentation generation.\n\n---\n\n# Rendering pipeline\n\nTypical flow:\n\n Python package\n ↓\n Loader (static analysis)\n ↓\n Semantic model\n ↓\n Renderer\n ↓\n MkDocs site or MCP JSON\n\n---\n\n# Google-Styled Doc-Forge Convention (GSDFC)\n\nGSDFC defines how docstrings must be written so they render correctly in MkDocs and remain machine-parsable by doc-forge and AI tooling.\n\n- Docstrings are the single source of truth.\n- doc-forge compiles docstrings but does not generate documentation content.\n- Documentation follows the Python import hierarchy.\n- Every public symbol should have a complete and accurate docstring.\n\n---\n\n## General rules\n\n- Use **Markdown headings** at package and module level.\n- Use **Google-style structured sections** at class, function, and method level.\n- Use type hints in signatures instead of duplicating types in prose.\n- Write summaries in imperative form.\n- Sections are separated by ```---```\n\n---\n\n## Notes subsection grouping\n\n- Group related information using labeled subsections.\n\nExample:\n Notes Example:\n\n Notes:\n **Guarantees:**\n\n - deterministic behavior\n\n **Lifecycle:**\n\n - created during initialization\n - reused across executions\n\n **Thread safety:**\n\n - safe for concurrent reads\n\n---\n\n## Example formatting\n\n- Use indentation for examples.\n- Use code blocks for example code.\n\nExample:\n Single example:\n\n Example:\n\n ```python\n foo = Foo(\"example\")\n process(foo, multiplier=2)\n ```\n\n Multiple examples:\n\n Example:\n Create foo:\n\n ```python\n foo = Foo(\"example\")\n ```\n\n Run engine:\n\n ```python\n engine = BarEngine([foo])\n engine.run()\n ```\n\nAvoid fenced code blocks inside structured sections.\n\n---\n\n## Separator rules\n\nUse horizontal separators only at docstring root level to separate sections:\n```markdown\n---\n```\n\nAllowed locations:\n\n- package docstrings\n- module docstrings\n- major documentation sections\n\nDo not use separators inside code sections.\n\n---\n\n## Package docstrings\n\n- Package docstrings act as the documentation home page.\n\nRecommended sections:\n\n # Summary\n # Installation\n # Quick start\n # CLI usage\n # Core concepts\n # Architecture\n # Rendering pipeline\n # Examples\n # Notes\n\nExample:\n Package Doc String:\n\n '''\n Foo-bar processing framework.\n\n Provides tools for defining Foo objects and executing Bar pipelines.\n\n ---\n\n # Installation\n\n ```bash\n pip install foo-bar\n ```\n\n ---\n\n # Quick start\n\n ```python\n from foobar import Foo, BarEngine\n\n foo = Foo(\"example\")\n engine = BarEngine([foo])\n\n result = engine.run()\n ```\n\n ---\n '''\n\n---\n\n## Module docstrings\n\n- Module docstrings describe a subsystem.\n\nRecommended sections:\n\n # Summary\n # Examples\n # Notes\n\nExample:\n Module Doc String:\n\n '''\n Foo execution subsystem.\n\n Provides utilities for executing Foo objects through Bar stages.\n\n ---\n\n Example:\n\n ```python\n from foobar.engine import BarEngine\n from foobar.foo import Foo\n\n foo = Foo(\"example\")\n\n engine = BarEngine([foo])\n engine.run()\n ```\n\n ---\n '''\n\n---\n\n## Class docstrings\n\n- Class docstrings define object responsibility, lifecycle, and attributes.\n\nRecommended sections:\n\n Attributes:\n Notes:\n Example:\n Raises:\n\nExample:\n Simple Foo:\n\n ```python\n class Foo:\n '''\n Represents a unit of work.\n\n Attributes:\n name (str):\n Identifier of the foo instance.\n\n value (int):\n Numeric value associated with foo.\n\n Notes:\n Guarantees:\n\n - instances are immutable after creation\n\n Lifecycle:\n\n - create instance\n - pass to processing engine\n\n Example:\n Create and inspect a Foo:\n\n ```python\n foo = Foo(\"example\", value=42)\n print(foo.name)\n ```\n '''\n ```\n\n Complex Bar:\n\n ```python\n class BarEngine:\n '''\n Executes Foo objects through Bar stages.\n\n Attributes:\n foos (tuple[Foo, ...]):\n Foo instances managed by the engine.\n\n Notes:\n Guarantees:\n\n - deterministic execution order\n\n Example:\n Run engine:\n\n ```python\n foo1 = Foo(\"a\")\n foo2 = Foo(\"b\")\n\n engine = BarEngine([foo1, foo2])\n engine.run()\n ```\n '''\n ```\n\n---\n\n## Function and method docstrings\n\n- Function docstrings define API contracts.\n\nRecommended sections:\n\n Args:\n Returns:\n Raises:\n Yields:\n Notes:\n Example:\n\nExample:\n Simple process method:\n\n ```python\n def process(foo: Foo, multiplier: int) -> int:\n '''\n Process a Foo instance.\n\n Args:\n foo (Foo):\n Foo instance to process.\n\n multiplier (int):\n Value used to scale foo.\n\n Returns:\n int:\n Processed result.\n\n Raises:\n ValueError:\n If multiplier is negative.\n\n Notes:\n Guarantees:\n\n - foo is not modified\n\n Example:\n Process foo:\n\n ```python\n foo = Foo(\"example\", value=10)\n\n result = process(foo, multiplier=2)\n print(result)\n ```\n '''\n ```\n\n Multiple Examples:\n\n ```python\n def combine(foo_a: Foo, foo_b: Foo) -> Foo:\n '''\n Combine two Foo instances.\n\n Args:\n foo_a (Foo):\n First foo.\n\n foo_b (Foo):\n Second foo.\n\n Returns:\n Foo:\n Combined foo.\n\n Example:\n Basic usage:\n\n ```python\n foo1 = Foo(\"a\")\n foo2 = Foo(\"b\")\n\n combined = combine(foo1, foo2)\n ```\n\n Pipeline usage:\n\n ```python\n engine = BarEngine([foo1, foo2])\n engine.run()\n ```\n '''\n ```\n\n---\n\n## Property docstrings\n\n- Properties must document return values.\n\nExample:\n Property Doc String:\n\n ```python\n @property\n def foos(self) -> tuple[Foo, ...]:\n '''\n Return contained Foo instances.\n\n Returns:\n tuple[Foo, ...]:\n Stored foo objects.\n\n Example:\n ```python\n container = FooContainer()\n\n foos = container.foos\n ```\n '''\n ```\n\n---\n\n## Attribute documentation\n\n- Document attributes in class docstrings using Attributes:.\n\nExample:\n Attribute Doc String:\n\n ```python\n '''\n Represents a processing stage.\n\n Attributes:\n id (str):\n Unique identifier.\n\n enabled (bool):\n Whether the stage is active.\n '''\n ```\n\n---\n\n## Parsing guarantees\n\nGSDFC ensures doc-forge can deterministically extract:\n\n- symbol kind (module, class, function, property, attribute)\n- symbol name\n- parameters\n- return values\n- attributes\n- examples\n- structured Notes subsections\n\nThis enables:\n\n- reliable MkDocs rendering\n- deterministic MCP export\n- accurate AI semantic interpretation\n\n---\n\nNotes:\n - doc-forge never executes analyzed modules.\n - Documentation is generated entirely through static analysis.", "objects": { "GriffeLoader": { "name": "GriffeLoader",