Compare commits
6 Commits
main
...
bd294bea30
| Author | SHA1 | Date | |
|---|---|---|---|
| bd294bea30 | |||
| c82868d5a7 | |||
| 9a066eb0af | |||
| 711bef1dce | |||
| 8e97e571b7 | |||
| 03caf5ce4c |
60
.drone.yml
60
.drone.yml
@@ -23,50 +23,20 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- PACKAGE_NAME=$(grep -E '^name\s*=' pyproject.toml | head -1 | cut -d'"' -f2)
|
- PACKAGE_NAME=$(grep -E '^name\s*=' pyproject.toml | head -1 | cut -d'"' -f2)
|
||||||
- VERSION=$(grep -E '^version\s*=' pyproject.toml | head -1 | cut -d'"' -f2)
|
- VERSION=$(grep -E '^version\s*=' pyproject.toml | head -1 | cut -d'"' -f2)
|
||||||
|
- echo "🔍 Checking if $PACKAGE_NAME==$VERSION exists on $PIP_REPO_URL ..."
|
||||||
- |
|
- |
|
||||||
if [ "$DRONE_TAG" != "$VERSION" ]; then
|
if curl -fsSL -u "$PIP_USERNAME:$PIP_PASSWORD" "$PIP_REPO_URL/simple/$PACKAGE_NAME/" | grep -q "$VERSION"; then
|
||||||
echo "Tag '$DRONE_TAG' does not match pyproject version '$VERSION'; refusing to publish."
|
echo "✅ $PACKAGE_NAME==$VERSION already exists — skipping build."
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- echo "Checking if $PACKAGE_NAME==$VERSION exists on $PIP_REPO_URL ..."
|
|
||||||
- |
|
|
||||||
if curl -fsSL -u "$PIP_USERNAME:$PIP_PASSWORD" "$PIP_REPO_URL/simple/$PACKAGE_NAME/" | grep -qE "${PACKAGE_NAME}-${VERSION}(-|\.tar\.gz|\.whl)"; then
|
|
||||||
echo "$PACKAGE_NAME==$VERSION already exists; skipping build."
|
|
||||||
exit 78
|
exit 78
|
||||||
else
|
else
|
||||||
echo "New version detected: $PACKAGE_NAME==$VERSION"
|
echo "🆕 New version detected: $PACKAGE_NAME==$VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: quality-gate
|
|
||||||
image: python:3.13-slim
|
|
||||||
environment:
|
|
||||||
PIP_REPO_URL:
|
|
||||||
from_secret: PIP_REPO_URL
|
|
||||||
PIP_USERNAME:
|
|
||||||
from_secret: PIP_USERNAME
|
|
||||||
PIP_PASSWORD:
|
|
||||||
from_secret: PIP_PASSWORD
|
|
||||||
commands:
|
|
||||||
- pip install --upgrade pip build
|
|
||||||
- |
|
|
||||||
if [ -z "$PIP_REPO_URL" ] || [ -z "$PIP_USERNAME" ] || [ -z "$PIP_PASSWORD" ]; then
|
|
||||||
echo "PIP_REPO_URL / PIP_USERNAME / PIP_PASSWORD are not set" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- AUTH_URL="https://$PIP_USERNAME:$PIP_PASSWORD@$(echo "$PIP_REPO_URL" | sed -E 's|^[a-zA-Z]+://||; s|/*$||')/simple"
|
|
||||||
- pip install --index-url "$AUTH_URL" --extra-index-url https://pypi.org/simple/ -U ".[dev]" "pydoclint>=0.9.1"
|
|
||||||
- echo "Running quality gate..."
|
|
||||||
- python -m black --check .
|
|
||||||
- python -m ruff check .
|
|
||||||
- python -m mypy
|
|
||||||
- pydoclint .
|
|
||||||
- python -m pytest
|
|
||||||
|
|
||||||
- name: build-package
|
- name: build-package
|
||||||
image: python:3.13-slim
|
image: python:3.13-slim
|
||||||
commands:
|
commands:
|
||||||
- pip install --upgrade pip build
|
- pip install --upgrade pip build
|
||||||
- echo "Building Python package..."
|
- echo "📦 Building Python package..."
|
||||||
- python -m build
|
- python -m build
|
||||||
- ls -l dist
|
- ls -l dist
|
||||||
|
|
||||||
@@ -81,7 +51,7 @@ steps:
|
|||||||
from_secret: PIP_PASSWORD
|
from_secret: PIP_PASSWORD
|
||||||
commands:
|
commands:
|
||||||
- pip install --upgrade twine
|
- pip install --upgrade twine
|
||||||
- echo "Uploading to private PyPI at $PIP_REPO_URL ..."
|
- echo "🚀 Uploading to private PyPI at $PIP_REPO_URL ..."
|
||||||
- |
|
- |
|
||||||
twine upload \
|
twine upload \
|
||||||
--repository-url "$PIP_REPO_URL" \
|
--repository-url "$PIP_REPO_URL" \
|
||||||
@@ -128,31 +98,25 @@ steps:
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
PACKAGE_NAME=$(grep -E '^name\s*=' pyproject.toml | cut -d'"' -f2)
|
PACKAGE_NAME=$(grep -E '^name\s*=' pyproject.toml | cut -d'"' -f2)
|
||||||
echo "Package: $PACKAGE_NAME"
|
echo "📦 Package: $PACKAGE_NAME"
|
||||||
|
|
||||||
for TAG in $(git tag --sort=version:refname); do
|
for TAG in $(git tag --sort=version:refname); do
|
||||||
VERSION="$TAG"
|
VERSION="$TAG"
|
||||||
echo "Version: $VERSION"
|
echo "🔁 Version: $VERSION"
|
||||||
|
|
||||||
if curl -fsSL -u "$PIP_USERNAME:$PIP_PASSWORD" \
|
if curl -fsSL -u "$PIP_USERNAME:$PIP_PASSWORD" \
|
||||||
"$PIP_REPO_URL/simple/$PACKAGE_NAME/" | grep -qE "${PACKAGE_NAME}-${VERSION}(-|\.tar\.gz|\.whl)"; then
|
"$PIP_REPO_URL/simple/$PACKAGE_NAME/" | grep -q "$VERSION"; then
|
||||||
echo "Exists, skipping"
|
echo "⏭️ Exists, skipping"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout --force "$TAG"
|
git checkout --force "$TAG"
|
||||||
|
|
||||||
TAG_VERSION=$(grep -E '^version\s*=' pyproject.toml | head -1 | cut -d'"' -f2)
|
echo "🏗️ Building $VERSION"
|
||||||
if [ "$TAG" != "$TAG_VERSION" ]; then
|
|
||||||
echo "Tag $TAG != pyproject version $TAG_VERSION at that commit; skipping"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Building $VERSION"
|
|
||||||
rm -rf dist
|
rm -rf dist
|
||||||
python -m build
|
python -m build
|
||||||
|
|
||||||
echo "Uploading $VERSION"
|
echo "⬆️ Uploading $VERSION"
|
||||||
twine upload \
|
twine upload \
|
||||||
--repository-url "$PIP_REPO_URL" \
|
--repository-url "$PIP_REPO_URL" \
|
||||||
-u "$PIP_USERNAME" \
|
-u "$PIP_USERNAME" \
|
||||||
|
|||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -53,7 +53,6 @@ test-results/
|
|||||||
site/
|
site/
|
||||||
docs/_site/
|
docs/_site/
|
||||||
docs/build/
|
docs/build/
|
||||||
mkdocs.yml
|
|
||||||
|
|
||||||
# =========================
|
# =========================
|
||||||
# MkDocs / Sphinx output
|
# MkDocs / Sphinx output
|
||||||
@@ -88,8 +87,3 @@ Thumbs.db
|
|||||||
# =========================
|
# =========================
|
||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
|
|
||||||
# =========================
|
|
||||||
# Testing artifacts
|
|
||||||
# =========================
|
|
||||||
coverage.xml
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="pytests" type="tests" factoryName="py.test">
|
<configuration default="false" name="pytest" type="tests" factoryName="py.test">
|
||||||
<module name="docforge" />
|
<module name="docforge" />
|
||||||
<option name="ENV_FILES" value="" />
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
327
ADS.llm.md
Normal file
327
ADS.llm.md
Normal file
@@ -0,0 +1,327 @@
|
|||||||
|
# doc-forge — Architecture & Design Specification
|
||||||
|
|
||||||
|
**doc-forge** is a renderer-agnostic Python documentation compiler. It converts Python source code and docstrings into a structured, semantic documentation model and then emits multiple downstream representations, including:
|
||||||
|
|
||||||
|
* Human-facing documentation sites (MkDocs, Sphinx)
|
||||||
|
* Machine-facing documentation bundles (MCP JSON)
|
||||||
|
* Live documentation APIs (MCP servers)
|
||||||
|
|
||||||
|
This document is the **authoritative design and codebase specification** for the library. It is written to be both **LLM-friendly** and **developer-facing**, and should be treated as the canonical reference for implementation decisions.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Design Goals
|
||||||
|
|
||||||
|
1. **Single Source of Truth**
|
||||||
|
Python source code and docstrings are the only authoritative input.
|
||||||
|
|
||||||
|
2. **Renderer Agnosticism**
|
||||||
|
MkDocs, Sphinx, MCP, or future renderers must not influence the core model.
|
||||||
|
|
||||||
|
3. **Deterministic Output**
|
||||||
|
Given the same codebase, outputs must be reproducible.
|
||||||
|
|
||||||
|
4. **AI-Native Documentation**
|
||||||
|
Documentation must be structured, queryable, and machine-consumable.
|
||||||
|
|
||||||
|
5. **Library-First, CLI-Second**
|
||||||
|
All functionality must be accessible as a Python API. The CLI is a thin wrapper.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Core Mental Model
|
||||||
|
|
||||||
|
### Fundamental Abstraction
|
||||||
|
|
||||||
|
> **The atomic unit of documentation is a Python import path**
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
* `mail_intake`
|
||||||
|
* `mail_intake.config`
|
||||||
|
* `mail_intake.adapters.base`
|
||||||
|
|
||||||
|
Files, Markdown, HTML, and JSON are *representations*, not documentation units.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 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)
|
||||||
|
```
|
||||||
|
|
||||||
|
Only the **Documentation Model** is shared across all outputs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Package Layout (Proposed)
|
||||||
|
|
||||||
|
```
|
||||||
|
docforge/
|
||||||
|
├── __init__.py
|
||||||
|
├── model/
|
||||||
|
│ ├── project.py
|
||||||
|
│ ├── module.py
|
||||||
|
│ ├── object.py
|
||||||
|
│ └── nav.py
|
||||||
|
├── loader/
|
||||||
|
│ └── griffe_loader.py
|
||||||
|
├── renderers/
|
||||||
|
│ ├── base.py
|
||||||
|
│ ├── mkdocs.py
|
||||||
|
│ └── sphinx.py
|
||||||
|
├── exporters/
|
||||||
|
│ └── mcp.py
|
||||||
|
├── server/
|
||||||
|
│ └── mcp_server.py
|
||||||
|
├── cli/
|
||||||
|
│ └── main.py
|
||||||
|
└── utils/
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Documentation Model (Core)
|
||||||
|
|
||||||
|
The documentation model is renderer-neutral and must not contain any MkDocs-, Sphinx-, or MCP-specific logic.
|
||||||
|
|
||||||
|
### 5.1 Project
|
||||||
|
|
||||||
|
```python
|
||||||
|
class Project:
|
||||||
|
name: str
|
||||||
|
version: str | None
|
||||||
|
modules: dict[str, Module]
|
||||||
|
nav: Navigation
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5.2 Module
|
||||||
|
|
||||||
|
```python
|
||||||
|
class Module:
|
||||||
|
path: str # import path
|
||||||
|
docstring: str | None
|
||||||
|
members: dict[str, DocObject]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5.3 DocObject
|
||||||
|
|
||||||
|
Represents classes, functions, variables, etc.
|
||||||
|
|
||||||
|
```python
|
||||||
|
class DocObject:
|
||||||
|
name: str
|
||||||
|
kind: str # class, function, attribute, module
|
||||||
|
path: str
|
||||||
|
signature: str | None
|
||||||
|
docstring: str | None
|
||||||
|
members: dict[str, DocObject]
|
||||||
|
```
|
||||||
|
|
||||||
|
Private members (`_name`) are excluded by default.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5.4 Navigation
|
||||||
|
|
||||||
|
```python
|
||||||
|
class Navigation:
|
||||||
|
entries: list[NavEntry]
|
||||||
|
|
||||||
|
class NavEntry:
|
||||||
|
title: str
|
||||||
|
module: str
|
||||||
|
```
|
||||||
|
|
||||||
|
Navigation is derived, not authored.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Introspection Layer
|
||||||
|
|
||||||
|
### 6.1 Griffe Loader
|
||||||
|
|
||||||
|
Griffe is the **only supported introspection backend**.
|
||||||
|
|
||||||
|
Responsibilities:
|
||||||
|
|
||||||
|
* Load modules by import path
|
||||||
|
* Resolve docstrings, signatures, and members
|
||||||
|
* Tolerate alias resolution failures
|
||||||
|
|
||||||
|
Output: fully populated `Project` and `Module` objects.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Renderer Interface
|
||||||
|
|
||||||
|
Renderers consume the documentation model and emit renderer-specific source trees.
|
||||||
|
|
||||||
|
```python
|
||||||
|
class DocRenderer(Protocol):
|
||||||
|
name: str
|
||||||
|
|
||||||
|
def generate_sources(self, project: Project, out_dir: Path) -> None:
|
||||||
|
"""Generate renderer-specific source files."""
|
||||||
|
|
||||||
|
def build(self, config: RendererConfig) -> None:
|
||||||
|
"""Build final artifacts (HTML, site, etc.)."""
|
||||||
|
|
||||||
|
def serve(self, config: RendererConfig) -> None:
|
||||||
|
"""Serve documentation locally (optional)."""
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. MkDocs Renderer
|
||||||
|
|
||||||
|
### Source Generation
|
||||||
|
|
||||||
|
* Emits `.md` files
|
||||||
|
* One file per module
|
||||||
|
* Uses `mkdocstrings` directives exclusively
|
||||||
|
|
||||||
|
```md
|
||||||
|
# Config
|
||||||
|
|
||||||
|
::: mail_intake.config
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
* Uses `mkdocs.commands.build`
|
||||||
|
|
||||||
|
### Serve
|
||||||
|
|
||||||
|
* Uses `mkdocs.commands.serve`
|
||||||
|
|
||||||
|
MkDocs-specific configuration lives outside the core model.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. Sphinx Renderer
|
||||||
|
|
||||||
|
### Source Generation
|
||||||
|
|
||||||
|
* Emits `.rst` files
|
||||||
|
* Uses `autodoc` directives
|
||||||
|
|
||||||
|
```rst
|
||||||
|
mail_intake.config
|
||||||
|
==================
|
||||||
|
|
||||||
|
.. automodule:: mail_intake.config
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
* Uses `sphinx.application.Sphinx` directly
|
||||||
|
|
||||||
|
### Serve
|
||||||
|
|
||||||
|
* Optional (static build is sufficient)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. MCP Exporter (Static)
|
||||||
|
|
||||||
|
The MCP exporter bypasses renderers entirely.
|
||||||
|
|
||||||
|
### Output Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
mcp/
|
||||||
|
├── index.json
|
||||||
|
├── nav.json
|
||||||
|
└── modules/
|
||||||
|
└── package.module.json
|
||||||
|
```
|
||||||
|
|
||||||
|
### Design Principles
|
||||||
|
|
||||||
|
* Alias-safe
|
||||||
|
* Deterministic
|
||||||
|
* Fully self-contained
|
||||||
|
* No Markdown, HTML, or templates
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 11. MCP Server (Live)
|
||||||
|
|
||||||
|
The MCP server exposes documentation as queryable resources.
|
||||||
|
|
||||||
|
### Resources
|
||||||
|
|
||||||
|
* `docs://index`
|
||||||
|
* `docs://nav`
|
||||||
|
* `docs://module/{module}`
|
||||||
|
|
||||||
|
### Characteristics
|
||||||
|
|
||||||
|
* Read-only
|
||||||
|
* Stateless
|
||||||
|
* Backed by MCP JSON bundle
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 12. CLI Design
|
||||||
|
|
||||||
|
The CLI is a thin orchestration layer.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
doc-forge generate --renderer mkdocs
|
||||||
|
doc-forge generate --renderer sphinx
|
||||||
|
|
||||||
|
doc-forge build --renderer mkdocs
|
||||||
|
doc-forge serve --renderer mkdocs
|
||||||
|
|
||||||
|
doc-forge export mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
Renderer choice never affects the core model.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 13. Explicit Non-Goals
|
||||||
|
|
||||||
|
* Markdown authoring
|
||||||
|
* Theme design
|
||||||
|
* Runtime code execution
|
||||||
|
* Code formatting or linting
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 14. Invariants (Must Never Break)
|
||||||
|
|
||||||
|
1. Import paths are canonical identifiers
|
||||||
|
2. Core model contains no renderer logic
|
||||||
|
3. MCP does not depend on MkDocs or Sphinx
|
||||||
|
4. Renderers do not introspect Python directly
|
||||||
|
5. All outputs trace back to the same model
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 15. One-Line Definition
|
||||||
|
|
||||||
|
> **doc-forge is a documentation compiler that turns Python code into structured knowledge and emits it through multiple human and machine interfaces.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*End of specification.*
|
||||||
64
CHANGELOG.md
64
CHANGELOG.md
@@ -1,64 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
||||||
|
|
||||||
## [Unreleased]
|
|
||||||
|
|
||||||
## [0.0.8] - 2026-10-17
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- `docforge-linkfix` MkDocs plugin (registered via the `mkdocs.plugins`
|
|
||||||
entry point) that rebases cross-kind relative links — for example
|
|
||||||
`../lib/...` written in a wiki page — to the repository root so they resolve
|
|
||||||
to `/<repo>/<kind>/` under directory URLs.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- The wiki template (`mkdocs.wiki.yml`) now enables `docforge-linkfix`;
|
|
||||||
regenerating a wiki config (or passing `--refresh`) propagates the fix.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Cross-kind links (`../lib/`, `../api/`, `../wiki/`) in generated wikis no
|
|
||||||
longer resolve into a non-existent `<kind>/<kind>/` path.
|
|
||||||
|
|
||||||
## [0.0.7] - 2026-10-17
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- `py.typed` marker for PEP 561 type information.
|
|
||||||
- `build --refresh` flag to rebaseline an existing `docs/mkdocs.{kind}.yml`
|
|
||||||
from the packaged templates.
|
|
||||||
- `wiki` build kind with navigation derived from the source file structure.
|
|
||||||
- `--api` build mode rendering an OpenAPI reference under `docs/api` with
|
|
||||||
lib-prefixed navigation.
|
|
||||||
- Hand-written wiki, plus doc-forge-generated API reference under `docs/lib`
|
|
||||||
and MCP bundle under `docs/mcp` (per-kind MkDocs configs).
|
|
||||||
- MIT `LICENSE`.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Adopted the standard Type A PyPI CI pipeline: a `tag == version` guard and a
|
|
||||||
quality gate (black, ruff, mypy, pydoclint, pytest).
|
|
||||||
- Standardized `pyproject.toml` (canonical packaging, lint tool config, extras).
|
|
||||||
- Pinned the `mcp` extra to `mcp>=1.0.0,<2.0.0` to restore compatibility with
|
|
||||||
the current MCP server API used by doc-forge.
|
|
||||||
- Per-kind MkDocs configs (`docs/mkdocs.{lib,api,wiki}.yml`) are generated only
|
|
||||||
when absent; an existing config is used verbatim (the file wins). Pass
|
|
||||||
`--refresh` to regenerate it from the templates.
|
|
||||||
- The wiki template now uses the mongo-ops look: horizontal `navigation.tabs`
|
|
||||||
header, blue grey/teal palette, Roboto font, and additional material feature
|
|
||||||
flags. The lib and api templates are unchanged.
|
|
||||||
- Docstrings and wiki brought to the GSDFC (Google-style) standard.
|
|
||||||
- The `dev` extra now includes the `mkdocs` and `mcp` extras so the
|
|
||||||
quality-gate environment can install and run the full test suite.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Loader-generated signatures render cleanly and unresolvable aliases are
|
|
||||||
dropped from generated models.
|
|
||||||
- Stub fixes for typed API surfaces.
|
|
||||||
- `import docforge` no longer requires the optional `mcp` dependency; the
|
|
||||||
MCP server imports `mcp` lazily, matching the MkDocs backend.
|
|
||||||
|
|
||||||
[Unreleased]: https://git.aetoskia.com/aetos/doc-forge/compare/0.0.8...HEAD
|
|
||||||
[0.0.8]: https://git.aetoskia.com/aetos/doc-forge/compare/0.0.7...0.0.8
|
|
||||||
[0.0.7]: https://git.aetoskia.com/aetos/doc-forge/compare/0.0.6...0.0.7
|
|
||||||
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2026 Aetoskia Platform
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
734
README.md
734
README.md
@@ -1,586 +1,244 @@
|
|||||||
# docforge
|
# doc-forge
|
||||||
|
|
||||||
# Summary
|
A renderer-agnostic Python documentation compiler that converts Python source code and docstrings into a structured, semantic documentation model and emits multiple downstream representations.
|
||||||
|
|
||||||
Renderer-agnostic Python documentation compiler that converts Python docstrings
|
## Features
|
||||||
into structured documentation for both humans (MkDocs) and machines (MCP / AI agents).
|
|
||||||
|
|
||||||
`doc-forge` statically analyzes source code, builds a semantic model of modules,
|
- **Single Source of Truth**: Python source code and docstrings are the only authoritative input
|
||||||
classes, functions, and attributes, and renders that model into documentation
|
- **Renderer Agnosticism**: MkDocs, Sphinx, MCP, or future renderers don't influence the core model
|
||||||
outputs without executing user code.
|
- **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
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
Install using pip:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install doc-forge
|
pip install doc-forge
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
### Optional Dependencies
|
||||||
|
|
||||||
# CLI usage
|
|
||||||
|
|
||||||
Each site kind (`lib`, `api`, `wiki`) is built independently into `site/{kind}`.
|
|
||||||
|
|
||||||
## Build the library reference from a Python package:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge build --mkdocs --module my_package
|
# 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]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build the API reference from an OpenAPI spec:
|
## Quick Start
|
||||||
|
|
||||||
|
### Command Line Interface
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge build --api --openapi-spec spec.json
|
# 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
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build the hand-written wiki:
|
### Python API
|
||||||
|
|
||||||
|
```python
|
||||||
|
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.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge build --wiki --site-name my_package
|
doc-forge generate --renderer mkdocs --out-dir docs mypackage
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generate MCP JSON documentation:
|
### `build`
|
||||||
|
Build final documentation artifacts (HTML, etc.).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge build --mcp --module my_package
|
doc-forge build --renderer sphinx mypackage
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build several kinds in one pass:
|
### `serve`
|
||||||
|
Start a local development server.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge build --mcp --mkdocs --wiki --module my_package
|
doc-forge serve --renderer mkdocs --port 9000 mypackage
|
||||||
```
|
```
|
||||||
|
|
||||||
Each enabled kind gets its own MkDocs config (`docs/mkdocs.{lib,api,wiki}.yml`)
|
### `export`
|
||||||
and its own site under `site/`.
|
Export to MCP format for machine consumption.
|
||||||
|
|
||||||
## Serve a site locally:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge serve --wiki # preview from docs/mkdocs.wiki.yml
|
doc-forge export --out-dir mcp mypackage
|
||||||
doc-forge serve --lib
|
|
||||||
doc-forge serve --api
|
|
||||||
# or any config directly:
|
|
||||||
doc-forge serve --mkdocs --mkdocs-yml docs/mkdocs.wiki.yml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Serve MCP locally:
|
### `server`
|
||||||
|
Start live MCP server for real-time access.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
doc-forge serve --mcp --module my_package
|
doc-forge server --host 0.0.0.0 --port 8080 mypackage
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
## Configuration
|
||||||
|
|
||||||
# Core concepts
|
doc-forge is designed to work with minimal configuration. Most settings are derived automatically from your Python code structure.
|
||||||
|
|
||||||
## Loader
|
### MkDocs Configuration
|
||||||
Extracts symbols, signatures, and docstrings using static analysis.
|
|
||||||
|
|
||||||
## Semantic model
|
The MkDocs renderer automatically generates `mkdocs.yml` with sensible defaults:
|
||||||
Structured, renderer-agnostic representation of the API.
|
|
||||||
|
|
||||||
## Renderer
|
```yaml
|
||||||
Converts the semantic model into output formats such as MkDocs or MCP JSON.
|
site_name: Your Project
|
||||||
|
plugins:
|
||||||
## Symbol
|
- mkdocstrings
|
||||||
Any documentable object
|
theme:
|
||||||
|
name: material
|
||||||
- module
|
|
||||||
- class
|
|
||||||
- function
|
|
||||||
- method
|
|
||||||
- property
|
|
||||||
- attribute
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Architecture
|
|
||||||
|
|
||||||
`doc-forge` follows a compiler architecture:
|
|
||||||
|
|
||||||
## Front-end:
|
|
||||||
|
|
||||||
Static analysis of modules, classes, functions, type hints, and docstrings.
|
|
||||||
|
|
||||||
## Middle-end:
|
|
||||||
|
|
||||||
Builds a semantic model describing symbols and relationships.
|
|
||||||
|
|
||||||
## Back-end:
|
|
||||||
|
|
||||||
Renders documentation using interchangeable renderers.
|
|
||||||
|
|
||||||
This architecture ensures deterministic documentation generation.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Rendering pipeline
|
|
||||||
|
|
||||||
Typical flow:
|
|
||||||
|
|
||||||
Python package
|
|
||||||
|
|
|
||||||
Loader (static analysis)
|
|
||||||
|
|
|
||||||
Semantic model
|
|
||||||
|
|
|
||||||
Renderer
|
|
||||||
|
|
|
||||||
MkDocs site or MCP JSON
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
- Docstrings are the single source of truth.
|
|
||||||
- `doc-forge` compiles docstrings but does not generate documentation content.
|
|
||||||
- Documentation follows the Python import hierarchy.
|
|
||||||
- Every public symbol should have a complete and accurate docstring.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## General rules
|
|
||||||
|
|
||||||
- Use **Markdown headings** at package and module level.
|
|
||||||
- Use **Google-style structured sections** at class, function, and method level.
|
|
||||||
- Use type hints in signatures.
|
|
||||||
- Use parenthesized types in prose entries (`name (Type):`) that match the
|
|
||||||
signature types. This keeps docstrings self-contained and machine-parseable.
|
|
||||||
- Write summaries in imperative form.
|
|
||||||
- Sections are separated by `---`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Notes subsection grouping
|
|
||||||
|
|
||||||
Group related information using labeled subsections.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
**Guarantees:**
|
|
||||||
|
|
||||||
- deterministic behavior
|
|
||||||
|
|
||||||
**Lifecycle:**
|
|
||||||
|
|
||||||
- created during initialization
|
|
||||||
- reused across executions
|
|
||||||
|
|
||||||
**Thread safety:**
|
|
||||||
|
|
||||||
- safe for concurrent reads
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Example formatting
|
|
||||||
|
|
||||||
- Use indentation for examples.
|
|
||||||
- Indent section contents using four spaces.
|
|
||||||
- Use code blocks for example code.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
Single example:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```python
|
|
||||||
foo = Foo("example")
|
|
||||||
process(foo, multiplier=2)
|
|
||||||
```
|
|
||||||
|
|
||||||
Multiple examples:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
Create foo:
|
|
||||||
|
|
||||||
```python
|
|
||||||
foo = Foo("example")
|
|
||||||
```
|
|
||||||
|
|
||||||
Run engine:
|
|
||||||
|
|
||||||
```python
|
|
||||||
engine = BarEngine([foo])
|
|
||||||
engine.run()
|
|
||||||
```
|
|
||||||
|
|
||||||
Avoid fenced code blocks inside argument descriptions and other prose lines.
|
|
||||||
|
|
||||||
Inside `Example:` sections, fenced `python` code blocks are allowed and must be
|
|
||||||
indented four spaces, matching the examples below.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Separator rules
|
|
||||||
|
|
||||||
Use horizontal separators only at docstring root level to separate sections:
|
|
||||||
|
|
||||||
```markdown
|
|
||||||
---
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Allowed locations:
|
### Sphinx Configuration
|
||||||
|
|
||||||
- package docstrings
|
The Sphinx renderer automatically generates `conf.py` with standard extensions:
|
||||||
- module docstrings
|
|
||||||
- major documentation sections
|
|
||||||
|
|
||||||
Do not use separators inside code sections.
|
```python
|
||||||
|
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
|
||||||
|
```bash
|
||||||
|
doc-forge export mypackage
|
||||||
|
```
|
||||||
|
Creates a static JSON bundle in `mcp/` directory that can be loaded by MCP clients.
|
||||||
|
|
||||||
|
### Live Server
|
||||||
|
```bash
|
||||||
|
doc-forge server mypackage
|
||||||
|
```
|
||||||
|
Starts a live MCP server providing real-time access to documentation resources:
|
||||||
|
|
||||||
|
- `docs://index` - Project metadata
|
||||||
|
- `docs://nav` - Navigation structure
|
||||||
|
- `docs://module/{module}` - Individual module data
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/doc-forge/doc-forge
|
||||||
|
cd doc-forge
|
||||||
|
pip install -e ".[dev]"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code Quality
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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:
|
||||||
|
|
||||||
|
1. **Single Source of Truth**: Python source code and docstrings are the only authoritative input
|
||||||
|
2. **Renderer Agnosticism**: The core model contains no renderer-specific logic
|
||||||
|
3. **Deterministic Output**: Same input always produces same output
|
||||||
|
4. **AI-Native Documentation**: Documentation must be structured, queryable, and machine-consumable
|
||||||
|
5. **Library-First**: All functionality must be accessible as a Python API
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Package docstrings
|
*doc-forge turns Python code into structured knowledge and emits it through multiple human and machine interfaces.*
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
'''
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
'''
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
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.
|
|
||||||
'''
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Type parity (`.pyi` stubs and `py.typed`)
|
|
||||||
|
|
||||||
Documented APIs ship matching type information:
|
|
||||||
|
|
||||||
- Each `.py` module has a synchronized `.pyi` stub in the same package.
|
|
||||||
- Packages expose a `py.typed` marker so type checkers (and consumers)
|
|
||||||
use the authored signatures instead of `Any`.
|
|
||||||
- When signatures change, update the `.py` implementation and its `.pyi`
|
|
||||||
stub together.
|
|
||||||
- Doc-forge documents the docstrings in `.py`; the `.pyi` stub is the
|
|
||||||
machine-consumable signature surface.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Parsing guarantees
|
|
||||||
|
|
||||||
GSDFC ensures doc-forge can deterministically extract:
|
|
||||||
|
|
||||||
- symbol kind (module, class, function, property, attribute)
|
|
||||||
- symbol name
|
|
||||||
- parameters
|
|
||||||
- return values
|
|
||||||
- attributes
|
|
||||||
- examples
|
|
||||||
- structured Notes subsections
|
|
||||||
|
|
||||||
This enables:
|
|
||||||
|
|
||||||
- reliable MkDocs rendering
|
|
||||||
- deterministic MCP export
|
|
||||||
- accurate AI semantic interpretation
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- doc-forge never executes analyzed modules.
|
|
||||||
- Documentation is generated entirely through static analysis.
|
|
||||||
@@ -1,30 +1,26 @@
|
|||||||
home: lib/index.md
|
home: docforge/index.md
|
||||||
groups:
|
groups:
|
||||||
Loaders:
|
Loaders:
|
||||||
- lib/loaders/index.md
|
- docforge/loaders/index.md
|
||||||
- lib/loaders/griffe_loader.md
|
- docforge/loaders/griffe_loader.md
|
||||||
Models:
|
Models:
|
||||||
- lib/models/index.md
|
- docforge/models/index.md
|
||||||
- lib/models/module.md
|
- docforge/models/module.md
|
||||||
- lib/models/object.md
|
- docforge/models/object.md
|
||||||
- lib/models/project.md
|
- docforge/models/project.md
|
||||||
Navigation:
|
Navigation:
|
||||||
- lib/nav/index.md
|
- docforge/nav/index.md
|
||||||
- lib/nav/spec.md
|
- docforge/nav/spec.md
|
||||||
- lib/nav/resolver.md
|
- docforge/nav/resolver.md
|
||||||
- lib/nav/mkdocs.md
|
- docforge/nav/mkdocs.md
|
||||||
Renderers:
|
Renderers:
|
||||||
- lib/renderers/index.md
|
- docforge/renderers/index.md
|
||||||
- lib/renderers/base.md
|
- docforge/renderers/base.md
|
||||||
- lib/renderers/mkdocs_renderer.md
|
- docforge/renderers/mkdocs_renderer.md
|
||||||
- lib/renderers/mcp_renderer.md
|
- docforge/renderers/mcp_renderer.md
|
||||||
CLI:
|
CLI:
|
||||||
- lib/cli/index.md
|
- docforge/cli/index.md
|
||||||
- lib/cli/main.md
|
- docforge/cli/main.md
|
||||||
- lib/cli/commands.md
|
- docforge/cli/commands.md
|
||||||
- lib/cli/api_utils.md
|
- docforge/cli/mcp_utils.md
|
||||||
- lib/cli/mcp_utils.md
|
- docforge/cli/mkdocs_utils.md
|
||||||
- lib/cli/mkdocs_utils.md
|
|
||||||
icon:
|
|
||||||
logo: material/file-document-multiple
|
|
||||||
repo: fontawesome/brands/github
|
|
||||||
|
|||||||
@@ -1,588 +1,63 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
# doc-forge
|
||||||
|
|
||||||
Renderer-agnostic Python documentation compiler that converts Python docstrings
|
`doc-forge` is a renderer-agnostic Python documentation compiler designed for
|
||||||
into structured documentation for both humans (MkDocs) and machines (MCP / AI agents).
|
speed, flexibility, and beautiful output. It decouples the introspection of
|
||||||
|
your code from the rendering process, allowing you to generate documentation
|
||||||
|
for various platforms (starting with MkDocs) from a single internal models.
|
||||||
|
|
||||||
`doc-forge` statically analyzes source code, builds a semantic model of modules,
|
## Available Commands
|
||||||
classes, functions, and attributes, and renders that model into documentation
|
|
||||||
outputs without executing user code.
|
|
||||||
|
|
||||||
---
|
- **build**: Build documentation (MkDocs site or MCP resources).
|
||||||
|
- **serve**: Serve documentation (MkDocs or MCP).
|
||||||
|
- **tree**: Visualize the introspected project structure.
|
||||||
|
|
||||||
# Installation
|
## Installation
|
||||||
|
|
||||||
Install using pip:
|
Install using `pip` with the optional `mkdocs` dependencies for a complete setup:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install doc-forge
|
pip install doc-forge
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
## Quick Start
|
||||||
|
|
||||||
# CLI usage
|
1. **Build Documentation**:
|
||||||
|
Introspect your package and generate documentation in one step:
|
||||||
|
```bash
|
||||||
|
# Build MkDocs site
|
||||||
|
doc-forge build --mkdocs --module my_package --site-name "My Docs"
|
||||||
|
|
||||||
Each site kind (`lib`, `api`, `wiki`) is built independently into `site/{kind}`.
|
# Build MCP resources
|
||||||
|
doc-forge build --mcp --module my_package
|
||||||
## Build the library reference from a Python package:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge build --mkdocs --module my_package
|
|
||||||
```
|
|
||||||
|
|
||||||
## Build the API reference from an OpenAPI spec:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge build --api --openapi-spec spec.json
|
|
||||||
```
|
|
||||||
|
|
||||||
## Build the hand-written wiki:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge build --wiki --site-name my_package
|
|
||||||
```
|
|
||||||
|
|
||||||
## Generate MCP JSON documentation:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge build --mcp --module my_package
|
|
||||||
```
|
|
||||||
|
|
||||||
## Build several kinds in one pass:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge build --mcp --mkdocs --wiki --module my_package
|
|
||||||
```
|
|
||||||
|
|
||||||
Each enabled kind gets its own MkDocs config (`docs/mkdocs.{lib,api,wiki}.yml`)
|
|
||||||
and its own site under `site/`.
|
|
||||||
|
|
||||||
## Serve a site locally:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge serve --wiki # preview from docs/mkdocs.wiki.yml
|
|
||||||
doc-forge serve --lib
|
|
||||||
doc-forge serve --api
|
|
||||||
# or any config directly:
|
|
||||||
doc-forge serve --mkdocs --mkdocs-yml docs/mkdocs.wiki.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
## Serve MCP locally:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge serve --mcp --module my_package
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Core concepts
|
|
||||||
|
|
||||||
## Loader
|
|
||||||
Extracts symbols, signatures, and docstrings using static analysis.
|
|
||||||
|
|
||||||
## Semantic model
|
|
||||||
Structured, renderer-agnostic representation of the API.
|
|
||||||
|
|
||||||
## Renderer
|
|
||||||
Converts the semantic model into output formats such as MkDocs or MCP JSON.
|
|
||||||
|
|
||||||
## Symbol
|
|
||||||
Any documentable object
|
|
||||||
|
|
||||||
- module
|
|
||||||
- class
|
|
||||||
- function
|
|
||||||
- method
|
|
||||||
- property
|
|
||||||
- attribute
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Architecture
|
|
||||||
|
|
||||||
`doc-forge` follows a compiler architecture:
|
|
||||||
|
|
||||||
## Front-end:
|
|
||||||
|
|
||||||
Static analysis of modules, classes, functions, type hints, and docstrings.
|
|
||||||
|
|
||||||
## Middle-end:
|
|
||||||
|
|
||||||
Builds a semantic model describing symbols and relationships.
|
|
||||||
|
|
||||||
## Back-end:
|
|
||||||
|
|
||||||
Renders documentation using interchangeable renderers.
|
|
||||||
|
|
||||||
This architecture ensures deterministic documentation generation.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Rendering pipeline
|
|
||||||
|
|
||||||
Typical flow:
|
|
||||||
|
|
||||||
Python package
|
|
||||||
|
|
|
||||||
Loader (static analysis)
|
|
||||||
|
|
|
||||||
Semantic model
|
|
||||||
|
|
|
||||||
Renderer
|
|
||||||
|
|
|
||||||
MkDocs site or MCP JSON
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
- Docstrings are the single source of truth.
|
|
||||||
- `doc-forge` compiles docstrings but does not generate documentation content.
|
|
||||||
- Documentation follows the Python import hierarchy.
|
|
||||||
- Every public symbol should have a complete and accurate docstring.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## General rules
|
|
||||||
|
|
||||||
- Use **Markdown headings** at package and module level.
|
|
||||||
- Use **Google-style structured sections** at class, function, and method level.
|
|
||||||
- Use type hints in signatures.
|
|
||||||
- Use parenthesized types in prose entries (`name (Type):`) that match the
|
|
||||||
signature types. This keeps docstrings self-contained and machine-parseable.
|
|
||||||
- Write summaries in imperative form.
|
|
||||||
- Sections are separated by `---`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Notes subsection grouping
|
|
||||||
|
|
||||||
Group related information using labeled subsections.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
**Guarantees:**
|
|
||||||
|
|
||||||
- deterministic behavior
|
|
||||||
|
|
||||||
**Lifecycle:**
|
|
||||||
|
|
||||||
- created during initialization
|
|
||||||
- reused across executions
|
|
||||||
|
|
||||||
**Thread safety:**
|
|
||||||
|
|
||||||
- safe for concurrent reads
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Example formatting
|
|
||||||
|
|
||||||
- Use indentation for examples.
|
|
||||||
- Indent section contents using four spaces.
|
|
||||||
- Use code blocks for example code.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
Single example:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```python
|
|
||||||
foo = Foo("example")
|
|
||||||
process(foo, multiplier=2)
|
|
||||||
```
|
|
||||||
|
|
||||||
Multiple examples:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
Create foo:
|
|
||||||
|
|
||||||
```python
|
|
||||||
foo = Foo("example")
|
|
||||||
```
|
|
||||||
|
|
||||||
Run engine:
|
|
||||||
|
|
||||||
```python
|
|
||||||
engine = BarEngine([foo])
|
|
||||||
engine.run()
|
|
||||||
```
|
|
||||||
|
|
||||||
Avoid fenced code blocks inside argument descriptions and other prose lines.
|
|
||||||
|
|
||||||
Inside `Example:` sections, fenced `python` code blocks are allowed and must be
|
|
||||||
indented four spaces, matching the examples below.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Separator rules
|
|
||||||
|
|
||||||
Use horizontal separators only at docstring root level to separate sections:
|
|
||||||
|
|
||||||
```markdown
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
Allowed locations:
|
|
||||||
|
|
||||||
- package docstrings
|
|
||||||
- module docstrings
|
|
||||||
- major documentation sections
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
'''
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
'''
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
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:
|
2. **Define Navigation**:
|
||||||
|
Create a `docforge.nav.yml` to organize your documentation:
|
||||||
```python
|
```yaml
|
||||||
class BarEngine:
|
home: my_package/index.md
|
||||||
'''
|
groups:
|
||||||
Executes Foo objects through Bar stages.
|
Core API:
|
||||||
|
- my_package/core/*.md
|
||||||
Attributes:
|
Utilities:
|
||||||
foos (tuple[Foo, ...]):
|
- my_package/utils.md
|
||||||
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()
|
|
||||||
```
|
|
||||||
'''
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
3. **Preview**:
|
||||||
|
```bash
|
||||||
|
# Serve MkDocs site
|
||||||
|
doc-forge serve --mkdocs
|
||||||
|
|
||||||
# Function and method docstrings
|
# Serve MCP documentation
|
||||||
|
doc-forge serve --mcp
|
||||||
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:
|
## Project Structure
|
||||||
|
|
||||||
```python
|
- `docforge.loaders`: Introspects source code using static analysis (`griffe`).
|
||||||
def combine(foo_a: Foo, foo_b: Foo) -> Foo:
|
- `docforge.models`: The internal representation of your project, modules, and objects.
|
||||||
'''
|
- `docforge.renderers`: Converters that turn the models into physical files.
|
||||||
Combine two Foo instances.
|
- `docforge.nav`: Managers for logical-to-physical path mapping and navigation.
|
||||||
|
|
||||||
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.
|
|
||||||
'''
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Type parity (`.pyi` stubs and `py.typed`)
|
|
||||||
|
|
||||||
Documented APIs ship matching type information:
|
|
||||||
|
|
||||||
- Each `.py` module has a synchronized `.pyi` stub in the same package.
|
|
||||||
- Packages expose a `py.typed` marker so type checkers (and consumers)
|
|
||||||
use the authored signatures instead of `Any`.
|
|
||||||
- When signatures change, update the `.py` implementation and its `.pyi`
|
|
||||||
stub together.
|
|
||||||
- Doc-forge documents the docstrings in `.py`; the `.pyi` stub is the
|
|
||||||
machine-consumable signature surface.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Parsing guarantees
|
|
||||||
|
|
||||||
GSDFC ensures doc-forge can deterministically extract:
|
|
||||||
|
|
||||||
- symbol kind (module, class, function, property, attribute)
|
|
||||||
- symbol name
|
|
||||||
- parameters
|
|
||||||
- return values
|
|
||||||
- attributes
|
|
||||||
- examples
|
|
||||||
- structured Notes subsections
|
|
||||||
|
|
||||||
This enables:
|
|
||||||
|
|
||||||
- reliable MkDocs rendering
|
|
||||||
- deterministic MCP export
|
|
||||||
- accurate AI semantic interpretation
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- doc-forge never executes analyzed modules.
|
|
||||||
- Documentation is generated entirely through static analysis.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .loaders import GriffeLoader, discover_module_paths
|
from .loaders import GriffeLoader, discover_module_paths
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from . import models
|
|
||||||
from .cli import main
|
|
||||||
from .loaders import GriffeLoader, discover_module_paths
|
from .loaders import GriffeLoader, discover_module_paths
|
||||||
from .renderers import MCPRenderer, MkDocsRenderer
|
from .renderers import MkDocsRenderer, MCPRenderer
|
||||||
|
from .cli import main
|
||||||
|
from . import models
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"GriffeLoader",
|
"GriffeLoader",
|
||||||
|
|||||||
@@ -1,40 +1,18 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
# CLI Layer
|
||||||
|
|
||||||
Command line interface entry point for doc-forge.
|
The `docforge.cli` package provides the command-line interface for interacting
|
||||||
|
with doc-forge.
|
||||||
|
|
||||||
This module exposes the primary CLI entry function used by the
|
## Available Commands
|
||||||
`doc-forge` command. The actual command implementation resides in
|
|
||||||
`docforge.cli.main`, while this module provides a stable import path
|
|
||||||
for external tools and the package entry point configuration.
|
|
||||||
|
|
||||||
The CLI is responsible for orchestrating documentation workflows such as
|
- **build**: Build documentation (MkDocs site or MCP resources).
|
||||||
generating renderer sources, building documentation sites, exporting
|
- **serve**: Serve documentation (MkDocs or MCP).
|
||||||
machine-readable documentation bundles, and starting development or MCP
|
- **tree**: Visualize the introspected project structure.
|
||||||
servers.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Typical usage
|
|
||||||
|
|
||||||
The CLI is normally invoked through the installed command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
doc-forge <command> [options]
|
|
||||||
```
|
|
||||||
|
|
||||||
Programmatic invocation is also possible:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```python
|
|
||||||
from docforge.cli import main
|
|
||||||
main()
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .main import main
|
from .main import main
|
||||||
|
|
||||||
__all__ = ["main"]
|
__all__ = [
|
||||||
|
"main"
|
||||||
|
]
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
from .main import main
|
from .main import main
|
||||||
|
|
||||||
__all__ = ["main"]
|
__all__ = [
|
||||||
|
"main"
|
||||||
|
]
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Utilities for building API documentation from an OpenAPI specification.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import click
|
|
||||||
|
|
||||||
SWAGGER_SPEC_FILENAME = "openapi.json"
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class OpenAPIMetadata:
|
|
||||||
"""
|
|
||||||
Metadata derived from the ``info`` block of an OpenAPI specification.
|
|
||||||
|
|
||||||
Attributes:
|
|
||||||
site_name: Spec title, used as the MkDocs site name.
|
|
||||||
site_description: Spec description, used as the site description.
|
|
||||||
site_author: Contact name (fallback: contact email), used as the
|
|
||||||
site author.
|
|
||||||
"""
|
|
||||||
|
|
||||||
site_name: str
|
|
||||||
site_description: str | None
|
|
||||||
site_author: str | None
|
|
||||||
|
|
||||||
|
|
||||||
def load_openapi_spec(spec_path: Path) -> dict:
|
|
||||||
"""
|
|
||||||
Load and validate an OpenAPI specification from a JSON file.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
spec_path (Path):
|
|
||||||
Path to the OpenAPI JSON specification file.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict:
|
|
||||||
The parsed OpenAPI specification.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.ClickException:
|
|
||||||
If the file cannot be read or the ``info`` block is invalid.
|
|
||||||
"""
|
|
||||||
if not spec_path.exists():
|
|
||||||
raise click.ClickException(f"OpenAPI spec not found: {spec_path}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = json.loads(spec_path.read_text(encoding="utf-8"))
|
|
||||||
except (json.JSONDecodeError, OSError) as exc:
|
|
||||||
raise click.ClickException(f"Unable to read OpenAPI spec: {exc}") from exc
|
|
||||||
|
|
||||||
if not isinstance(data, dict):
|
|
||||||
raise click.ClickException("OpenAPI spec must be a JSON mapping")
|
|
||||||
|
|
||||||
info = data.get("info")
|
|
||||||
if not isinstance(info, dict) or not isinstance(info.get("title"), str):
|
|
||||||
raise click.ClickException("OpenAPI spec missing 'info.title'")
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def derive_metadata(spec: dict) -> OpenAPIMetadata:
|
|
||||||
"""
|
|
||||||
Derive MkDocs site metadata from an OpenAPI spec ``info`` block.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
spec (dict):
|
|
||||||
Parsed OpenAPI specification.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
OpenAPIMetadata:
|
|
||||||
Site name, description, and author derived from the spec.
|
|
||||||
"""
|
|
||||||
info = spec["info"]
|
|
||||||
|
|
||||||
contact = info.get("contact")
|
|
||||||
if isinstance(contact, dict):
|
|
||||||
author = contact.get("name") or contact.get("email")
|
|
||||||
else:
|
|
||||||
author = None
|
|
||||||
|
|
||||||
return OpenAPIMetadata(
|
|
||||||
site_name=info.get("title", ""),
|
|
||||||
site_description=info.get("description"),
|
|
||||||
site_author=author,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_api_sources(spec: dict, docs_dir: Path) -> None:
|
|
||||||
"""
|
|
||||||
Generate swagger-enabled Markdown sources and the spec copy.
|
|
||||||
|
|
||||||
The specification is written as ``openapi.json`` inside ``docs_dir`` and
|
|
||||||
an ``index.md`` embedding the swagger UI is generated alongside it.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
spec (dict):
|
|
||||||
Parsed OpenAPI specification.
|
|
||||||
docs_dir (Path):
|
|
||||||
Directory (for example ``docs/api``) where the swagger
|
|
||||||
sources are written.
|
|
||||||
"""
|
|
||||||
docs_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
spec_path = docs_dir / SWAGGER_SPEC_FILENAME
|
|
||||||
spec_json = json.dumps(spec, indent=2)
|
|
||||||
if not spec_path.exists() or spec_path.read_text(encoding="utf-8") != spec_json:
|
|
||||||
spec_path.write_text(spec_json, encoding="utf-8")
|
|
||||||
|
|
||||||
index_path = docs_dir / "index.md"
|
|
||||||
content = "# API Reference\n\n" f'<swagger-ui src="{SWAGGER_SPEC_FILENAME}"/>\n'
|
|
||||||
if not index_path.exists() or index_path.read_text(encoding="utf-8") != content:
|
|
||||||
index_path.write_text(content, encoding="utf-8")
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
from dataclasses import dataclass
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class OpenAPIMetadata:
|
|
||||||
site_name: str
|
|
||||||
site_description: str | None
|
|
||||||
site_author: str | None
|
|
||||||
|
|
||||||
def load_openapi_spec(spec_path: Path) -> dict[Any, Any]: ...
|
|
||||||
def derive_metadata(spec: dict[Any, Any]) -> OpenAPIMetadata: ...
|
|
||||||
def generate_api_sources(spec: dict[Any, Any], docs_dir: Path) -> None: ...
|
|
||||||
@@ -1,284 +1,72 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Command definitions for the doc-forge CLI.
|
|
||||||
|
|
||||||
Provides the CLI structure using Click, including build, serve, and tree commands.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- The `build` command validates requested modes before generating anything.
|
|
||||||
- `--mkdocs`, `--api`, and `--wiki` each emit their own MkDocs config and
|
|
||||||
build (`docs/mkdocs.{kind}.yml` into `site/{kind}`); `--mcp` generates a
|
|
||||||
machine-readable bundle independently.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
from pathlib import Path
|
||||||
from docforge.cli import api_utils, mcp_utils, mkdocs_utils
|
from typing import Sequence, Optional
|
||||||
from docforge.loaders import GriffeLoader
|
from docforge.loaders import GriffeLoader
|
||||||
from docforge.models import DocObject
|
from docforge.cli import mkdocs_utils
|
||||||
|
from docforge.cli import mcp_utils
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
def cli() -> None:
|
def cli() -> None:
|
||||||
"""
|
"""
|
||||||
Root command group for the doc-forge CLI.
|
doc-forge CLI: A tool for introspecting Python projects and generating
|
||||||
|
documentation.
|
||||||
Provides commands for building, serving, and inspecting
|
|
||||||
documentation generated from Python source code.
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("--mcp", is_flag=True, help="Build MCP resources")
|
@click.option("--mcp", is_flag=True, help="Build MCP resources")
|
||||||
@click.option("--mkdocs", is_flag=True, help="Build the lib MkDocs site")
|
@click.option("--mkdocs", is_flag=True, help="Build MkDocs site")
|
||||||
@click.option("--api", is_flag=True, help="Build API docs from an OpenAPI spec")
|
|
||||||
@click.option(
|
|
||||||
"--wiki", is_flag=True, help="Build a hand-written wiki as its own MkDocs site"
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--refresh",
|
|
||||||
is_flag=True,
|
|
||||||
help="Regenerate existing docs/mkdocs.{kind}.yml configs from templates",
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--module-is-source",
|
|
||||||
is_flag=True,
|
|
||||||
help="Module is source folder and to be treated as root folder",
|
|
||||||
)
|
|
||||||
@click.option("--module", help="Python module to document")
|
@click.option("--module", help="Python module to document")
|
||||||
@click.option(
|
|
||||||
"--openapi-spec",
|
|
||||||
type=click.Path(path_type=Path),
|
|
||||||
help="Path to the OpenAPI JSON specification",
|
|
||||||
)
|
|
||||||
@click.option("--project-name", help="Project name override")
|
@click.option("--project-name", help="Project name override")
|
||||||
@click.option("--site-name", help="MkDocs site name for lib and wiki sites")
|
# MkDocs specific
|
||||||
@click.option(
|
@click.option("--site-name", help="MkDocs site name")
|
||||||
"--docs-dir",
|
@click.option("--docs-dir", type=click.Path(path_type=Path), default=Path("docs"), help="Directory for MD sources")
|
||||||
type=click.Path(path_type=Path),
|
@click.option("--nav", "nav_file", type=click.Path(path_type=Path), default=Path("docforge.nav.yml"),
|
||||||
default=Path("docs"),
|
help="Nav spec path")
|
||||||
help="MkDocs documentation root",
|
@click.option("--template", type=click.Path(path_type=Path), help="MkDocs template path")
|
||||||
)
|
@click.option("--mkdocs-yml", type=click.Path(path_type=Path), default=Path("mkdocs.yml"), help="Output config path")
|
||||||
@click.option(
|
# MCP specific
|
||||||
"--wiki-dir",
|
@click.option("--out-dir", type=click.Path(path_type=Path), default=Path("mcp_docs"), help="MCP output directory")
|
||||||
type=click.Path(path_type=Path),
|
|
||||||
default=Path("docs/wiki"),
|
|
||||||
help="Hand-written wiki directory built as its own MkDocs site",
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--nav",
|
|
||||||
"nav_file",
|
|
||||||
type=click.Path(path_type=Path),
|
|
||||||
default=Path("docforge.nav.yml"),
|
|
||||||
help="Nav spec path",
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--template", type=click.Path(path_type=Path), help="MkDocs template path"
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--out-dir",
|
|
||||||
type=click.Path(path_type=Path),
|
|
||||||
default=Path("docs/mcp"),
|
|
||||||
help="MCP output directory",
|
|
||||||
)
|
|
||||||
def build(
|
def build(
|
||||||
mcp: bool,
|
mcp: bool,
|
||||||
mkdocs: bool,
|
mkdocs: bool,
|
||||||
api: bool,
|
module: Optional[str],
|
||||||
wiki: bool,
|
project_name: Optional[str],
|
||||||
refresh: bool,
|
site_name: Optional[str],
|
||||||
module_is_source: bool,
|
|
||||||
module: str | None,
|
|
||||||
openapi_spec: Path | None,
|
|
||||||
project_name: str | None,
|
|
||||||
site_name: str | None,
|
|
||||||
docs_dir: Path,
|
docs_dir: Path,
|
||||||
wiki_dir: Path,
|
|
||||||
nav_file: Path,
|
nav_file: Path,
|
||||||
template: Path | None,
|
template: Optional[Path],
|
||||||
|
mkdocs_yml: Path,
|
||||||
out_dir: Path,
|
out_dir: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Build documentation artifacts.
|
Build documentation (MkDocs site or MCP resources).
|
||||||
|
|
||||||
This command runs the full documentation pipeline: it loads Python
|
|
||||||
modules, generates renderer-specific documentation sources, and
|
|
||||||
optionally builds the final output.
|
|
||||||
|
|
||||||
Depending on the selected options, the build can target:
|
|
||||||
|
|
||||||
- A lib MkDocs site (`--mkdocs`) for library reference docs
|
|
||||||
- A swagger-enabled API MkDocs site (`--api`) built from an OpenAPI spec
|
|
||||||
- A wiki MkDocs site (`--wiki`) built from hand-written markdown
|
|
||||||
- MCP structured documentation resources (`--mcp`)
|
|
||||||
|
|
||||||
Each enabled site kind produces its own MkDocs configuration
|
|
||||||
(`docs/mkdocs.{kind}.yml`) and its own build (`site/{kind}`).
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- At least one of `--mcp`, `--mkdocs`, `--wiki`, or `--api` must be
|
|
||||||
provided.
|
|
||||||
- `--mkdocs`, `--api`, and `--wiki` emit independent MkDocs builds,
|
|
||||||
while `--mcp` emits a machine-readable bundle.
|
|
||||||
- Configuration files are generated only when absent; an existing
|
|
||||||
`docs/mkdocs.{kind}.yml` is used as-is. Pass `--refresh` to
|
|
||||||
rebaseline it from the templates.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
mcp (bool):
|
|
||||||
Enable MCP documentation generation.
|
|
||||||
|
|
||||||
mkdocs (bool):
|
|
||||||
Enable the lib MkDocs documentation generation.
|
|
||||||
|
|
||||||
api (bool):
|
|
||||||
Enable API documentation generation from an OpenAPI spec.
|
|
||||||
|
|
||||||
wiki (bool):
|
|
||||||
Build a hand-written wiki directory as its own MkDocs site.
|
|
||||||
|
|
||||||
refresh (bool):
|
|
||||||
Regenerate ``docs/mkdocs.{kind}.yml`` from templates even when
|
|
||||||
it already exists. By default, existing configs are used as-is.
|
|
||||||
|
|
||||||
module_is_source (bool):
|
|
||||||
Treat the specified module directory as the project root.
|
|
||||||
|
|
||||||
module (str | None):
|
|
||||||
Python module import path to document.
|
|
||||||
|
|
||||||
openapi_spec (Path | None):
|
|
||||||
Path to the OpenAPI JSON specification used for API docs.
|
|
||||||
|
|
||||||
project_name (str | None):
|
|
||||||
Optional override for the project name.
|
|
||||||
|
|
||||||
site_name (str | None):
|
|
||||||
Display name for the lib and wiki MkDocs sites.
|
|
||||||
|
|
||||||
docs_dir (Path):
|
|
||||||
Shared documentation root used for generated sources.
|
|
||||||
wiki_dir (Path):
|
|
||||||
Directory containing hand-written wiki markdown files.
|
|
||||||
|
|
||||||
nav_file (Path):
|
|
||||||
Path to the navigation specification file.
|
|
||||||
|
|
||||||
template (Path | None):
|
|
||||||
Optional custom MkDocs configuration template.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Output directory for generated MCP resources.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.UsageError:
|
|
||||||
If required options are missing or conflicting.
|
|
||||||
"""
|
"""
|
||||||
if not mcp and not mkdocs and not api and not wiki:
|
if not mcp and not mkdocs:
|
||||||
raise click.UsageError("Must specify either --mcp, --mkdocs, --wiki, or --api")
|
raise click.UsageError("Must specify either --mcp or --mkdocs")
|
||||||
|
|
||||||
if api:
|
|
||||||
if not openapi_spec:
|
|
||||||
raise click.UsageError("--openapi-spec is required for API build")
|
|
||||||
if site_name and not mkdocs and not wiki:
|
|
||||||
raise click.UsageError(
|
|
||||||
"--site-name cannot be overridden for API build; "
|
|
||||||
"the OpenAPI spec provides the site name"
|
|
||||||
)
|
|
||||||
|
|
||||||
if mkdocs and not module:
|
|
||||||
raise click.UsageError("--module is required for MkDocs build")
|
|
||||||
if mcp and not module:
|
|
||||||
raise click.UsageError("--module is required for MCP build")
|
|
||||||
|
|
||||||
spec: dict | None = None
|
|
||||||
if api:
|
|
||||||
spec = api_utils.load_openapi_spec(openapi_spec)
|
|
||||||
|
|
||||||
kinds: list[str] = []
|
|
||||||
if mkdocs:
|
if mkdocs:
|
||||||
kinds.append("lib")
|
if not module:
|
||||||
lib_dir = docs_dir / "lib"
|
raise click.UsageError("--module is required for MkDocs build")
|
||||||
click.echo(f"Generating MkDocs sources in {lib_dir}...")
|
if not site_name:
|
||||||
mkdocs_utils.generate_sources(
|
site_name = module
|
||||||
module,
|
|
||||||
lib_dir,
|
|
||||||
project_name,
|
|
||||||
module_is_source,
|
|
||||||
readme_dir=Path(".").resolve(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if api:
|
click.echo(f"Generating MkDocs sources in {docs_dir}...")
|
||||||
kinds.append("api")
|
mkdocs_utils.generate_sources(module, project_name, docs_dir)
|
||||||
api_dir = docs_dir / "api"
|
|
||||||
click.echo(f"Generating API sources in {api_dir}...")
|
|
||||||
api_utils.generate_api_sources(spec, api_dir)
|
|
||||||
|
|
||||||
if wiki:
|
click.echo(f"Generating MkDocs config {mkdocs_yml}...")
|
||||||
kinds.append("wiki")
|
mkdocs_utils.generate_config(docs_dir, nav_file, template, mkdocs_yml, site_name)
|
||||||
|
|
||||||
if kinds:
|
click.echo("Running MkDocs build...")
|
||||||
api_metadata: api_utils.OpenAPIMetadata | None = None
|
mkdocs_utils.build(mkdocs_yml)
|
||||||
if api:
|
click.echo("MkDocs build completed.")
|
||||||
api_metadata = api_utils.derive_metadata(spec)
|
|
||||||
theme_icon = mkdocs_utils.load_spec_icon(nav_file)
|
|
||||||
|
|
||||||
config_paths: list[Path] = []
|
|
||||||
for kind in kinds:
|
|
||||||
out = docs_dir / f"mkdocs.{kind}.yml"
|
|
||||||
if out.exists() and not refresh:
|
|
||||||
click.echo(
|
|
||||||
f"Using existing MkDocs config {out} (run --refresh to rebaseline)..."
|
|
||||||
)
|
|
||||||
config_paths.append(out)
|
|
||||||
continue
|
|
||||||
|
|
||||||
kind_root = wiki_dir if kind == "wiki" else docs_dir / kind
|
|
||||||
|
|
||||||
site_name_kind = site_name or module or Path.cwd().name
|
|
||||||
site_description: str | None = None
|
|
||||||
site_author: str | None = None
|
|
||||||
if kind == "api" and api_metadata:
|
|
||||||
site_name_kind = api_metadata.site_name
|
|
||||||
site_description = api_metadata.site_description
|
|
||||||
site_author = api_metadata.site_author
|
|
||||||
|
|
||||||
if kind == "lib":
|
|
||||||
nav_block, _kind_icon = mkdocs_utils.build_lib_nav(nav_file, docs_dir)
|
|
||||||
elif kind == "wiki":
|
|
||||||
nav_block = mkdocs_utils.build_wiki_nav_block(wiki_dir)
|
|
||||||
else:
|
|
||||||
nav_block = [{"API Reference": "index.md"}]
|
|
||||||
|
|
||||||
click.echo(f"Generating MkDocs config {out}...")
|
|
||||||
mkdocs_utils.generate_site_config(
|
|
||||||
kind,
|
|
||||||
kind_root,
|
|
||||||
nav_block,
|
|
||||||
out,
|
|
||||||
site_name_kind,
|
|
||||||
Path(os.path.relpath(kind_root, docs_dir)).as_posix(),
|
|
||||||
Path(os.path.relpath(Path.cwd() / "site" / kind, docs_dir)).as_posix(),
|
|
||||||
template=template,
|
|
||||||
site_description=site_description,
|
|
||||||
site_author=site_author,
|
|
||||||
theme_icon=theme_icon,
|
|
||||||
)
|
|
||||||
config_paths.append(out)
|
|
||||||
|
|
||||||
click.echo("Running MkDocs builds...")
|
|
||||||
mkdocs_utils.build_configs(config_paths)
|
|
||||||
|
|
||||||
if mcp:
|
if mcp:
|
||||||
|
if not module:
|
||||||
|
raise click.UsageError("--module is required for MCP build")
|
||||||
|
|
||||||
click.echo(f"Generating MCP resources in {out_dir}...")
|
click.echo(f"Generating MCP resources in {out_dir}...")
|
||||||
mcp_utils.generate_resources(module, project_name, out_dir)
|
mcp_utils.generate_resources(module, project_name, out_dir)
|
||||||
click.echo("MCP build completed.")
|
click.echo("MCP build completed.")
|
||||||
@@ -286,137 +74,49 @@ def build(
|
|||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("--mcp", is_flag=True, help="Serve MCP documentation")
|
@click.option("--mcp", is_flag=True, help="Serve MCP documentation")
|
||||||
@click.option("--mkdocs", is_flag=True, help="Serve an MkDocs site from --mkdocs-yml")
|
@click.option("--mkdocs", is_flag=True, help="Serve MkDocs site")
|
||||||
@click.option("--lib", is_flag=True, help="Serve the lib MkDocs site")
|
@click.option("--mkdocs-yml", type=click.Path(path_type=Path), default=Path("mkdocs.yml"), help="MkDocs config path")
|
||||||
@click.option("--api", is_flag=True, help="Serve the API MkDocs site")
|
@click.option("--out-dir", type=click.Path(path_type=Path), default=Path("mcp_docs"), help="MCP root directory")
|
||||||
@click.option("--wiki", is_flag=True, help="Serve the wiki MkDocs site")
|
|
||||||
@click.option("--module", help="Python module to serve")
|
|
||||||
@click.option(
|
|
||||||
"--mkdocs-yml",
|
|
||||||
type=click.Path(path_type=Path),
|
|
||||||
default=Path("docs/mkdocs.wiki.yml"),
|
|
||||||
help="MkDocs config path",
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--out-dir",
|
|
||||||
type=click.Path(path_type=Path),
|
|
||||||
default=Path("docs/mcp"),
|
|
||||||
help="MCP root directory",
|
|
||||||
)
|
|
||||||
def serve(
|
def serve(
|
||||||
mcp: bool,
|
mcp: bool,
|
||||||
mkdocs: bool,
|
mkdocs: bool,
|
||||||
lib: bool,
|
|
||||||
api: bool,
|
|
||||||
wiki: bool,
|
|
||||||
module: str | None,
|
|
||||||
mkdocs_yml: Path,
|
mkdocs_yml: Path,
|
||||||
out_dir: Path,
|
out_dir: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Serve generated documentation locally.
|
Serve documentation.
|
||||||
|
|
||||||
Depending on the selected mode, this command starts either:
|
|
||||||
|
|
||||||
- A MkDocs development server for browsing a site, or
|
|
||||||
- An MCP server exposing structured documentation resources
|
|
||||||
|
|
||||||
The kind flags (`--lib`, `--api`, `--wiki`) select the generated
|
|
||||||
per-kind config (`docs/mkdocs.{kind}.yml`); `--mkdocs` serves the config
|
|
||||||
passed via `--mkdocs-yml`.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
mcp (bool):
|
|
||||||
Serve documentation using the MCP server.
|
|
||||||
|
|
||||||
mkdocs (bool):
|
|
||||||
Serve the MkDocs development site from ``--mkdocs-yml``.
|
|
||||||
|
|
||||||
lib (bool):
|
|
||||||
Serve the lib MkDocs site.
|
|
||||||
|
|
||||||
api (bool):
|
|
||||||
Serve the API MkDocs site.
|
|
||||||
|
|
||||||
wiki (bool):
|
|
||||||
Serve the wiki MkDocs site.
|
|
||||||
|
|
||||||
module (str | None):
|
|
||||||
Python module import path to serve via MCP.
|
|
||||||
|
|
||||||
mkdocs_yml (Path):
|
|
||||||
Path to the MkDocs configuration file.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Root directory containing MCP documentation resources.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.UsageError:
|
|
||||||
If invalid or conflicting options are provided.
|
|
||||||
"""
|
"""
|
||||||
selected = [
|
if mcp and mkdocs:
|
||||||
name
|
raise click.UsageError("Cannot specify both --mcp and --mkdocs")
|
||||||
for name, enabled in (
|
if not mcp and not mkdocs:
|
||||||
("mcp", mcp),
|
raise click.UsageError("Must specify either --mcp or --mkdocs")
|
||||||
("mkdocs", mkdocs),
|
|
||||||
("lib", lib),
|
|
||||||
("api", api),
|
|
||||||
("wiki", wiki),
|
|
||||||
)
|
|
||||||
if enabled
|
|
||||||
]
|
|
||||||
if len(selected) != 1:
|
|
||||||
raise click.UsageError(
|
|
||||||
"Must specify exactly one of --mcp, --mkdocs, --lib, --api, --wiki"
|
|
||||||
)
|
|
||||||
|
|
||||||
if mcp:
|
if mkdocs:
|
||||||
if not module:
|
mkdocs_utils.serve(mkdocs_yml)
|
||||||
raise click.UsageError("--module is required for MCP serve")
|
elif mcp:
|
||||||
mcp_utils.serve(module, out_dir)
|
mcp_utils.serve(out_dir)
|
||||||
return
|
|
||||||
|
|
||||||
config = mkdocs_yml
|
|
||||||
if lib:
|
|
||||||
config = Path("docs/mkdocs.lib.yml")
|
|
||||||
elif api:
|
|
||||||
config = Path("docs/mkdocs.api.yml")
|
|
||||||
elif wiki:
|
|
||||||
config = Path("docs/mkdocs.wiki.yml")
|
|
||||||
|
|
||||||
mkdocs_utils.serve(config)
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
"--module",
|
"--modules",
|
||||||
|
multiple=True,
|
||||||
required=True,
|
required=True,
|
||||||
help="Python module import path to introspect",
|
help="Python module import paths to introspect",
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--project-name",
|
"--project-name",
|
||||||
help="Project name (defaults to specified module)",
|
help="Project name (defaults to first module)",
|
||||||
)
|
)
|
||||||
def tree(
|
def tree(
|
||||||
module: str,
|
modules: Sequence[str],
|
||||||
project_name: str | None,
|
project_name: Optional[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Display the documentation object tree for a module.
|
Visualize the project structure.
|
||||||
|
|
||||||
This command introspects the specified module and prints a
|
|
||||||
hierarchical representation of the discovered documentation
|
|
||||||
objects, including modules, classes, functions, and members.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module (str):
|
|
||||||
Python module import path to introspect.
|
|
||||||
|
|
||||||
project_name (str | None):
|
|
||||||
Optional name to display as the project root.
|
|
||||||
"""
|
"""
|
||||||
loader = GriffeLoader()
|
loader = GriffeLoader()
|
||||||
project = loader.load_project([module], project_name)
|
project = loader.load_project(list(modules), project_name)
|
||||||
|
|
||||||
click.echo(project.name)
|
click.echo(project.name)
|
||||||
|
|
||||||
@@ -426,19 +126,9 @@ def tree(
|
|||||||
_print_object(obj, indent="│ ")
|
_print_object(obj, indent="│ ")
|
||||||
|
|
||||||
|
|
||||||
def _print_object(obj: DocObject, indent: str) -> None:
|
def _print_object(obj, indent: str) -> None:
|
||||||
"""
|
"""
|
||||||
Recursively print a documentation object and its members.
|
Recursive helper to print doc objects and their members to the console.
|
||||||
|
|
||||||
This helper function traverses the documentation object graph
|
|
||||||
and prints each object with indentation to represent hierarchy.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj (DocObject):
|
|
||||||
Documentation object to print.
|
|
||||||
|
|
||||||
indent (str):
|
|
||||||
Current indentation prefix used for nested members.
|
|
||||||
"""
|
"""
|
||||||
click.echo(f"{indent}├── {obj.name}")
|
click.echo(f"{indent}├── {obj.name}")
|
||||||
for member in obj.get_all_members():
|
for member in obj.get_all_members():
|
||||||
|
|||||||
@@ -1,39 +1,32 @@
|
|||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from click.core import Group
|
from click.core import Group
|
||||||
|
from pathlib import Path
|
||||||
from docforge.models import DocObject
|
from typing import Sequence, Optional, Any
|
||||||
|
|
||||||
cli: Group
|
cli: Group
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
mcp: bool,
|
mcp: bool,
|
||||||
mkdocs: bool,
|
mkdocs: bool,
|
||||||
api: bool,
|
module: Optional[str],
|
||||||
wiki: bool,
|
project_name: Optional[str],
|
||||||
module_is_source: bool,
|
site_name: Optional[str],
|
||||||
module: str | None,
|
|
||||||
openapi_spec: Path | None,
|
|
||||||
project_name: str | None,
|
|
||||||
site_name: str | None,
|
|
||||||
docs_dir: Path,
|
docs_dir: Path,
|
||||||
wiki_dir: Path,
|
|
||||||
nav_file: Path,
|
nav_file: Path,
|
||||||
template: Path | None,
|
template: Optional[Path],
|
||||||
out_dir: Path,
|
|
||||||
) -> None: ...
|
|
||||||
def serve(
|
|
||||||
mcp: bool,
|
|
||||||
mkdocs: bool,
|
|
||||||
lib: bool,
|
|
||||||
api: bool,
|
|
||||||
wiki: bool,
|
|
||||||
module: str | None,
|
|
||||||
mkdocs_yml: Path,
|
mkdocs_yml: Path,
|
||||||
out_dir: Path,
|
out_dir: Path,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def tree(
|
|
||||||
module: str,
|
def serve(
|
||||||
project_name: str | None,
|
mcp: bool,
|
||||||
|
mkdocs: bool,
|
||||||
|
mkdocs_yml: Path,
|
||||||
|
out_dir: Path,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def _print_object(obj: DocObject, indent: str) -> None: ...
|
|
||||||
|
def tree(
|
||||||
|
modules: Sequence[str],
|
||||||
|
project_name: Optional[str],
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
def _print_object(obj: Any, indent: str) -> None: ...
|
||||||
|
|||||||
@@ -1,25 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
Main entry point for the doc-forge CLI.
|
||||||
|
|
||||||
Command-line entry point for the doc-forge CLI.
|
|
||||||
|
|
||||||
This module exposes the executable entry point that initializes the
|
|
||||||
Click command group defined in `docforge.cli.commands`.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from docforge.cli.commands import cli
|
from docforge.cli.commands import cli
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""
|
"""
|
||||||
Run the doc-forge command-line interface.
|
CLI Entry point. Boots the click application.
|
||||||
|
|
||||||
This function initializes and executes the Click CLI application.
|
|
||||||
It is used as the console entry point when invoking `doc-forge`
|
|
||||||
from the command line.
|
|
||||||
"""
|
"""
|
||||||
cli()
|
cli()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1,48 +1,12 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Utilities for working with MCP in the doc-forge CLI.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- `generate_resources` produces the bundle consumed by `MCPServer`:
|
|
||||||
`index.json`, `nav.json`, and per-module resources under `modules/`.
|
|
||||||
- Resource URIs use the `docs://` scheme: `docs://index`, `docs://nav`,
|
|
||||||
and `docs://modules/{module}`.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||||
from docforge.renderers import MCPRenderer
|
from docforge.renderers import MCPRenderer
|
||||||
from docforge.servers import MCPServer
|
from docforge.servers import MCPServer
|
||||||
|
|
||||||
|
|
||||||
def generate_resources(module: str, project_name: str | None, out_dir: Path) -> None:
|
def generate_resources(module: str, project_name: str | None, out_dir: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Generate MCP documentation resources from a Python module.
|
Generate MCP-compatible documentation resources.
|
||||||
|
|
||||||
The function performs project introspection, builds the internal
|
|
||||||
documentation model, and renders MCP-compatible JSON resources
|
|
||||||
to the specified output directory.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module (str):
|
|
||||||
Python module import path used as the entry point for
|
|
||||||
documentation generation.
|
|
||||||
|
|
||||||
project_name (str | None):
|
|
||||||
Optional override for the project name used in generated
|
|
||||||
documentation metadata.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Directory where MCP resources (index.json, nav.json, and module data)
|
|
||||||
will be written.
|
|
||||||
"""
|
"""
|
||||||
loader = GriffeLoader()
|
loader = GriffeLoader()
|
||||||
discovered_paths = discover_module_paths(module)
|
discovered_paths = discover_module_paths(module)
|
||||||
@@ -51,29 +15,12 @@ def generate_resources(module: str, project_name: str | None, out_dir: Path) ->
|
|||||||
renderer = MCPRenderer()
|
renderer = MCPRenderer()
|
||||||
renderer.generate_sources(project, out_dir)
|
renderer.generate_sources(project, out_dir)
|
||||||
|
|
||||||
|
def serve(mcp_root: Path) -> None:
|
||||||
def serve(module: str, mcp_root: Path) -> None:
|
|
||||||
"""
|
"""
|
||||||
Start an MCP server for a pre-generated documentation bundle.
|
Serve MCP documentation.
|
||||||
|
|
||||||
The server exposes documentation resources such as project metadata,
|
|
||||||
navigation structure, and module documentation through MCP endpoints.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module (str):
|
|
||||||
Python module import path used to identify the served
|
|
||||||
documentation instance.
|
|
||||||
|
|
||||||
mcp_root (Path):
|
|
||||||
Path to the directory containing the MCP documentation
|
|
||||||
bundle (index.json, nav.json, and modules/).
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.ClickException:
|
|
||||||
If the MCP documentation bundle is missing required files or directories.
|
|
||||||
"""
|
"""
|
||||||
if not mcp_root.exists():
|
if not mcp_root.exists():
|
||||||
raise click.ClickException(f"MCP docs directory not found: {mcp_root}")
|
raise click.ClickException(f"mcp_docs directory not found: {mcp_root}")
|
||||||
|
|
||||||
required = [
|
required = [
|
||||||
mcp_root / "index.json",
|
mcp_root / "index.json",
|
||||||
@@ -87,6 +34,6 @@ def serve(module: str, mcp_root: Path) -> None:
|
|||||||
|
|
||||||
server = MCPServer(
|
server = MCPServer(
|
||||||
mcp_root=mcp_root,
|
mcp_root=mcp_root,
|
||||||
name=f"{module}-mcp",
|
name="doc-forge-mcp",
|
||||||
)
|
)
|
||||||
server.run()
|
server.run()
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
def generate_resources(
|
def generate_resources(module: str, project_name: str | None, out_dir: Path) -> None: ...
|
||||||
module: str, project_name: str | None, out_dir: Path
|
def serve(mcp_root: Path) -> None: ...
|
||||||
) -> None: ...
|
|
||||||
def serve(module: str, mcp_root: Path) -> None: ...
|
|
||||||
|
|||||||
@@ -1,453 +1,69 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Utilities for working with MkDocs in the doc-forge CLI.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- A separate `mkdocs.{kind}.yml` configuration and build is emitted per
|
|
||||||
enabled kind (lib, api, wiki), each scoped to its own `docs_dir` and
|
|
||||||
written into its own `site_dir` (`site/lib`, `site/api`, `site/wiki`).
|
|
||||||
- Navigation blocks are re-rooted per kind: the wiki navigation drops its
|
|
||||||
leading `wiki/` scope and the resolved nav spec drops its `lib/` scope.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
|
||||||
|
|
||||||
from collections.abc import Iterable
|
|
||||||
from importlib import resources
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, cast
|
from importlib import resources
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from docforge.loaders import GriffeLoader, discover_module_paths
|
from docforge.loaders import GriffeLoader, discover_module_paths
|
||||||
from docforge.nav import (
|
|
||||||
MkDocsNavEmitter,
|
|
||||||
build_wiki_nav,
|
|
||||||
load_nav_spec,
|
|
||||||
resolve_nav,
|
|
||||||
)
|
|
||||||
from docforge.renderers import MkDocsRenderer
|
from docforge.renderers import MkDocsRenderer
|
||||||
|
from docforge.nav import load_nav_spec, resolve_nav, MkDocsNavEmitter
|
||||||
|
|
||||||
|
def generate_sources(module: str, project_name: str | None, docs_dir: Path) -> None:
|
||||||
def generate_sources(
|
|
||||||
module: str,
|
|
||||||
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.
|
Generate Markdown source files for the specified module.
|
||||||
|
|
||||||
This function introspects the specified module, builds the internal
|
|
||||||
documentation model, and renders Markdown documentation files for
|
|
||||||
use with MkDocs.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module (str):
|
|
||||||
Python module import path used as the entry point for
|
|
||||||
documentation generation.
|
|
||||||
|
|
||||||
docs_dir (Path):
|
|
||||||
Directory where the generated Markdown files will be written.
|
|
||||||
|
|
||||||
project_name (str | None):
|
|
||||||
Optional override for the project name used in documentation metadata.
|
|
||||||
|
|
||||||
module_is_source (bool | None):
|
|
||||||
If True, treat the specified module directory as the project root
|
|
||||||
rather than a nested module.
|
|
||||||
|
|
||||||
readme_dir (Path | None):
|
|
||||||
Directory where the generated README.md should be written. If not
|
|
||||||
provided, defaults to the parent of ``docs_dir``.
|
|
||||||
"""
|
"""
|
||||||
loader = GriffeLoader()
|
loader = GriffeLoader()
|
||||||
discovered_paths = discover_module_paths(module)
|
discovered_paths = discover_module_paths(module)
|
||||||
project = loader.load_project(discovered_paths, project_name)
|
project = loader.load_project(discovered_paths, project_name)
|
||||||
|
|
||||||
renderer = MkDocsRenderer()
|
renderer = MkDocsRenderer()
|
||||||
renderer.generate_sources(
|
renderer.generate_sources(project, docs_dir)
|
||||||
project,
|
|
||||||
docs_dir,
|
|
||||||
module_is_source,
|
|
||||||
)
|
|
||||||
|
|
||||||
renderer.generate_readme(
|
def generate_config(docs_dir: Path, nav_file: Path, template: Path | None, out: Path, site_name: str) -> None:
|
||||||
project,
|
|
||||||
docs_dir,
|
|
||||||
module_is_source,
|
|
||||||
readme_dir,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def build_lib_nav(
|
|
||||||
nav_file: Path,
|
|
||||||
docs_root: Path,
|
|
||||||
) -> tuple[list[dict[str, Any]], dict[str, str] | None]:
|
|
||||||
"""
|
"""
|
||||||
Build the re-rooted navigation block for a lib site.
|
Generate an mkdocs.yml configuration file.
|
||||||
|
|
||||||
The navigation specification is resolved against the shared documentation
|
|
||||||
root and every resulting path is re-rooted relative to the ``lib``
|
|
||||||
subdirectory by stripping its leading ``lib/`` scope component.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
nav_file (Path):
|
|
||||||
Path to the `docforge.nav.yml` navigation specification.
|
|
||||||
|
|
||||||
docs_root (Path):
|
|
||||||
Shared documentation root containing the ``lib`` sources.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
tuple[list[dict[str, Any]], dict[str, str] | None]:
|
|
||||||
The re-rooted navigation block and the optional theme icon
|
|
||||||
mapping from the specification.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.FileError:
|
|
||||||
If the navigation specification cannot be found.
|
|
||||||
"""
|
"""
|
||||||
if not nav_file.exists():
|
if not nav_file.exists():
|
||||||
raise click.FileError(str(nav_file), hint="Nav spec not found")
|
raise click.FileError(str(nav_file), hint="Nav spec not found")
|
||||||
|
|
||||||
spec = load_nav_spec(nav_file)
|
spec = load_nav_spec(nav_file)
|
||||||
resolved = resolve_nav(spec, docs_root)
|
resolved = resolve_nav(spec, docs_dir)
|
||||||
block = MkDocsNavEmitter().emit(resolved)
|
nav_block = MkDocsNavEmitter().emit(resolved)
|
||||||
return cast(list[dict[str, Any]], _strip_scope(block, "lib")), spec.icon
|
|
||||||
|
|
||||||
|
# Load template
|
||||||
def build_wiki_nav_block(wiki_dir: Path) -> list[dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
Build the re-rooted navigation block for a wiki site.
|
|
||||||
|
|
||||||
The wiki navigation derived from the wiki file structure is re-rooted
|
|
||||||
relative to the wiki directory itself by stripping the leading ``wiki/``
|
|
||||||
scope component.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
wiki_dir (Path):
|
|
||||||
Path to the hand-written wiki directory, for example ``docs/wiki``.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict[str, Any]]:
|
|
||||||
Navigation entries relative to the wiki directory.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.FileError:
|
|
||||||
If the wiki directory does not exist.
|
|
||||||
"""
|
|
||||||
if not wiki_dir.exists():
|
|
||||||
raise click.FileError(str(wiki_dir), hint="Wiki dir not found")
|
|
||||||
|
|
||||||
return cast(list[dict[str, Any]], _strip_scope(build_wiki_nav(wiki_dir), "wiki"))
|
|
||||||
|
|
||||||
|
|
||||||
def load_spec_icon(nav_file: Path) -> dict[str, str] | None:
|
|
||||||
"""
|
|
||||||
Load the theme icon mapping from a navigation specification.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
nav_file (Path):
|
|
||||||
Path to the navigation specification file.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict[str, str] | None:
|
|
||||||
The icon mapping, or ``None`` when the specification file is
|
|
||||||
absent or cannot be parsed.
|
|
||||||
"""
|
|
||||||
if not nav_file.exists():
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
|
||||||
return load_nav_spec(nav_file).icon
|
|
||||||
except (ValueError, yaml.YAMLError):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _strip_scope(value: object, scope: str) -> object:
|
|
||||||
"""
|
|
||||||
Re-root navigation paths by removing a leading scope component.
|
|
||||||
|
|
||||||
The navigation block is walked recursively and every relative path
|
|
||||||
string that starts with ``{scope}/`` has that prefix removed, so a lib
|
|
||||||
or wiki site scoped to its own ``docs_dir`` can reuse paths that were
|
|
||||||
originally written relative to the shared documentation root.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
value (object):
|
|
||||||
Navigation block, group list, path string, or scalar value.
|
|
||||||
scope (str):
|
|
||||||
Leading path component to strip, for example ``lib`` or ``wiki``.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
object:
|
|
||||||
The navigation structure with re-rooted paths.
|
|
||||||
"""
|
|
||||||
if isinstance(value, str):
|
|
||||||
prefix = f"{scope}/"
|
|
||||||
return value[len(prefix) :] if value.startswith(prefix) else value
|
|
||||||
if isinstance(value, list):
|
|
||||||
return [_strip_scope(item, scope) for item in value]
|
|
||||||
if isinstance(value, dict):
|
|
||||||
return {key: _strip_scope(val, scope) for key, val in value.items()}
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def generate_site_config(
|
|
||||||
kind: str,
|
|
||||||
kind_root: Path,
|
|
||||||
nav_block: list[dict[str, Any]],
|
|
||||||
out: Path,
|
|
||||||
site_name: str,
|
|
||||||
docs_dir: str,
|
|
||||||
site_dir: str,
|
|
||||||
template: Path | None = None,
|
|
||||||
site_description: str | None = None,
|
|
||||||
site_author: str | None = None,
|
|
||||||
theme_icon: dict[str, str] | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Generate a per-kind `mkdocs.{kind}.yml` configuration file.
|
|
||||||
|
|
||||||
The configuration is created by merging the shared ``mkdocs.common.yml``
|
|
||||||
template with the fragment contributed by the kind (``lib``, ``api``, or
|
|
||||||
``wiki``). Both ``docs_dir`` and ``site_dir`` are written relative to the
|
|
||||||
configuration file's directory: the kind's sources when expressed as a
|
|
||||||
sibling path (for example ``lib``) and the per-kind site output (for
|
|
||||||
example ``../site/lib``).
|
|
||||||
|
|
||||||
Args:
|
|
||||||
kind (str):
|
|
||||||
Documentation kind, one of ``lib``, ``api``, or ``wiki``.
|
|
||||||
|
|
||||||
kind_root (Path):
|
|
||||||
Directory scoped to the kind (for example ``docs/lib``) that
|
|
||||||
serves as the MkDocs ``docs_dir``.
|
|
||||||
|
|
||||||
nav_block (list[dict[str, Any]]):
|
|
||||||
Re-rooted navigation entries for the kind's site.
|
|
||||||
|
|
||||||
out (Path):
|
|
||||||
Destination path where the generated ``mkdocs.{kind}.yml`` file
|
|
||||||
is written.
|
|
||||||
|
|
||||||
site_name (str):
|
|
||||||
Display name for the generated documentation site.
|
|
||||||
|
|
||||||
docs_dir (str):
|
|
||||||
MkDocs ``docs_dir`` value, relative to the configuration
|
|
||||||
file's directory.
|
|
||||||
|
|
||||||
site_dir (str):
|
|
||||||
MkDocs ``site_dir`` value, relative to the configuration
|
|
||||||
file's directory.
|
|
||||||
|
|
||||||
template (Path | None):
|
|
||||||
Optional path to a fully custom MkDocs configuration template
|
|
||||||
that replaces the built-in templates entirely.
|
|
||||||
|
|
||||||
site_description (str | None):
|
|
||||||
Optional site description written into the configuration.
|
|
||||||
|
|
||||||
site_author (str | None):
|
|
||||||
Optional site author written into the configuration.
|
|
||||||
|
|
||||||
theme_icon (dict[str, str] | None):
|
|
||||||
Optional mapping of theme icon entries injected as
|
|
||||||
``theme.icon``.
|
|
||||||
"""
|
|
||||||
data = _load_template(template, [kind])
|
|
||||||
|
|
||||||
data["site_name"] = site_name
|
|
||||||
if site_description:
|
|
||||||
data["site_description"] = site_description
|
|
||||||
if site_author:
|
|
||||||
data["site_author"] = site_author
|
|
||||||
data["docs_dir"] = docs_dir
|
|
||||||
data["site_dir"] = site_dir
|
|
||||||
data["nav"] = nav_block
|
|
||||||
|
|
||||||
if theme_icon:
|
|
||||||
theme = data.setdefault("theme", {})
|
|
||||||
if not isinstance(theme, dict):
|
|
||||||
theme = {}
|
|
||||||
theme["icon"] = theme_icon
|
|
||||||
data["theme"] = theme
|
|
||||||
|
|
||||||
out.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8")
|
|
||||||
|
|
||||||
|
|
||||||
def _load_template(
|
|
||||||
template: Path | None,
|
|
||||||
modes: Iterable[str] | None,
|
|
||||||
) -> dict:
|
|
||||||
"""
|
|
||||||
Load the MkDocs configuration template.
|
|
||||||
|
|
||||||
When a custom template path is provided, it is used as-is. Otherwise the
|
|
||||||
shared ``mkdocs.common.yml`` template is deep-merged with the fragments
|
|
||||||
contributed by each enabled mode (``lib``, ``api``, or ``wiki``).
|
|
||||||
|
|
||||||
Args:
|
|
||||||
template (Path | None):
|
|
||||||
Optional fully custom template that replaces the built-ins.
|
|
||||||
|
|
||||||
modes (Iterable[str] | None):
|
|
||||||
Documentation modes whose template fragments should be merged.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict:
|
|
||||||
Merged MkDocs configuration mapping.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.FileError:
|
|
||||||
If a referenced template file cannot be found.
|
|
||||||
"""
|
|
||||||
if template is not None:
|
if template is not None:
|
||||||
if not template.exists():
|
if not template.exists():
|
||||||
raise click.FileError(str(template), hint="Template not found")
|
raise click.FileError(str(template), hint="Template not found")
|
||||||
return yaml.safe_load(template.read_text(encoding="utf-8"))
|
data = yaml.safe_load(template.read_text(encoding="utf-8"))
|
||||||
|
else:
|
||||||
data: dict = {}
|
|
||||||
active_modes = list(modes) if modes else ["lib"]
|
|
||||||
parts = ["common", *active_modes]
|
|
||||||
|
|
||||||
seen: set[str] = set()
|
|
||||||
for part_name in parts:
|
|
||||||
if part_name in seen:
|
|
||||||
continue
|
|
||||||
seen.add(part_name)
|
|
||||||
|
|
||||||
text = (
|
text = (
|
||||||
resources.files("docforge.templates")
|
resources.files("docforge.templates")
|
||||||
.joinpath(f"mkdocs.{part_name}.yml")
|
.joinpath("mkdocs.sample.yml")
|
||||||
.read_text(encoding="utf-8")
|
.read_text(encoding="utf-8")
|
||||||
)
|
)
|
||||||
part: dict = yaml.safe_load(text)
|
data = yaml.safe_load(text)
|
||||||
data = _deep_merge(data, part)
|
|
||||||
|
|
||||||
return data
|
data["site_name"] = site_name
|
||||||
|
data["nav"] = nav_block
|
||||||
|
|
||||||
|
out.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8")
|
||||||
|
|
||||||
def _item_name(item: object) -> str:
|
def build(mkdocs_yml: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Return the identifying name of a list entry.
|
Build the documentation site using MkDocs.
|
||||||
|
|
||||||
String entries identify as themselves; mapping entries identify by their
|
|
||||||
first key. This is used to deduplicate plugin and extension lists.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
item (object):
|
|
||||||
List entry, either a string or a single-key mapping.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str:
|
|
||||||
The identifying name of the entry.
|
|
||||||
"""
|
"""
|
||||||
if isinstance(item, dict):
|
if not mkdocs_yml.exists():
|
||||||
return next(iter(item.keys()), "")
|
raise click.ClickException(f"mkdocs.yml not found: {mkdocs_yml}")
|
||||||
return str(item)
|
|
||||||
|
|
||||||
|
|
||||||
def _merge_list(base: list, added: list) -> list:
|
|
||||||
"""
|
|
||||||
Merge two lists, preserving order and dropping duplicates by name.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
base (list):
|
|
||||||
Existing list entries.
|
|
||||||
added (list):
|
|
||||||
Entries to append when not already present.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list:
|
|
||||||
Merged list with duplicates removed.
|
|
||||||
"""
|
|
||||||
result = list(base)
|
|
||||||
names = {_item_name(item) for item in result}
|
|
||||||
for item in added:
|
|
||||||
name = _item_name(item)
|
|
||||||
if name not in names:
|
|
||||||
result.append(item)
|
|
||||||
names.add(name)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def _deep_merge(base: dict, part: dict) -> dict:
|
|
||||||
"""
|
|
||||||
Deep merge a template fragment into a base configuration.
|
|
||||||
|
|
||||||
Mappings are merged recursively, while lists are combined by
|
|
||||||
deduplicating entries by their identifying name. Non-container values in
|
|
||||||
the fragment override the base.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
base (dict):
|
|
||||||
Configuration being built up.
|
|
||||||
part (dict):
|
|
||||||
Template fragment to merge into the base.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict:
|
|
||||||
The merged configuration.
|
|
||||||
"""
|
|
||||||
for key, value in part.items():
|
|
||||||
if isinstance(value, dict) and isinstance(base.get(key), dict):
|
|
||||||
base[key] = _deep_merge(base[key], value)
|
|
||||||
elif isinstance(value, list) and isinstance(base.get(key), list):
|
|
||||||
base[key] = _merge_list(base[key], value)
|
|
||||||
else:
|
|
||||||
base[key] = value
|
|
||||||
return base
|
|
||||||
|
|
||||||
|
|
||||||
def build_configs(yml_paths: Iterable[Path]) -> None:
|
|
||||||
"""
|
|
||||||
Build the MkDocs documentation site for every given configuration.
|
|
||||||
|
|
||||||
Each configuration file is loaded and built in turn, producing the
|
|
||||||
per-kind static sites (``site/lib``, ``site/api``, ``site/wiki``).
|
|
||||||
|
|
||||||
Args:
|
|
||||||
yml_paths (Iterable[Path]):
|
|
||||||
Configuration files to build, in order.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.ClickException:
|
|
||||||
If a configuration file does not exist.
|
|
||||||
"""
|
|
||||||
from mkdocs.commands.build import build as mkdocs_build
|
|
||||||
from mkdocs.config import load_config
|
from mkdocs.config import load_config
|
||||||
|
from mkdocs.commands.build import build as mkdocs_build
|
||||||
|
|
||||||
for yml in yml_paths:
|
mkdocs_build(load_config(str(mkdocs_yml)))
|
||||||
if not yml.exists():
|
|
||||||
raise click.ClickException(f"mkdocs.yml not found: {yml}")
|
|
||||||
mkdocs_build(load_config(str(yml)))
|
|
||||||
|
|
||||||
|
|
||||||
def serve(mkdocs_yml: Path) -> None:
|
def serve(mkdocs_yml: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Start an MkDocs development server with live reload.
|
Serve the documentation site with live-reload using MkDocs.
|
||||||
|
|
||||||
The server watches documentation files and automatically reloads
|
|
||||||
the site when changes are detected.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
mkdocs_yml (Path):
|
|
||||||
Path to the `mkdocs.yml` configuration file.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
click.ClickException:
|
|
||||||
If the configuration file does not exist.
|
|
||||||
"""
|
"""
|
||||||
if not mkdocs_yml.exists():
|
if not mkdocs_yml.exists():
|
||||||
raise click.ClickException(f"mkdocs.yml not found: {mkdocs_yml}")
|
raise click.ClickException(f"mkdocs.yml not found: {mkdocs_yml}")
|
||||||
|
|
||||||
from mkdocs.commands.serve import serve as mkdocs_serve
|
from mkdocs.commands.serve import serve as mkdocs_serve
|
||||||
|
|
||||||
mkdocs_serve(config_file=str(mkdocs_yml))
|
mkdocs_serve(config_file=str(mkdocs_yml))
|
||||||
|
|||||||
@@ -1,33 +1,6 @@
|
|||||||
from collections.abc import Iterable
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
def generate_sources(
|
def generate_sources(module: str, project_name: str | None, docs_dir: Path) -> None: ...
|
||||||
module: str,
|
def generate_config(docs_dir: Path, nav_file: Path, template: Path | None, out: Path, site_name: str) -> None: ...
|
||||||
docs_dir: Path,
|
def build(mkdocs_yml: Path) -> None: ...
|
||||||
project_name: str | None = None,
|
|
||||||
module_is_source: bool | None = None,
|
|
||||||
readme_dir: Path | None = None,
|
|
||||||
) -> None: ...
|
|
||||||
def build_lib_nav(
|
|
||||||
nav_file: Path,
|
|
||||||
docs_root: Path,
|
|
||||||
) -> tuple[list[dict[str, Any]], dict[str, str] | None]: ...
|
|
||||||
def build_wiki_nav_block(wiki_dir: Path) -> list[dict[str, Any]]: ...
|
|
||||||
def load_spec_icon(nav_file: Path) -> dict[str, str] | None: ...
|
|
||||||
def _strip_scope(value: object, scope: str) -> object: ...
|
|
||||||
def generate_site_config(
|
|
||||||
kind: str,
|
|
||||||
kind_root: Path,
|
|
||||||
nav_block: list[dict[str, Any]],
|
|
||||||
out: Path,
|
|
||||||
site_name: str,
|
|
||||||
docs_dir: str,
|
|
||||||
site_dir: str,
|
|
||||||
template: Path | None = None,
|
|
||||||
site_description: str | None = None,
|
|
||||||
site_author: str | None = None,
|
|
||||||
theme_icon: dict[str, str] | None = None,
|
|
||||||
) -> None: ...
|
|
||||||
def build_configs(yml_paths: Iterable[Path]) -> None: ...
|
|
||||||
def serve(mkdocs_yml: Path) -> None: ...
|
def serve(mkdocs_yml: Path) -> None: ...
|
||||||
|
|||||||
@@ -1,28 +1,17 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
# Loader Layer
|
||||||
|
|
||||||
Loader layer for doc-forge.
|
The `docforge.loaders` package is responsible for discovering Python source files
|
||||||
|
and extracting their documentation using static analysis.
|
||||||
|
|
||||||
The `docforge.loaders` package is responsible for discovering Python modules
|
## Core Features
|
||||||
and extracting documentation data using static analysis.
|
|
||||||
|
|
||||||
---
|
- **Discovery**: Automatically find all modules and packages in a project
|
||||||
|
directory.
|
||||||
# Overview
|
- **Introspection**: Uses `griffe` to parse docstrings, signatures, and
|
||||||
|
hierarchical relationships without executing the code.
|
||||||
This layer converts Python source code into an intermediate documentation
|
- **Filtering**: Automatically excludes private members (prefixed with `_`) to
|
||||||
model used by doc-forge. It performs module discovery, introspection, and
|
ensure clean public documentation.
|
||||||
initial filtering before the data is passed to the core documentation models.
|
|
||||||
|
|
||||||
Core capabilities include:
|
|
||||||
|
|
||||||
- **Module discovery** – Locate Python modules and packages within a project.
|
|
||||||
- **Static introspection** – Parse docstrings, signatures, and object
|
|
||||||
hierarchies using the `griffe` library without executing the code.
|
|
||||||
- **Public API filtering** – Exclude private members (names prefixed with
|
|
||||||
`_`) to produce clean public documentation structures.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .griffe_loader import GriffeLoader, discover_module_paths
|
from .griffe_loader import GriffeLoader, discover_module_paths
|
||||||
|
|||||||
@@ -1,37 +1,21 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
This module provides the GriffeLoader, which uses the 'griffe' library to
|
||||||
|
introspect Python source code and populate the doc-forge Project models.
|
||||||
Utilities for loading and introspecting Python modules using Griffe.
|
|
||||||
|
|
||||||
This module provides the `GriffeLoader` class and helper utilities used to
|
|
||||||
discover Python modules, introspect their structure, and convert the results
|
|
||||||
into doc-forge documentation models.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- All analysis is static; analyzed modules are never executed.
|
|
||||||
- Private members (names starting with `_`) are skipped during conversion.
|
|
||||||
- Imported aliases that cannot be resolved (stdlib/third-party names) are
|
|
||||||
skipped; aliases that resolve within the documented project are kept.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
from griffe import (
|
|
||||||
AliasResolutionError,
|
|
||||||
LinesCollection,
|
|
||||||
ModulesCollection,
|
|
||||||
Object,
|
|
||||||
)
|
|
||||||
from griffe import (
|
from griffe import (
|
||||||
GriffeLoader as _GriffeLoader,
|
GriffeLoader as _GriffeLoader,
|
||||||
|
ModulesCollection,
|
||||||
|
LinesCollection,
|
||||||
|
Object,
|
||||||
|
AliasResolutionError,
|
||||||
)
|
)
|
||||||
|
|
||||||
from docforge.models import DocObject, Module, Project
|
from docforge.models import Module, Project, DocObject
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -39,34 +23,21 @@ logger = logging.getLogger(__name__)
|
|||||||
def discover_module_paths(
|
def discover_module_paths(
|
||||||
module_name: str,
|
module_name: str,
|
||||||
project_root: Path | None = None,
|
project_root: Path | None = None,
|
||||||
) -> list[str]:
|
) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Discover Python modules within a package directory.
|
Discover all Python modules under a package via filesystem traversal.
|
||||||
|
|
||||||
The function scans the filesystem for `.py` files inside the specified
|
Rules:
|
||||||
package and converts them into dotted module import paths.
|
- Directory with __init__.py is treated as a package.
|
||||||
|
- Any .py file is treated as a module.
|
||||||
Discovery rules:
|
- All paths are converted to dotted module paths.
|
||||||
|
|
||||||
- Directories containing `__init__.py` are treated as packages.
|
|
||||||
- Each `.py` file is treated as a module.
|
|
||||||
- Results are returned as dotted import paths.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
module_name (str):
|
module_name: The name of the package to discover.
|
||||||
Top-level package name to discover modules from.
|
project_root: The root directory of the project. Defaults to current working directory.
|
||||||
|
|
||||||
project_root (Path | None):
|
|
||||||
Root directory used to resolve module paths. If not provided, the
|
|
||||||
current working directory is used.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]:
|
A sorted list of dotted module paths.
|
||||||
A sorted list of unique dotted module import paths.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
FileNotFoundError:
|
|
||||||
If the specified package directory does not exist.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if project_root is None:
|
if project_root is None:
|
||||||
@@ -76,7 +47,7 @@ def discover_module_paths(
|
|||||||
if not pkg_dir.exists():
|
if not pkg_dir.exists():
|
||||||
raise FileNotFoundError(f"Package not found: {pkg_dir}")
|
raise FileNotFoundError(f"Package not found: {pkg_dir}")
|
||||||
|
|
||||||
module_paths: list[str] = []
|
module_paths: List[str] = []
|
||||||
|
|
||||||
for path in pkg_dir.rglob("*.py"):
|
for path in pkg_dir.rglob("*.py"):
|
||||||
if path.name == "__init__.py":
|
if path.name == "__init__.py":
|
||||||
@@ -93,23 +64,12 @@ def discover_module_paths(
|
|||||||
|
|
||||||
class GriffeLoader:
|
class GriffeLoader:
|
||||||
"""
|
"""
|
||||||
Load Python modules using Griffe and convert them into doc-forge models.
|
Loads Python modules and extracts documentation using the Griffe introspection engine.
|
||||||
|
|
||||||
This loader uses the Griffe introspection engine to analyze Python source
|
|
||||||
code and transform the extracted information into `Project`, `Module`,
|
|
||||||
and `DocObject` instances used by doc-forge.
|
|
||||||
|
|
||||||
Attributes:
|
|
||||||
_loader (_GriffeLoader):
|
|
||||||
Internal Griffe loader with dedicated module and line collections.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize the Griffe-backed loader.
|
Initialize the GriffeLoader.
|
||||||
|
|
||||||
Creates an internal Griffe loader instance with dedicated collections
|
|
||||||
for modules and source lines.
|
|
||||||
"""
|
"""
|
||||||
self._loader = _GriffeLoader(
|
self._loader = _GriffeLoader(
|
||||||
modules_collection=ModulesCollection(),
|
modules_collection=ModulesCollection(),
|
||||||
@@ -118,38 +78,20 @@ class GriffeLoader:
|
|||||||
|
|
||||||
def load_project(
|
def load_project(
|
||||||
self,
|
self,
|
||||||
module_paths: list[str],
|
module_paths: List[str],
|
||||||
project_name: str | None = None,
|
project_name: Optional[str] = None,
|
||||||
skip_import_errors: bool | None = None,
|
skip_import_errors: bool = None,
|
||||||
) -> Project:
|
) -> Project:
|
||||||
"""
|
"""
|
||||||
Load multiple modules and assemble them into a Project model.
|
Load multiple modules and combine them into a single Project models.
|
||||||
|
|
||||||
Each module path is introspected and converted into a `Module`
|
|
||||||
instance. All modules are then aggregated into a single `Project`
|
|
||||||
object.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
module_paths (list[str]):
|
module_paths: A list of dotted paths to the modules to load.
|
||||||
List of dotted module import paths to load.
|
project_name: Optional name for the project. Defaults to the first module name.
|
||||||
|
skip_import_errors: If True, modules that fail to import will be skipped.
|
||||||
project_name (str | None):
|
|
||||||
Optional override for the project name. Defaults to the top-level
|
|
||||||
name of the first module.
|
|
||||||
|
|
||||||
skip_import_errors (bool | None):
|
|
||||||
If True, modules that fail to load will be skipped instead of raising an error.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Project:
|
A Project instance containing the loaded modules.
|
||||||
A populated `Project` instance containing the loaded modules.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
ValueError:
|
|
||||||
If no module paths are provided.
|
|
||||||
|
|
||||||
ImportError:
|
|
||||||
If a module fails to load and `skip_import_errors` is False.
|
|
||||||
"""
|
"""
|
||||||
if not module_paths:
|
if not module_paths:
|
||||||
raise ValueError("At least one module path must be provided")
|
raise ValueError("At least one module path must be provided")
|
||||||
@@ -174,33 +116,13 @@ class GriffeLoader:
|
|||||||
|
|
||||||
def load_module(self, path: str) -> Module:
|
def load_module(self, path: str) -> Module:
|
||||||
"""
|
"""
|
||||||
Load and convert a single Python module.
|
Load a single module and convert its introspection data into the docforge models.
|
||||||
|
|
||||||
The module is introspected using Griffe and then transformed into
|
|
||||||
a doc-forge `Module` model.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (str):
|
path: The dotted path of the module to load.
|
||||||
Dotted import path of the module.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Module:
|
A Module instance.
|
||||||
A populated `Module` instance.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
ImportError:
|
|
||||||
If the module cannot be loaded by Griffe.
|
|
||||||
|
|
||||||
KeyError:
|
|
||||||
If the loaded module is missing from the module collection.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
Load a single module:
|
|
||||||
|
|
||||||
```python
|
|
||||||
loader = GriffeLoader()
|
|
||||||
module = loader.load_module("mypackage.submodule")
|
|
||||||
```
|
|
||||||
"""
|
"""
|
||||||
self._loader.load(path)
|
self._loader.load(path)
|
||||||
griffe_module = self._loader.modules_collection[path]
|
griffe_module = self._loader.modules_collection[path]
|
||||||
@@ -213,18 +135,13 @@ class GriffeLoader:
|
|||||||
|
|
||||||
def _convert_module(self, obj: Object) -> Module:
|
def _convert_module(self, obj: Object) -> Module:
|
||||||
"""
|
"""
|
||||||
Convert a Griffe module object into a doc-forge Module.
|
Convert a Griffe Object (module) into a docforge Module.
|
||||||
|
|
||||||
All public members of the module are recursively converted into
|
|
||||||
`DocObject` instances.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj (Object):
|
obj: The Griffe Object representing the module.
|
||||||
Griffe object representing the module.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Module:
|
A populated Module instance.
|
||||||
A populated `Module` model.
|
|
||||||
"""
|
"""
|
||||||
module = Module(
|
module = Module(
|
||||||
path=obj.path,
|
path=obj.path,
|
||||||
@@ -234,8 +151,6 @@ class GriffeLoader:
|
|||||||
for name, member in obj.members.items():
|
for name, member in obj.members.items():
|
||||||
if name.startswith("_"):
|
if name.startswith("_"):
|
||||||
continue
|
continue
|
||||||
if not self._is_resolvable_alias(member):
|
|
||||||
continue
|
|
||||||
|
|
||||||
module.add_object(self._convert_object(member))
|
module.add_object(self._convert_object(member))
|
||||||
|
|
||||||
@@ -243,19 +158,13 @@ class GriffeLoader:
|
|||||||
|
|
||||||
def _convert_object(self, obj: Object) -> DocObject:
|
def _convert_object(self, obj: Object) -> DocObject:
|
||||||
"""
|
"""
|
||||||
Convert a Griffe object into a doc-forge DocObject.
|
Recursively convert a Griffe Object into a DocObject hierarchy.
|
||||||
|
|
||||||
The conversion preserves the object's metadata such as name,
|
|
||||||
kind, path, signature, and docstring. Child members are processed
|
|
||||||
recursively.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj (Object):
|
obj: The Griffe Object to convert.
|
||||||
Griffe object representing a documented Python object.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
DocObject:
|
A DocObject instance.
|
||||||
A `DocObject` instance representing the converted object.
|
|
||||||
"""
|
"""
|
||||||
kind = obj.kind.value
|
kind = obj.kind.value
|
||||||
signature = self._safe_signature(obj)
|
signature = self._safe_signature(obj)
|
||||||
@@ -272,8 +181,6 @@ class GriffeLoader:
|
|||||||
for name, member in obj.members.items():
|
for name, member in obj.members.items():
|
||||||
if name.startswith("_"):
|
if name.startswith("_"):
|
||||||
continue
|
continue
|
||||||
if not self._is_resolvable_alias(member):
|
|
||||||
continue
|
|
||||||
doc_obj.add_member(self._convert_object(member))
|
doc_obj.add_member(self._convert_object(member))
|
||||||
except AliasResolutionError:
|
except AliasResolutionError:
|
||||||
pass
|
pass
|
||||||
@@ -284,74 +191,34 @@ class GriffeLoader:
|
|||||||
# Safe extractors
|
# Safe extractors
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
||||||
def _safe_docstring(self, obj: Object) -> str | None:
|
def _safe_docstring(self, obj: Object) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Safely extract a docstring from a Griffe object.
|
Safely retrieve the docstring value from a Griffe object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj (Object):
|
obj: The Griffe Object to inspect.
|
||||||
Griffe object to inspect.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str | None:
|
The raw docstring string, or None if missing or unresolvable.
|
||||||
The raw docstring text if available, otherwise `None`.
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return obj.docstring.value if obj.docstring else None
|
return obj.docstring.value if obj.docstring else None
|
||||||
except AliasResolutionError:
|
except AliasResolutionError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _safe_signature(self, obj: Object) -> str | None:
|
def _safe_signature(self, obj: Object) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
Safely extract the signature of a Griffe object.
|
Safely retrieve the signature string from a Griffe object.
|
||||||
|
|
||||||
Griffe exposes signatures as callables (``Object.signature``); the
|
|
||||||
method is invoked and stringified to produce a clean, stable signature.
|
|
||||||
Aliases that point outside the loaded project fail resolution and are
|
|
||||||
reported as `None`.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj (Object):
|
obj: The Griffe Object to inspect.
|
||||||
Griffe object to inspect.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str | None:
|
The string representation of the signature, or None.
|
||||||
Clean string representation of the object's signature if
|
|
||||||
available, otherwise `None`.
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
signature = getattr(obj, "signature", None)
|
if hasattr(obj, "signature") and obj.signature:
|
||||||
if signature is None:
|
return str(obj.signature)
|
||||||
return None
|
|
||||||
if callable(signature):
|
|
||||||
signature = signature()
|
|
||||||
if not signature:
|
|
||||||
return None
|
|
||||||
return str(signature).strip() or None
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _is_resolvable_alias(self, obj: Object) -> bool:
|
|
||||||
"""
|
|
||||||
Report whether an object is a resolvable part of the documented API.
|
|
||||||
|
|
||||||
Aliases that cannot be resolved (stdlib or third-party imports) are
|
|
||||||
treated as noise and excluded from the model. Non-alias objects are
|
|
||||||
always resolvable.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj (Object):
|
|
||||||
Griffe object to test.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool:
|
|
||||||
True if the object should be kept, False if it is an
|
|
||||||
unresolvable alias.
|
|
||||||
"""
|
|
||||||
if obj.kind.value != "alias":
|
|
||||||
return True
|
|
||||||
try:
|
|
||||||
_ = obj.canonical_path
|
|
||||||
except AliasResolutionError:
|
except AliasResolutionError:
|
||||||
return False
|
return None
|
||||||
return True
|
return None
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
|
from typing import List, Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from docforge.models import Module, Project
|
from docforge.models import Module, Project
|
||||||
|
|
||||||
|
|
||||||
def discover_module_paths(
|
def discover_module_paths(
|
||||||
module_name: str,
|
module_name: str,
|
||||||
project_root: Path | None = None,
|
project_root: Path | None = None,
|
||||||
) -> list[str]: ...
|
) -> List[str]:
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
class GriffeLoader:
|
class GriffeLoader:
|
||||||
"""Griffe-based introspection loaders.
|
"""Griffe-based introspection loaders.
|
||||||
|
|
||||||
This is the only supported introspection backend in doc-forge.
|
This is the only supported introspection backend in doc-forge.
|
||||||
Converts Griffe results into `Project`, `Module`, and `DocObject` models.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None: ...
|
def __init__(self) -> None: ...
|
||||||
|
|
||||||
def load_project(
|
def load_project(
|
||||||
self,
|
self,
|
||||||
module_paths: list[str],
|
module_paths: List[str],
|
||||||
project_name: str | None = ...,
|
project_name: Optional[str] = ...,
|
||||||
skip_import_errors: bool | None = ...,
|
skip_import_errors: bool = ...,
|
||||||
) -> Project:
|
) -> Project:
|
||||||
"""Load a documentation project from Python modules."""
|
"""Load a documentation project from Python modules."""
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
MkDocs plugin that fixes cross-kind relative links in generated wikis.
|
|
||||||
|
|
||||||
A repository served under ``/<repo>/<kind>/`` (for example a wiki at
|
|
||||||
``/myrepo/wiki/`` and a library reference at ``/myrepo/lib/``) is built as
|
|
||||||
two independent MkDocs sites. Authors naturally write links between them
|
|
||||||
using source-relative paths such as ``../lib/01_build_recipe/``.
|
|
||||||
|
|
||||||
MkDocs only rewrites links whose target lives inside ``docs_dir``; anything
|
|
||||||
pointing at a sibling site is emitted verbatim. When ``use_directory_urls``
|
|
||||||
is enabled (the default) the rendered page sits one or more directory levels
|
|
||||||
deeper than its source, so ``../lib/`` resolves to ``/<repo>/wiki/lib/`` and
|
|
||||||
breaks.
|
|
||||||
|
|
||||||
`docforge-linkfix` rewrites such links at render time, prefixing them with
|
|
||||||
enough ``../`` segments to climb back to the repository root so they resolve
|
|
||||||
to ``/<repo>/<kind>/`` regardless of how deeply the page is nested.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import re
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from mkdocs.plugins import BasePlugin
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from mkdocs.config.defaults import MkDocsConfig
|
|
||||||
from mkdocs.structure.files import Files
|
|
||||||
from mkdocs.structure.pages import Page
|
|
||||||
|
|
||||||
__all__ = ["LinkFixPlugin"]
|
|
||||||
|
|
||||||
_CROSS_KIND_LINK = re.compile(r"\]\((?:\.\./)+(lib|api|wiki)/")
|
|
||||||
"""Matches a Markdown link whose target climbs out of the current doc kind."""
|
|
||||||
|
|
||||||
|
|
||||||
class LinkFixPlugin(BasePlugin): # type: ignore[no-untyped-call, type-arg]
|
|
||||||
"""
|
|
||||||
Rewrite cross-kind relative links so they survive directory URLs.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def on_page_markdown(
|
|
||||||
self,
|
|
||||||
markdown: str,
|
|
||||||
/,
|
|
||||||
*,
|
|
||||||
page: Page,
|
|
||||||
config: MkDocsConfig,
|
|
||||||
files: Files,
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Prefix cross-kind links with the depth required to reach the repo root.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
markdown (str): The raw Markdown source of the current page.
|
|
||||||
page (Page): The page being rendered; its destination URI is used
|
|
||||||
to determine how many directory levels the output sits below
|
|
||||||
the site root.
|
|
||||||
config (MkDocsConfig): The active MkDocs configuration.
|
|
||||||
files (Files): The collection of files in the site.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: The Markdown with cross-kind links rebased to the repo root.
|
|
||||||
"""
|
|
||||||
depth = page.file.dest_uri.count("/")
|
|
||||||
prefix = "../" * (depth + 1)
|
|
||||||
return _CROSS_KIND_LINK.sub(
|
|
||||||
lambda match: f"]({prefix}{match.group(1)}/", markdown
|
|
||||||
)
|
|
||||||
@@ -1,33 +1,17 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
# Model Layer
|
||||||
|
|
||||||
Model layer for doc-forge.
|
The `docforge.models` package provides the core data structures used to represent
|
||||||
|
Python source code in a documentation-focused hierarchy.
|
||||||
|
|
||||||
The `docforge.models` package defines the core data structures used to
|
## Key Components
|
||||||
represent Python source code as a structured documentation model.
|
|
||||||
|
|
||||||
---
|
- **Project**: The root container for all documented modules.
|
||||||
|
- **Module**: Represents a Python module or package, containing members.
|
||||||
|
- **DocObject**: A recursive structure for classes, functions, and attributes.
|
||||||
|
|
||||||
# Overview
|
These classes are designed to be renderer-agnostic, allowing the same internal
|
||||||
|
representation to be transformed into various output formats (currently MkDocs).
|
||||||
The model layer forms the central intermediate representation used throughout
|
|
||||||
doc-forge. Python modules and objects discovered during introspection are
|
|
||||||
converted into a hierarchy of documentation models that can later be rendered
|
|
||||||
into different documentation formats.
|
|
||||||
|
|
||||||
Key components:
|
|
||||||
|
|
||||||
- **Project** – Root container representing an entire documented codebase.
|
|
||||||
- **Module** – Representation of a Python module or package containing
|
|
||||||
documented members.
|
|
||||||
- **DocObject** – Recursive structure representing Python objects such as
|
|
||||||
classes, functions, methods, and attributes.
|
|
||||||
|
|
||||||
These models are intentionally **renderer-agnostic**, allowing the same
|
|
||||||
documentation structure to be transformed into multiple output formats
|
|
||||||
(e.g., MkDocs, MCP, or other renderers).
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .project import Project
|
from .project import Project
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
from .project import Project
|
||||||
from .module import Module
|
from .module import Module
|
||||||
from .object import DocObject
|
from .object import DocObject
|
||||||
from .project import Project
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Project",
|
"Project",
|
||||||
|
|||||||
@@ -1,98 +1,66 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
This module defines the Module class, which represents a Python module or package
|
||||||
|
in the doc-forge documentation models. It acts as a container for top-level
|
||||||
Documentation model representing a Python module or package.
|
documented objects.
|
||||||
|
|
||||||
This module defines the `Module` class used in the doc-forge documentation
|
|
||||||
model. A `Module` acts as a container for top-level documented objects
|
|
||||||
(classes, functions, variables, and other members) discovered during
|
|
||||||
introspection.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- Only public members are stored; private names are filtered by the loader.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Iterable
|
from typing import Dict, Iterable, Optional
|
||||||
|
|
||||||
from docforge.models.object import DocObject
|
from docforge.models.object import DocObject
|
||||||
|
|
||||||
|
|
||||||
class Module:
|
class Module:
|
||||||
"""
|
"""
|
||||||
Representation of a documented Python module or package.
|
Represents a documented Python module or package.
|
||||||
|
|
||||||
A `Module` stores metadata about the module itself and maintains a
|
|
||||||
collection of top-level documentation objects discovered during
|
|
||||||
introspection.
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
path (str):
|
path: Dotted import path of the module.
|
||||||
Dotted import path of the module.
|
docstring: Module-level docstring content.
|
||||||
|
members: Dictionary mapping object names to their DocObject representations.
|
||||||
docstring (str | None):
|
|
||||||
Module-level documentation string, if present.
|
|
||||||
|
|
||||||
members (dict[str, DocObject]):
|
|
||||||
Mapping of object names to their corresponding `DocObject` representations.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
docstring: str | None = None,
|
docstring: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a Module instance.
|
Initialize a new Module.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (str):
|
path: The dotted path of the module.
|
||||||
Dotted import path identifying the module.
|
docstring: The module's docstring, if any.
|
||||||
|
|
||||||
docstring (str | None):
|
|
||||||
Module-level documentation text, if available.
|
|
||||||
"""
|
"""
|
||||||
self.path = path
|
self.path = path
|
||||||
self.docstring = docstring
|
self.docstring = docstring
|
||||||
self.members: dict[str, DocObject] = {}
|
self.members: Dict[str, DocObject] = {}
|
||||||
|
|
||||||
def add_object(self, obj: DocObject) -> None:
|
def add_object(self, obj: DocObject) -> None:
|
||||||
"""
|
"""
|
||||||
Add a documented object to the module.
|
Add a documented object to the module.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj (DocObject):
|
obj: The object to add.
|
||||||
Documentation object to register as a top-level member of the module.
|
|
||||||
"""
|
"""
|
||||||
self.members[obj.name] = obj
|
self.members[obj.name] = obj
|
||||||
|
|
||||||
def get_object(self, name: str) -> DocObject:
|
def get_object(self, name: str) -> DocObject:
|
||||||
"""
|
"""
|
||||||
Retrieve a documented object by name.
|
Retrieve a member object by name.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str):
|
name: The name of the object.
|
||||||
Name of the object to retrieve.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
DocObject:
|
The requested DocObject.
|
||||||
The corresponding `DocObject` instance.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
KeyError:
|
|
||||||
If no object with the given name exists.
|
|
||||||
"""
|
"""
|
||||||
return self.members[name]
|
return self.members[name]
|
||||||
|
|
||||||
def get_all_objects(self) -> Iterable[DocObject]:
|
def get_all_objects(self) -> Iterable[DocObject]:
|
||||||
"""
|
"""
|
||||||
Return all top-level documentation objects in the module.
|
Get all top-level objects in the module.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Iterable[DocObject]:
|
An iterable of DocObject instances.
|
||||||
An iterable of `DocObject` instances representing the module's public members.
|
|
||||||
"""
|
"""
|
||||||
return self.members.values()
|
return self.members.values()
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
from collections.abc import Iterable
|
from typing import Dict, Iterable, Optional
|
||||||
|
|
||||||
from docforge.models.object import DocObject
|
from docforge.models.object import DocObject
|
||||||
|
|
||||||
|
|
||||||
class Module:
|
class Module:
|
||||||
"""Represents a documented Python module."""
|
"""Represents a documented Python module."""
|
||||||
|
|
||||||
path: str
|
path: str
|
||||||
docstring: str | None
|
docstring: Optional[str]
|
||||||
members: dict[str, DocObject]
|
members: Dict[str, DocObject]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
docstring: str | None = ...,
|
docstring: Optional[str] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
def add_object(self, obj: DocObject) -> None: ...
|
def add_object(self, obj: DocObject) -> None: ...
|
||||||
|
|
||||||
def get_object(self, name: str) -> DocObject: ...
|
def get_object(self, name: str) -> DocObject: ...
|
||||||
|
|
||||||
def get_all_objects(self) -> Iterable[DocObject]: ...
|
def get_all_objects(self) -> Iterable[DocObject]: ...
|
||||||
|
|||||||
@@ -1,51 +1,23 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
This module defines the DocObject class, the fundamental recursive unit of the
|
||||||
|
doc-forge documentation models. A DocObject represents a single Python entity
|
||||||
Documentation model representing individual Python objects.
|
(class, function, method, or attribute) and its nested members.
|
||||||
|
|
||||||
This module defines the `DocObject` class, the fundamental recursive unit of
|
|
||||||
the doc-forge documentation model. Each `DocObject` represents a Python
|
|
||||||
entity such as a class, function, method, or attribute, and may contain nested
|
|
||||||
members that form a hierarchical documentation structure.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- `DocObject` instances form a tree mirroring the Python import hierarchy.
|
|
||||||
- Objects are renderer-agnostic and may be consumed by any renderer.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Iterable
|
from typing import Dict, Iterable, Optional
|
||||||
|
|
||||||
|
|
||||||
class DocObject:
|
class DocObject:
|
||||||
"""
|
"""
|
||||||
Representation of a documented Python object.
|
Represents a documented Python object (class, function, method, etc.).
|
||||||
|
|
||||||
A `DocObject` models a single Python entity discovered during
|
|
||||||
introspection. Objects may contain nested members, allowing the structure
|
|
||||||
of modules, classes, and other containers to be represented recursively.
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
name (str):
|
name: Local name of the object.
|
||||||
Local name of the object.
|
kind: Type of object (e.g., 'class', 'function', 'attribute').
|
||||||
|
path: Full dotted import path to the object.
|
||||||
kind (str):
|
signature: Callable signature, if applicable.
|
||||||
Type of object (for example `class`, `function`, `method`, or `attribute`).
|
docstring: Raw docstring content extracted from the source.
|
||||||
|
members: Dictionary mapping member names to their DocObject representations.
|
||||||
path (str):
|
|
||||||
Fully qualified dotted path to the object.
|
|
||||||
|
|
||||||
signature (str | None):
|
|
||||||
Callable signature if the object represents a callable.
|
|
||||||
|
|
||||||
docstring (str | None):
|
|
||||||
Raw docstring text extracted from the source code.
|
|
||||||
|
|
||||||
members (dict[str, DocObject]):
|
|
||||||
Mapping of member names to child `DocObject` instances.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -53,72 +25,52 @@ class DocObject:
|
|||||||
name: str,
|
name: str,
|
||||||
kind: str,
|
kind: str,
|
||||||
path: str,
|
path: str,
|
||||||
signature: str | None = None,
|
signature: Optional[str] = None,
|
||||||
docstring: str | None = None,
|
docstring: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a DocObject instance.
|
Initialize a new DocObject.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str):
|
name: The local name of the object.
|
||||||
Local name of the object.
|
kind: The kind of object (e.g., 'class', 'function').
|
||||||
|
path: The full dotted path to the object.
|
||||||
kind (str):
|
signature: The object's signature (for callable objects).
|
||||||
Object type identifier (for example `class` or `function`).
|
docstring: The object's docstring, if any.
|
||||||
|
|
||||||
path (str):
|
|
||||||
Fully qualified dotted path of the object.
|
|
||||||
|
|
||||||
signature (str | None):
|
|
||||||
Callable signature if applicable.
|
|
||||||
|
|
||||||
docstring (str | None):
|
|
||||||
Documentation string associated with the object.
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
self.path = path
|
self.path = path
|
||||||
self.signature = signature
|
self.signature = signature
|
||||||
self.docstring = docstring
|
self.docstring = docstring
|
||||||
self.members: dict[str, DocObject] = {}
|
self.members: Dict[str, 'DocObject'] = {}
|
||||||
|
|
||||||
def add_member(self, obj: "DocObject") -> None:
|
def add_member(self, obj: 'DocObject') -> None:
|
||||||
"""
|
"""
|
||||||
Add a child documentation object.
|
Add a child member to this object (e.g., a method to a class).
|
||||||
|
|
||||||
This is typically used when attaching methods to classes or
|
|
||||||
nested objects to their parent containers.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj (DocObject):
|
obj: The child DocObject to add.
|
||||||
Documentation object to add as a member.
|
|
||||||
"""
|
"""
|
||||||
self.members[obj.name] = obj
|
self.members[obj.name] = obj
|
||||||
|
|
||||||
def get_member(self, name: str) -> "DocObject":
|
def get_member(self, name: str) -> 'DocObject':
|
||||||
"""
|
"""
|
||||||
Retrieve a member object by name.
|
Retrieve a child member by name.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str):
|
name: The name of the member.
|
||||||
Name of the member to retrieve.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
DocObject:
|
The requested DocObject.
|
||||||
The corresponding `DocObject` instance.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
KeyError:
|
|
||||||
If the member does not exist.
|
|
||||||
"""
|
"""
|
||||||
return self.members[name]
|
return self.members[name]
|
||||||
|
|
||||||
def get_all_members(self) -> Iterable["DocObject"]:
|
def get_all_members(self) -> Iterable['DocObject']:
|
||||||
"""
|
"""
|
||||||
Return all child members of the object.
|
Get all members of this object.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Iterable[DocObject]:
|
An iterable of child DocObject instances.
|
||||||
An iterable of `DocObject` instances representing nested members.
|
|
||||||
"""
|
"""
|
||||||
return self.members.values()
|
return self.members.values()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from collections.abc import Iterable
|
from typing import Dict, Iterable, Optional
|
||||||
|
|
||||||
|
|
||||||
class DocObject:
|
class DocObject:
|
||||||
"""Represents a documented Python object."""
|
"""Represents a documented Python object."""
|
||||||
@@ -6,18 +7,21 @@ class DocObject:
|
|||||||
name: str
|
name: str
|
||||||
kind: str
|
kind: str
|
||||||
path: str
|
path: str
|
||||||
signature: str | None
|
signature: Optional[str]
|
||||||
docstring: str | None
|
docstring: Optional[str]
|
||||||
members: dict[str, DocObject]
|
members: Dict[str, "DocObject"]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
kind: str,
|
kind: str,
|
||||||
path: str,
|
path: str,
|
||||||
signature: str | None = ...,
|
signature: Optional[str] = ...,
|
||||||
docstring: str | None = ...,
|
docstring: Optional[str] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def add_member(self, obj: DocObject) -> None: ...
|
|
||||||
def get_member(self, name: str) -> DocObject: ...
|
def add_member(self, obj: "DocObject") -> None: ...
|
||||||
def get_all_members(self) -> Iterable[DocObject]: ...
|
|
||||||
|
def get_member(self, name: str) -> "DocObject": ...
|
||||||
|
|
||||||
|
def get_all_members(self) -> Iterable["DocObject"]: ...
|
||||||
|
|||||||
@@ -1,67 +1,38 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
This module defines the Project class, the top-level container for a documented
|
||||||
|
project. It aggregates multiple Module instances into a single named entity.
|
||||||
Documentation model representing a project.
|
|
||||||
|
|
||||||
This module defines the `Project` class, the top-level container used by
|
|
||||||
doc-forge to represent a documented codebase. A `Project` aggregates multiple
|
|
||||||
modules and provides access to them through a unified interface.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- Modules are keyed by their dotted import path.
|
|
||||||
- Objects are renderer-agnostic; the same model feeds every renderer.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Iterable
|
from typing import Dict, Iterable
|
||||||
|
|
||||||
from docforge.models.module import Module
|
from docforge.models.module import Module
|
||||||
|
|
||||||
|
|
||||||
class Project:
|
class Project:
|
||||||
"""
|
"""
|
||||||
Representation of a documentation project.
|
Represents a documentation project, serving as a container for modules.
|
||||||
|
|
||||||
A `Project` serves as the root container for all modules discovered during
|
|
||||||
introspection. Each module is stored by its dotted import path.
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
name (str):
|
name: Name of the project.
|
||||||
Name of the project.
|
modules: Dictionary mapping module paths to Module instances.
|
||||||
|
|
||||||
modules (dict[str, Module]):
|
|
||||||
Mapping of module paths to `Module` instances.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str) -> None:
|
def __init__(self, name: str) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a Project instance.
|
Initialize a new Project.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str):
|
name: The name of the project.
|
||||||
Name used to identify the documentation project.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
Create a project and register a module:
|
|
||||||
|
|
||||||
```python
|
|
||||||
project = Project("mypackage")
|
|
||||||
project.add_module(module)
|
|
||||||
```
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.modules: dict[str, Module] = {}
|
self.modules: Dict[str, Module] = {}
|
||||||
|
|
||||||
def add_module(self, module: Module) -> None:
|
def add_module(self, module: Module) -> None:
|
||||||
"""
|
"""
|
||||||
Register a module in the project.
|
Add a module to the project.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
module (Module):
|
module: The module to add.
|
||||||
Module instance to add to the project.
|
|
||||||
"""
|
"""
|
||||||
self.modules[module.path] = module
|
self.modules[module.path] = module
|
||||||
|
|
||||||
@@ -70,35 +41,27 @@ class Project:
|
|||||||
Retrieve a module by its dotted path.
|
Retrieve a module by its dotted path.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (str):
|
path: The dotted path of the module (e.g., 'pkg.mod').
|
||||||
Fully qualified dotted module path (for example `pkg.module`).
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Module:
|
The requested Module.
|
||||||
The corresponding `Module` instance.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
KeyError:
|
|
||||||
If the module does not exist in the project.
|
|
||||||
"""
|
"""
|
||||||
return self.modules[path]
|
return self.modules[path]
|
||||||
|
|
||||||
def get_all_modules(self) -> Iterable[Module]:
|
def get_all_modules(self) -> Iterable[Module]:
|
||||||
"""
|
"""
|
||||||
Return all modules contained in the project.
|
Get all modules in the project.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Iterable[Module]:
|
An iterable of Module objects.
|
||||||
An iterable of `Module` instances.
|
|
||||||
"""
|
"""
|
||||||
return self.modules.values()
|
return self.modules.values()
|
||||||
|
|
||||||
def get_module_list(self) -> list[str]:
|
def get_module_list(self) -> list[str]:
|
||||||
"""
|
"""
|
||||||
Return the list of module import paths.
|
Get the list of all module dotted paths.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]:
|
A list of module paths.
|
||||||
A list containing the dotted paths of all modules in the project.
|
|
||||||
"""
|
"""
|
||||||
return list(self.modules.keys())
|
return list(self.modules.keys())
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
from collections.abc import Iterable
|
from typing import Dict, Iterable
|
||||||
|
|
||||||
from docforge.models.module import Module
|
from docforge.models.module import Module
|
||||||
|
|
||||||
|
|
||||||
class Project:
|
class Project:
|
||||||
"""Represents a documentation project."""
|
"""Represents a documentation project."""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
modules: dict[str, Module]
|
modules: Dict[str, Module]
|
||||||
|
|
||||||
def __init__(self, name: str) -> None: ...
|
def __init__(self, name: str) -> None: ...
|
||||||
|
|
||||||
def add_module(self, module: Module) -> None: ...
|
def add_module(self, module: Module) -> None: ...
|
||||||
|
|
||||||
def get_module(self, path: str) -> Module: ...
|
def get_module(self, path: str) -> Module: ...
|
||||||
|
|
||||||
def get_all_modules(self) -> Iterable[Module]: ...
|
def get_all_modules(self) -> Iterable[Module]: ...
|
||||||
|
|
||||||
def get_module_list(self) -> list[str]: ...
|
def get_module_list(self) -> list[str]: ...
|
||||||
|
|||||||
@@ -1,38 +1,27 @@
|
|||||||
"""
|
"""
|
||||||
Navigation layer for doc-forge.
|
# Navigation Layer
|
||||||
|
|
||||||
The ``docforge.nav`` package manages the relationship between the logical
|
The `docforge.nav` package manages the mapping between the logical documentation
|
||||||
documentation structure defined by the user and the physical documentation
|
structure and the physical files on disk.
|
||||||
files generated on disk.
|
|
||||||
|
|
||||||
---
|
## Workflow
|
||||||
|
|
||||||
Workflow
|
1. **Spec Definition**: Users define navigation intent in `docforge.nav.yml`.
|
||||||
--------
|
2. **Resolution**: `resolve_nav` matches patterns in the spec to generated `.md` files.
|
||||||
|
3. **Emission**: `MkDocsNavEmitter` produces the final YAML structure for `mkdocs.yml`.
|
||||||
|
|
||||||
1. **Specification** – Users define navigation intent in ``docforge.nav.yml``.
|
This abstraction allows doc-forge to support complex grouping and ordering
|
||||||
2. **Resolution** – ``resolve_nav`` expands patterns and matches them against
|
independently of the source code's physical layout.
|
||||||
generated Markdown files.
|
|
||||||
3. **Emission** – ``MkDocsNavEmitter`` converts the resolved structure into
|
|
||||||
the YAML navigation format required by ``mkdocs.yml``.
|
|
||||||
|
|
||||||
This layer separates documentation organization from the underlying source
|
|
||||||
code layout, enabling flexible grouping, ordering, and navigation structures
|
|
||||||
independent of module hierarchy.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .spec import NavSpec, load_nav_spec
|
from .spec import NavSpec, load_nav_spec
|
||||||
from .resolver import ResolvedNav, resolve_nav
|
from .resolver import ResolvedNav, resolve_nav
|
||||||
from .mkdocs import MkDocsNavEmitter
|
from .mkdocs import MkDocsNavEmitter
|
||||||
from .wiki import build_wiki_nav
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"NavSpec",
|
"NavSpec",
|
||||||
"ResolvedNav",
|
"ResolvedNav",
|
||||||
"MkDocsNavEmitter",
|
"MkDocsNavEmitter",
|
||||||
"build_wiki_nav",
|
|
||||||
"resolve_nav",
|
"resolve_nav",
|
||||||
"load_nav_spec",
|
"load_nav_spec",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
from .mkdocs import MkDocsNavEmitter
|
|
||||||
from .resolver import ResolvedNav, resolve_nav
|
|
||||||
from .spec import NavSpec, load_nav_spec
|
from .spec import NavSpec, load_nav_spec
|
||||||
from .wiki import build_wiki_nav
|
from .resolver import ResolvedNav, resolve_nav
|
||||||
|
from .mkdocs import MkDocsNavEmitter
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"NavSpec",
|
"NavSpec",
|
||||||
"ResolvedNav",
|
"ResolvedNav",
|
||||||
"MkDocsNavEmitter",
|
"MkDocsNavEmitter",
|
||||||
"build_wiki_nav",
|
|
||||||
"resolve_nav",
|
"resolve_nav",
|
||||||
"load_nav_spec",
|
"load_nav_spec",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,49 +1,32 @@
|
|||||||
"""
|
"""
|
||||||
MkDocs navigation emitter.
|
This module provides the MkDocsNavEmitter, which converts a ResolvedNav instance
|
||||||
|
into the specific YAML-ready list structure expected by the MkDocs 'nav'
|
||||||
This module provides the ``MkDocsNavEmitter`` class, which converts a
|
configuration.
|
||||||
``ResolvedNav`` instance into the navigation structure required by the
|
|
||||||
MkDocs ``nav`` configuration.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- The emitted structure is a list of dictionaries, one per top-level nav
|
|
||||||
entry, matching the MkDocs ``nav`` YAML format.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import List, Dict, Any
|
||||||
|
|
||||||
from docforge.nav.resolver import ResolvedNav
|
from docforge.nav.resolver import ResolvedNav
|
||||||
|
|
||||||
|
|
||||||
class MkDocsNavEmitter:
|
class MkDocsNavEmitter:
|
||||||
"""
|
"""
|
||||||
Emit MkDocs navigation structures from resolved navigation data.
|
Emitter responsible for transforming a ResolvedNav into an MkDocs-compatible
|
||||||
|
navigation structure.
|
||||||
The emitter transforms a ``ResolvedNav`` object into the YAML-compatible
|
|
||||||
list structure expected by the MkDocs ``nav`` configuration field.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def emit(self, nav: ResolvedNav) -> list[dict[str, Any]]:
|
def emit(self, nav: ResolvedNav) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Generate a navigation structure for ``mkdocs.yml``.
|
Generate a list of navigation entries for mkdocs.yml.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
nav (ResolvedNav):
|
nav: The resolved navigation data.
|
||||||
Resolved navigation data describing documentation groups
|
|
||||||
and their associated Markdown files.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[dict[str, Any]]:
|
A list of dictionary mappings representing the MkDocs navigation.
|
||||||
A list of dictionaries representing the MkDocs navigation layout.
|
|
||||||
Each dictionary maps a navigation label to a page or a list of
|
|
||||||
pages.
|
|
||||||
"""
|
"""
|
||||||
result: list[dict[str, Any]] = []
|
result: List[Dict[str, Any]] = []
|
||||||
|
|
||||||
# Home entry (semantic path)
|
# Home entry (semantic path)
|
||||||
if nav.home:
|
if nav.home:
|
||||||
@@ -51,7 +34,7 @@ class MkDocsNavEmitter:
|
|||||||
|
|
||||||
# Group entries
|
# Group entries
|
||||||
for group, paths in nav.groups.items():
|
for group, paths in nav.groups.items():
|
||||||
entries: list[str] = []
|
entries: List[str] = []
|
||||||
for p in paths:
|
for p in paths:
|
||||||
# Convert filesystem path back to docs-relative path
|
# Convert filesystem path back to docs-relative path
|
||||||
rel_path = self._to_relative(p, nav._docs_root)
|
rel_path = self._to_relative(p, nav._docs_root)
|
||||||
@@ -62,21 +45,16 @@ class MkDocsNavEmitter:
|
|||||||
|
|
||||||
def _to_relative(self, path: Path, docs_root: Path | None) -> str:
|
def _to_relative(self, path: Path, docs_root: Path | None) -> str:
|
||||||
"""
|
"""
|
||||||
Convert a filesystem path into a documentation-relative path.
|
Convert a filesystem path to a path relative to the documentation root.
|
||||||
|
This handles both absolute and relative filesystem paths, ensuring the
|
||||||
This method normalizes paths so they can be used in MkDocs navigation.
|
output is compatible with MkDocs navigation requirements.
|
||||||
It handles both absolute and relative filesystem paths and ensures the
|
|
||||||
resulting path is relative to the documentation root.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (Path):
|
path: The path to convert.
|
||||||
Filesystem path to convert.
|
docs_root: The root directory for documentation.
|
||||||
docs_root (Path | None):
|
|
||||||
Root directory of the documentation sources.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str:
|
A string representing the relative POSIX-style path.
|
||||||
POSIX-style path relative to the documentation root.
|
|
||||||
"""
|
"""
|
||||||
if docs_root and path.is_absolute():
|
if docs_root and path.is_absolute():
|
||||||
try:
|
try:
|
||||||
@@ -88,7 +66,7 @@ class MkDocsNavEmitter:
|
|||||||
path_str = path.as_posix()
|
path_str = path.as_posix()
|
||||||
docs_root_str = docs_root.as_posix()
|
docs_root_str = docs_root.as_posix()
|
||||||
if path_str.startswith(docs_root_str + "/"):
|
if path_str.startswith(docs_root_str + "/"):
|
||||||
return path_str[len(docs_root_str) + 1 :]
|
return path_str[len(docs_root_str) + 1:]
|
||||||
|
|
||||||
# Fallback for other cases
|
# Fallback for other cases
|
||||||
return path.as_posix().split("/docs/", 1)[-1]
|
return path.as_posix().split("/docs/", 1)[-1]
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
|
from typing import Dict, List, Any
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from docforge.nav.resolver import ResolvedNav
|
from docforge.nav.resolver import ResolvedNav
|
||||||
|
|
||||||
|
|
||||||
class MkDocsNavEmitter:
|
class MkDocsNavEmitter:
|
||||||
"""
|
"""
|
||||||
Converts a ResolvedNav into MkDocs-compatible `nav` data.
|
Converts a ResolvedNav into MkDocs-compatible `nav` data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def emit(self, nav: ResolvedNav) -> list[dict[str, Any]]:
|
def emit(self, nav: ResolvedNav) -> List[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Emit a structure suitable for insertion into mkdocs.yml.
|
Emit a structure suitable for insertion into mkdocs.yml.
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +1,40 @@
|
|||||||
"""
|
"""
|
||||||
Navigation resolution utilities.
|
This module contains the logic for resolving a NavSpec against the physical
|
||||||
|
filesystem. It expands globs and validates that all referenced documents
|
||||||
This module resolves a ``NavSpec`` against the filesystem by expanding glob
|
actually exist on disk.
|
||||||
patterns and validating that referenced documentation files exist.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- Glob resolution is recursive and returns paths in sorted order.
|
|
||||||
- Unmatched patterns raise ``FileNotFoundError`` to fail fast on typos.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Dict, Iterable, List
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
from collections.abc import Iterable
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from docforge.nav.spec import NavSpec
|
from docforge.nav.spec import NavSpec
|
||||||
|
|
||||||
|
|
||||||
class ResolvedNav:
|
class ResolvedNav:
|
||||||
"""
|
"""
|
||||||
Resolved navigation structure.
|
Represents a navigation structure where all patterns and paths have been
|
||||||
|
resolved against the actual filesystem contents.
|
||||||
A ``ResolvedNav`` represents navigation data after glob patterns have been
|
|
||||||
expanded and paths validated against the filesystem.
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
home: Relative path to the documentation home page.
|
home: Resolved relative path to the home page.
|
||||||
groups: Mapping of navigation group titles to lists of resolved
|
groups: Mapping of group titles to lists of absolute or relative Path objects.
|
||||||
documentation file paths.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
home: str | None,
|
home: str | None,
|
||||||
groups: dict[str, list[Path]],
|
groups: Dict[str, List[Path]],
|
||||||
docs_root: Path | None = None,
|
docs_root: Path | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a ResolvedNav instance.
|
Initialize a ResolvedNav instance.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
home (str | None):
|
home: The relative path to the project home page.
|
||||||
Relative path to the home page within the documentation root.
|
groups: A mapping of group names to their resolved filesystem paths.
|
||||||
groups (dict[str, list[Path]]):
|
docs_root: The root documentation directory.
|
||||||
Mapping of group titles to resolved documentation file paths.
|
|
||||||
docs_root (Path | None):
|
|
||||||
Root directory of the documentation source files.
|
|
||||||
"""
|
"""
|
||||||
self.home = home
|
self.home = home
|
||||||
self.groups = groups
|
self.groups = groups
|
||||||
@@ -56,24 +42,18 @@ class ResolvedNav:
|
|||||||
|
|
||||||
def all_files(self) -> Iterable[Path]:
|
def all_files(self) -> Iterable[Path]:
|
||||||
"""
|
"""
|
||||||
Iterate over all files referenced by the navigation structure.
|
Get an iterable of all resolved files in the navigation structure.
|
||||||
|
|
||||||
Yields:
|
Returns:
|
||||||
Path:
|
An iterable of Path objects.
|
||||||
A documentation file referenced by the navigation, including
|
|
||||||
the home page when defined.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
RuntimeError: If the home page is defined but the documentation
|
|
||||||
root is not available for resolution.
|
|
||||||
"""
|
"""
|
||||||
if self.home:
|
if self.home:
|
||||||
if self._docs_root is None:
|
if self._docs_root is None:
|
||||||
raise RuntimeError("docs_root is required to resolve home path")
|
raise RuntimeError("docs_root is required to resolve home path")
|
||||||
yield self._docs_root / self.home
|
yield self._docs_root / self.home
|
||||||
|
|
||||||
for paths in self.groups.values():
|
for paths in self.groups.values():
|
||||||
yield from paths
|
for p in paths:
|
||||||
|
yield p
|
||||||
|
|
||||||
|
|
||||||
def resolve_nav(
|
def resolve_nav(
|
||||||
@@ -81,52 +61,46 @@ def resolve_nav(
|
|||||||
docs_root: Path,
|
docs_root: Path,
|
||||||
) -> ResolvedNav:
|
) -> ResolvedNav:
|
||||||
"""
|
"""
|
||||||
Resolve a navigation specification against the filesystem.
|
Create a ResolvedNav by processing a NavSpec against the filesystem.
|
||||||
|
This expands globs and validates the existence of referenced files.
|
||||||
The function expands glob patterns defined in a ``NavSpec`` and verifies
|
|
||||||
that referenced documentation files exist within the documentation root.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
spec (NavSpec):
|
spec: The navigation specification to resolve.
|
||||||
Navigation specification describing documentation layout.
|
docs_root: The root directory for documentation files.
|
||||||
docs_root (Path):
|
|
||||||
Root directory containing documentation Markdown files.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ResolvedNav:
|
A ResolvedNav instance.
|
||||||
A `ResolvedNav` instance containing validated navigation paths.
|
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
FileNotFoundError: If the documentation root does not exist or a
|
FileNotFoundError: If a pattern doesn't match any files or the docs_root doesn't exist.
|
||||||
navigation pattern does not match any files.
|
|
||||||
"""
|
"""
|
||||||
if not docs_root.exists():
|
if not docs_root.exists():
|
||||||
raise FileNotFoundError(docs_root)
|
raise FileNotFoundError(docs_root)
|
||||||
|
|
||||||
def resolve_pattern(pattern: str) -> list[Path]:
|
def resolve_pattern(pattern: str) -> List[Path]:
|
||||||
"""
|
"""
|
||||||
Resolve a glob pattern relative to the documentation root.
|
Resolve a single glob pattern relative to the docs_root.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
pattern (str):
|
pattern: The glob pattern to resolve.
|
||||||
Glob pattern used to match documentation files.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[Path]:
|
A sorted list of matching Path objects.
|
||||||
A sorted list of matching `Path` objects.
|
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
FileNotFoundError: If the pattern does not match any files.
|
FileNotFoundError: If the pattern doesn't match any files.
|
||||||
"""
|
"""
|
||||||
full = docs_root / pattern
|
full = docs_root / pattern
|
||||||
matches = sorted(Path(p) for p in glob.glob(str(full), recursive=True))
|
matches = sorted(
|
||||||
|
Path(p) for p in glob.glob(str(full), recursive=True)
|
||||||
|
)
|
||||||
|
|
||||||
if not matches:
|
if not matches:
|
||||||
raise FileNotFoundError(pattern)
|
raise FileNotFoundError(pattern)
|
||||||
|
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
# Resolve home page
|
# Resolve home
|
||||||
home: str | None = None
|
home: str | None = None
|
||||||
if spec.home:
|
if spec.home:
|
||||||
home_path = docs_root / spec.home
|
home_path = docs_root / spec.home
|
||||||
@@ -134,11 +108,11 @@ def resolve_nav(
|
|||||||
raise FileNotFoundError(spec.home)
|
raise FileNotFoundError(spec.home)
|
||||||
home = spec.home
|
home = spec.home
|
||||||
|
|
||||||
# Resolve navigation groups
|
# Resolve groups
|
||||||
resolved_groups: dict[str, list[Path]] = {}
|
resolved_groups: Dict[str, List[Path]] = {}
|
||||||
|
|
||||||
for group, patterns in spec.groups.items():
|
for group, patterns in spec.groups.items():
|
||||||
files: list[Path] = []
|
files: List[Path] = []
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
files.extend(resolve_pattern(pattern))
|
files.extend(resolve_pattern(pattern))
|
||||||
resolved_groups[group] = files
|
resolved_groups[group] = files
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from collections.abc import Iterable
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Dict, List, Iterable, Optional
|
||||||
|
|
||||||
from docforge.nav.spec import NavSpec
|
from docforge.nav.spec import NavSpec
|
||||||
|
|
||||||
|
|
||||||
class ResolvedNav:
|
class ResolvedNav:
|
||||||
"""
|
"""
|
||||||
Fully-resolved navigation tree.
|
Fully-resolved navigation tree.
|
||||||
@@ -12,16 +13,17 @@ class ResolvedNav:
|
|||||||
- Order is preserved
|
- Order is preserved
|
||||||
"""
|
"""
|
||||||
|
|
||||||
home: str | None
|
home: Optional[str]
|
||||||
groups: dict[str, list[Path]]
|
groups: Dict[str, List[Path]]
|
||||||
_docs_root: Path | None
|
_docs_root: Optional[Path]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
home: str | None,
|
home: str | None,
|
||||||
groups: dict[str, list[Path]],
|
groups: Dict[str, List[Path]],
|
||||||
docs_root: Path | None = ...,
|
docs_root: Path | None = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
def all_files(self) -> Iterable[Path]:
|
def all_files(self) -> Iterable[Path]:
|
||||||
"""
|
"""
|
||||||
Return all resolved documentation files in nav order.
|
Return all resolved documentation files in nav order.
|
||||||
@@ -31,6 +33,7 @@ class ResolvedNav:
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
def resolve_nav(
|
def resolve_nav(
|
||||||
spec: NavSpec,
|
spec: NavSpec,
|
||||||
docs_root: Path,
|
docs_root: Path,
|
||||||
|
|||||||
@@ -1,84 +1,53 @@
|
|||||||
"""
|
"""
|
||||||
Navigation specification model.
|
This module defines the NavSpec class, which represents the user's intent for
|
||||||
|
documentation navigation as defined in a YAML specification (usually
|
||||||
This module defines the ``NavSpec`` class, which represents the navigation
|
docforge.nav.yml).
|
||||||
structure defined by the user in the doc-forge navigation specification
|
|
||||||
(typically ``docforge.nav.yml``).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- The spec file supports an optional ``icon`` mapping for MkDocs theme
|
|
||||||
customization.
|
|
||||||
- All file references in ``groups`` are relative to the documentation root.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
class NavSpec:
|
class NavSpec:
|
||||||
"""
|
"""
|
||||||
Parsed representation of a navigation specification.
|
Parsed representation of the docforge navigation specification file.
|
||||||
|
|
||||||
A ``NavSpec`` describes the intended documentation navigation layout before
|
|
||||||
it is resolved against the filesystem.
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
home: Relative path to the documentation home page (for example
|
home: Path to the home document (e.g., 'index.md').
|
||||||
``index.md``).
|
groups: Mapping of group titles to lists of path patterns/globs.
|
||||||
groups: Mapping of navigation group titles to lists of file patterns
|
|
||||||
or glob expressions.
|
|
||||||
icon: Optional mapping of theme icon entries (for example
|
|
||||||
``{"logo": "material/code-tags"}``) injected into the MkDocs
|
|
||||||
theme as ``theme.icon``.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
home: str | None,
|
home: Optional[str],
|
||||||
groups: dict[str, list[str]],
|
groups: Dict[str, List[str]],
|
||||||
icon: dict[str, str] | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a NavSpec instance.
|
Initialize a NavSpec.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
home (str | None):
|
home: The path to the home document.
|
||||||
Relative path to the home document.
|
groups: A mapping of group names to lists of path patterns (globs).
|
||||||
groups (dict[str, list[str]]):
|
|
||||||
Mapping of group names to lists of path patterns
|
|
||||||
(glob expressions).
|
|
||||||
icon (dict[str, str] | None):
|
|
||||||
Optional mapping of theme icon entries applied to the
|
|
||||||
generated MkDocs configuration.
|
|
||||||
"""
|
"""
|
||||||
self.home = home
|
self.home = home
|
||||||
self.groups = groups
|
self.groups = groups
|
||||||
self.icon = icon
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, path: Path) -> NavSpec:
|
def load(cls, path: Path) -> "NavSpec":
|
||||||
"""
|
"""
|
||||||
Load a navigation specification from a YAML file.
|
Load a NavSpec from a YAML file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (Path):
|
path: The filesystem path to the YAML file.
|
||||||
Filesystem path to the navigation specification file.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
NavSpec:
|
A NavSpec instance.
|
||||||
A ``NavSpec`` instance representing the parsed configuration.
|
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
FileNotFoundError: If the specified file does not exist.
|
FileNotFoundError: If the path does not exist.
|
||||||
ValueError: If the file contents are not a valid navigation
|
ValueError: If the file content is not a valid NavSpec mapping.
|
||||||
specification.
|
|
||||||
"""
|
"""
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
raise FileNotFoundError(path)
|
raise FileNotFoundError(path)
|
||||||
@@ -90,7 +59,6 @@ class NavSpec:
|
|||||||
|
|
||||||
home = data.get("home")
|
home = data.get("home")
|
||||||
groups = data.get("groups", {})
|
groups = data.get("groups", {})
|
||||||
icon = data.get("icon")
|
|
||||||
|
|
||||||
if home is not None and not isinstance(home, str):
|
if home is not None and not isinstance(home, str):
|
||||||
raise ValueError("home must be a string")
|
raise ValueError("home must be a string")
|
||||||
@@ -106,65 +74,41 @@ class NavSpec:
|
|||||||
):
|
):
|
||||||
raise ValueError(f"group '{key}' must be a list of strings")
|
raise ValueError(f"group '{key}' must be a list of strings")
|
||||||
|
|
||||||
if icon is not None and (
|
return cls(home=home, groups=groups)
|
||||||
not isinstance(icon, dict)
|
|
||||||
or not all(
|
|
||||||
isinstance(k, str) and isinstance(v, str) for k, v in icon.items()
|
|
||||||
)
|
|
||||||
):
|
|
||||||
raise ValueError("icon must be a mapping of strings")
|
|
||||||
|
|
||||||
return cls(home=home, groups=groups, icon=icon)
|
def all_patterns(self) -> List[str]:
|
||||||
|
|
||||||
def all_patterns(self) -> list[str]:
|
|
||||||
"""
|
"""
|
||||||
Return all path patterns referenced by the specification.
|
Get all path patterns referenced in the specification.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]:
|
A list of all patterns (home plus all groups).
|
||||||
A list containing the home document (if defined) and all
|
|
||||||
group pattern entries.
|
|
||||||
"""
|
"""
|
||||||
patterns: list[str] = []
|
patterns: List[str] = []
|
||||||
|
|
||||||
if self.home:
|
if self.home:
|
||||||
patterns.append(self.home)
|
patterns.append(self.home)
|
||||||
|
|
||||||
for items in self.groups.values():
|
for items in self.groups.values():
|
||||||
patterns.extend(items)
|
patterns.extend(items)
|
||||||
|
|
||||||
return patterns
|
return patterns
|
||||||
|
|
||||||
|
|
||||||
def load_nav_spec(path: Path) -> NavSpec:
|
def load_nav_spec(path: Path) -> NavSpec:
|
||||||
"""
|
"""
|
||||||
Load a navigation specification file.
|
Utility function to load a NavSpec from a file.
|
||||||
|
|
||||||
This helper function reads a YAML navigation file and constructs a
|
|
||||||
corresponding ``NavSpec`` instance.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (Path):
|
path: Path to the navigation specification file.
|
||||||
Path to the navigation specification file.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
NavSpec:
|
A loaded NavSpec instance.
|
||||||
A ``NavSpec`` instance representing the parsed specification.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
FileNotFoundError: If the specification file does not exist.
|
|
||||||
ValueError: If the YAML structure is invalid.
|
|
||||||
"""
|
"""
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
raise FileNotFoundError(path)
|
raise FileNotFoundError(path)
|
||||||
|
|
||||||
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
raise ValueError("Nav spec must be a YAML mapping")
|
raise ValueError("Nav spec must be a YAML mapping")
|
||||||
|
|
||||||
return NavSpec(
|
return NavSpec(
|
||||||
home=data.get("home"),
|
home=data.get("home"),
|
||||||
groups=data.get("groups", {}),
|
groups=data.get("groups", {}),
|
||||||
icon=data.get("icon"),
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
|
|
||||||
class NavSpec:
|
class NavSpec:
|
||||||
"""
|
"""
|
||||||
@@ -8,16 +10,18 @@ class NavSpec:
|
|||||||
of filesystem structure or MkDocs specifics.
|
of filesystem structure or MkDocs specifics.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
home: str | None
|
home: Optional[str]
|
||||||
groups: dict[str, list[str]]
|
groups: Dict[str, List[str]]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
home: str | None,
|
home: Optional[str],
|
||||||
groups: dict[str, list[str]],
|
groups: Dict[str, List[str]],
|
||||||
) -> None: ...
|
) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, path: Path) -> NavSpec:
|
def load(cls, path: Path) -> "NavSpec":
|
||||||
"""
|
"""
|
||||||
Load and validate a nav specification from YAML.
|
Load and validate a nav specification from YAML.
|
||||||
|
|
||||||
@@ -27,11 +31,12 @@ class NavSpec:
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def all_patterns(self) -> list[str]:
|
def all_patterns(self) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Return all path patterns referenced by the spec
|
Return all path patterns referenced by the spec
|
||||||
(including home and group entries).
|
(including home and group entries).
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
def load_nav_spec(path: Path) -> NavSpec: ...
|
def load_nav_spec(path: Path) -> NavSpec: ...
|
||||||
|
|||||||
@@ -1,165 +0,0 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Wiki navigation derivation.
|
|
||||||
|
|
||||||
This module provides ``build_wiki_nav``, which derives an MkDocs-ready
|
|
||||||
navigation block from the file structure of a hand-written wiki directory
|
|
||||||
(typically ``docs/wiki``). wiki content is authored by hand and is never
|
|
||||||
modified by doc-forge; only the navigation layout is inferred.
|
|
||||||
|
|
||||||
# Notes
|
|
||||||
|
|
||||||
- ``index.md`` at the wiki root becomes the ``Home`` entry.
|
|
||||||
- Page labels are derived from filenames: numeric order prefixes such as
|
|
||||||
``01_`` or ``02-`` are stripped, separators are replaced with spaces, and
|
|
||||||
names are title-cased (``01_overview.md`` becomes ``Overview``).
|
|
||||||
- Subdirectories become nested navigation groups. A nested ``index.md`` is
|
|
||||||
rendered as the section root placed first inside the group.
|
|
||||||
- Only ``.md`` files are considered; hidden entries are ignored.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
|
||||||
from collections.abc import Callable
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
def build_wiki_nav(wiki_dir: Path) -> list[dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
Derive an MkDocs navigation block from a wiki directory.
|
|
||||||
|
|
||||||
Returned paths are relative to the parent of ``wiki_dir`` and carry the
|
|
||||||
wiki directory name as their leading component (for example
|
|
||||||
``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes
|
|
||||||
the result directly usable in an MkDocs ``nav`` block with
|
|
||||||
|
|
||||||
- ``index.md`` at the wiki root becomes the ``Home`` entry.
|
|
||||||
- Page labels are derived from filenames: numeric order prefixes such as
|
|
||||||
``01_`` or ``02-`` are stripped, separators are replaced with spaces, and
|
|
||||||
names are title-cased (``01_overview.md`` becomes ``Overview``).
|
|
||||||
- Subdirectories become nested navigation groups. A nested ``index.md`` is
|
|
||||||
rendered as the section root placed first inside the group.
|
|
||||||
- Only ``.md`` files are considered; hidden entries are ignored.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
wiki_dir (Path):
|
|
||||||
Path to the hand-written wiki directory, for example ``docs/wiki``.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict[str, Any]]:
|
|
||||||
Navigation entries compatible with the MkDocs ``nav`` configuration.
|
|
||||||
The list is empty if the wiki contains no Markdown files.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
FileNotFoundError:
|
|
||||||
If the wiki directory does not exist.
|
|
||||||
"""
|
|
||||||
if not wiki_dir.exists():
|
|
||||||
raise FileNotFoundError(wiki_dir)
|
|
||||||
|
|
||||||
root = wiki_dir.parent
|
|
||||||
|
|
||||||
def rel(path: Path) -> str:
|
|
||||||
try:
|
|
||||||
return path.relative_to(root).as_posix()
|
|
||||||
except ValueError:
|
|
||||||
return path.as_posix()
|
|
||||||
|
|
||||||
nav: list[dict[str, Any]] = []
|
|
||||||
|
|
||||||
if (wiki_dir / "index.md").exists():
|
|
||||||
nav.append({"Home": rel(wiki_dir / "index.md")})
|
|
||||||
|
|
||||||
nav.extend(_render_entries(wiki_dir, rel))
|
|
||||||
|
|
||||||
return nav
|
|
||||||
|
|
||||||
|
|
||||||
def _render_entries(
|
|
||||||
base_dir: Path,
|
|
||||||
rel: Callable[[Path], str],
|
|
||||||
) -> list[dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
Render navigation entries for the children of a wiki directory.
|
|
||||||
|
|
||||||
Markdown pages become labeled entries, subdirectories containing
|
|
||||||
Markdown become nested groups, and a nested ``index.md`` is emitted
|
|
||||||
first as the section root.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
base_dir (Path):
|
|
||||||
Directory whose children are rendered.
|
|
||||||
|
|
||||||
rel (Callable[[Path], str]):
|
|
||||||
Callable converting a wiki file path into a docs-relative path.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict[str, Any]]:
|
|
||||||
Navigation entries for ``base_dir`` in natural sort order.
|
|
||||||
"""
|
|
||||||
children = sorted(
|
|
||||||
(child for child in base_dir.iterdir() if not child.name.startswith(".")),
|
|
||||||
key=lambda child: _natural_key(child.name),
|
|
||||||
)
|
|
||||||
|
|
||||||
entries: list[dict[str, Any]] = []
|
|
||||||
|
|
||||||
for child in children:
|
|
||||||
if child.is_dir():
|
|
||||||
if not any(child.rglob("*.md")):
|
|
||||||
continue
|
|
||||||
|
|
||||||
group: list[dict[str, Any]] = []
|
|
||||||
nested_index = child / "index.md"
|
|
||||||
if nested_index.exists():
|
|
||||||
group.append({_prettify(child.name): rel(nested_index)})
|
|
||||||
group.extend(_render_entries(child, rel))
|
|
||||||
entries.append({_prettify(child.name): group})
|
|
||||||
elif child.suffix == ".md":
|
|
||||||
if child.name == "index.md":
|
|
||||||
continue
|
|
||||||
entries.append({_prettify(child.stem): rel(child)})
|
|
||||||
|
|
||||||
return entries
|
|
||||||
|
|
||||||
|
|
||||||
def _prettify(name: str) -> str:
|
|
||||||
"""
|
|
||||||
Convert a filename or directory name into a navigation label.
|
|
||||||
|
|
||||||
Numeric order prefixes (``01_``, ``02-``, ``03.``) are stripped,
|
|
||||||
separators are replaced with spaces, and the result is title-cased.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
name (str):
|
|
||||||
Filename stem or directory name to prettify.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str:
|
|
||||||
Title-cased navigation label.
|
|
||||||
"""
|
|
||||||
name = re.sub(r"^\d+[_\-. ]?", "", name)
|
|
||||||
name = re.sub(r"[_-]+", " ", name).strip()
|
|
||||||
return name.title()
|
|
||||||
|
|
||||||
|
|
||||||
def _natural_key(name: str) -> list[object]:
|
|
||||||
"""
|
|
||||||
Build a natural sort key from a filename.
|
|
||||||
|
|
||||||
The key splits ``name`` into alternating non-digit and digit parts so
|
|
||||||
that numeric prefixes sort numerically (``02`` before ``10``).
|
|
||||||
|
|
||||||
Args:
|
|
||||||
name (str):
|
|
||||||
Filename or directory name to key.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[object]:
|
|
||||||
Mixed list of lowercased strings and integers used for sorting.
|
|
||||||
"""
|
|
||||||
return [
|
|
||||||
int(part) if part.isdigit() else part.lower()
|
|
||||||
for part in re.split(r"(\d+)", name)
|
|
||||||
]
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
from collections.abc import Callable
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
def build_wiki_nav(wiki_dir: Path) -> list[dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
Derive an MkDocs navigation block from a wiki directory.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
wiki_dir (Path):
|
|
||||||
Path to the hand-written wiki directory.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict[str, Any]]:
|
|
||||||
Wiki navigation entries compatible with the MkDocs `nav`
|
|
||||||
configuration.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
FileNotFoundError:
|
|
||||||
If the wiki directory does not exist.
|
|
||||||
"""
|
|
||||||
...
|
|
||||||
|
|
||||||
def _render_entries(
|
|
||||||
base_dir: Path,
|
|
||||||
rel: Callable[[Path], str],
|
|
||||||
) -> list[dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
Render navigation entries for the children of a wiki directory.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
base_dir (Path):
|
|
||||||
Directory whose children are rendered.
|
|
||||||
rel (Callable[[Path], str]):
|
|
||||||
Callable converting a wiki file path into a docs-relative path.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict[str, Any]]:
|
|
||||||
Navigation entries for `base_dir` in natural sort order.
|
|
||||||
"""
|
|
||||||
...
|
|
||||||
@@ -1,34 +1,20 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
# Renderers Layer
|
||||||
|
|
||||||
Renderers layer for doc-forge.
|
The `docforge.renderers` package handles the transformation of the internal
|
||||||
|
documentation models into physical files formatted for specific documentation
|
||||||
|
engines.
|
||||||
|
|
||||||
The `docforge.renderers` package transforms the internal documentation
|
## Current Implementations
|
||||||
models into files formatted for specific documentation systems.
|
|
||||||
|
|
||||||
---
|
- **MkDocsRenderer**: Generates Markdown files utilizing the `mkdocstrings`
|
||||||
|
syntax. It automatically handles package/module hierarchy and generates
|
||||||
|
`index.md` files for packages.
|
||||||
|
|
||||||
# Overview
|
## Extending
|
||||||
|
|
||||||
Renderers consume the doc-forge project model and generate output suitable
|
To add a new renderer, implement the `DocRenderer` protocol defined in
|
||||||
for documentation tools or machine interfaces.
|
`docforge.renderers.base`.
|
||||||
|
|
||||||
Current implementations:
|
|
||||||
|
|
||||||
- **MkDocsRenderer** – Produces Markdown files compatible with MkDocs and
|
|
||||||
the `mkdocstrings` plugin. It automatically handles package hierarchy
|
|
||||||
and generates `index.md` files for packages.
|
|
||||||
- **MCPRenderer** – Emits structured JSON resources designed for consumption
|
|
||||||
by Model Context Protocol (MCP) clients.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# Extending
|
|
||||||
|
|
||||||
New renderers can be added by implementing the `DocRenderer` protocol
|
|
||||||
defined in `docforge.renderers.base`.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .mkdocs_renderer import MkDocsRenderer
|
from .mkdocs_renderer import MkDocsRenderer
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from .mcp_renderer import MCPRenderer
|
|
||||||
from .mkdocs_renderer import MkDocsRenderer
|
from .mkdocs_renderer import MkDocsRenderer
|
||||||
|
from .mcp_renderer import MCPRenderer
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"MkDocsRenderer",
|
"MkDocsRenderer",
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
This module defines the base interfaces and configuration containers for
|
||||||
|
doc-forge renderers. All renderer implementations should adhere to the
|
||||||
Renderer base interfaces and configuration models.
|
DocRenderer protocol.
|
||||||
|
|
||||||
This module defines the base protocol and configuration container used by
|
|
||||||
doc-forge renderers. Concrete renderer implementations should implement the
|
|
||||||
`DocRenderer` protocol.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -18,28 +14,12 @@ class RendererConfig:
|
|||||||
"""
|
"""
|
||||||
Configuration container for documentation renderers.
|
Configuration container for documentation renderers.
|
||||||
|
|
||||||
A `RendererConfig` instance groups together the project model and the
|
Args:
|
||||||
output directory used during rendering.
|
out_dir: The directory where documentation files should be written.
|
||||||
|
project: The introspected project models to be rendered.
|
||||||
Attributes:
|
|
||||||
out_dir (Path):
|
|
||||||
Directory where generated documentation files will be written.
|
|
||||||
|
|
||||||
project (Project):
|
|
||||||
Documentation project model to be rendered.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, out_dir: Path, project: Project) -> None:
|
def __init__(self, out_dir: Path, project: Project) -> None:
|
||||||
"""
|
|
||||||
Initialize a RendererConfig instance.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
out_dir (Path):
|
|
||||||
Target directory where documentation files should be written.
|
|
||||||
|
|
||||||
project (Project):
|
|
||||||
Introspected project model to render.
|
|
||||||
"""
|
|
||||||
self.out_dir = out_dir
|
self.out_dir = out_dir
|
||||||
self.project = project
|
self.project = project
|
||||||
|
|
||||||
@@ -47,9 +27,6 @@ class RendererConfig:
|
|||||||
class DocRenderer(Protocol):
|
class DocRenderer(Protocol):
|
||||||
"""
|
"""
|
||||||
Protocol defining the interface for documentation renderers.
|
Protocol defining the interface for documentation renderers.
|
||||||
|
|
||||||
Implementations of this protocol are responsible for transforming a
|
|
||||||
`Project` model into renderer-specific documentation sources.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
@@ -60,13 +37,10 @@ class DocRenderer(Protocol):
|
|||||||
out_dir: Path,
|
out_dir: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Generate renderer-specific documentation sources.
|
Generate renderer-specific source files for the given project.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
project (Project):
|
project: The project models containing modules and objects.
|
||||||
Project model containing modules and documentation objects.
|
out_dir: Target directory for the generated files.
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Directory where generated documentation sources should be written.
|
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from typing import Protocol
|
|||||||
|
|
||||||
from docforge.models import Project
|
from docforge.models import Project
|
||||||
|
|
||||||
|
|
||||||
class RendererConfig:
|
class RendererConfig:
|
||||||
"""Renderer configuration container."""
|
"""Renderer configuration container."""
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ class RendererConfig:
|
|||||||
|
|
||||||
def __init__(self, out_dir: Path, project: Project) -> None: ...
|
def __init__(self, out_dir: Path, project: Project) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
class DocRenderer(Protocol):
|
class DocRenderer(Protocol):
|
||||||
"""Renderer interface."""
|
"""Renderer interface."""
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +1,33 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
MCP renderer implementation.
|
|
||||||
|
|
||||||
This module defines the `MCPRenderer` class, which generates documentation
|
|
||||||
resources compatible with the Model Context Protocol (MCP).
|
|
||||||
"""
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Dict, List
|
||||||
|
|
||||||
from docforge.models import DocObject, Module, Project
|
from docforge.models import Project, Module, DocObject
|
||||||
|
|
||||||
|
|
||||||
class MCPRenderer:
|
class MCPRenderer:
|
||||||
"""
|
"""
|
||||||
Renderer that generates MCP-compatible documentation resources.
|
Renderer that emits MCP-native JSON resources from docforge models.
|
||||||
|
|
||||||
This renderer converts doc-forge project models into structured JSON
|
|
||||||
resources suitable for consumption by systems implementing the Model
|
|
||||||
Context Protocol (MCP).
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = "mcp"
|
name = "mcp"
|
||||||
|
|
||||||
def generate_sources(self, project: Project, out_dir: Path) -> None:
|
def generate_sources(self, project: Project, out_dir: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Generate MCP documentation resources for a project.
|
Generate MCP-compatible JSON resources and navigation for the project.
|
||||||
|
|
||||||
The renderer serializes each module into a JSON resource and produces
|
|
||||||
supporting metadata files such as `nav.json` and `index.json`.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
project (Project):
|
|
||||||
Documentation project model to render.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Directory where MCP resources will be written.
|
|
||||||
"""
|
"""
|
||||||
modules_dir = out_dir / "modules"
|
modules_dir = out_dir / "modules"
|
||||||
modules_dir.mkdir(parents=True, exist_ok=True)
|
modules_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
nav: list[dict[str, str]] = []
|
nav: List[Dict[str, str]] = []
|
||||||
|
|
||||||
for module in project.get_all_modules():
|
for module in project.get_all_modules():
|
||||||
self._write_module(module, modules_dir)
|
self._write_module(module, modules_dir)
|
||||||
|
|
||||||
nav.append(
|
nav.append({
|
||||||
{
|
"module": module.path,
|
||||||
"module": module.path,
|
"resource": f"doc://modules/{module.path}",
|
||||||
"resource": f"docs://modules/{module.path}",
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Write nav.json
|
# Write nav.json
|
||||||
(out_dir / "nav.json").write_text(
|
(out_dir / "nav.json").write_text(
|
||||||
@@ -74,14 +50,7 @@ class MCPRenderer:
|
|||||||
|
|
||||||
def _write_module(self, module: Module, modules_dir: Path) -> None:
|
def _write_module(self, module: Module, modules_dir: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Serialize a module into an MCP resource file.
|
Serialize a module into an MCP JSON resource.
|
||||||
|
|
||||||
Args:
|
|
||||||
module (Module):
|
|
||||||
Module instance to serialize.
|
|
||||||
|
|
||||||
modules_dir (Path):
|
|
||||||
Directory where module JSON files are stored.
|
|
||||||
"""
|
"""
|
||||||
payload = {
|
payload = {
|
||||||
"module": module.path,
|
"module": module.path,
|
||||||
@@ -92,19 +61,11 @@ class MCPRenderer:
|
|||||||
out.parent.mkdir(parents=True, exist_ok=True)
|
out.parent.mkdir(parents=True, exist_ok=True)
|
||||||
out.write_text(self._json(payload), encoding="utf-8")
|
out.write_text(self._json(payload), encoding="utf-8")
|
||||||
|
|
||||||
def _render_module(self, module: Module) -> dict:
|
def _render_module(self, module: Module) -> Dict:
|
||||||
"""
|
"""
|
||||||
Convert a Module model into MCP-compatible structured data.
|
Render a Module into MCP-friendly structured data.
|
||||||
|
|
||||||
Args:
|
|
||||||
module (Module):
|
|
||||||
Module instance to convert.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict:
|
|
||||||
Dictionary representing the module and its documented objects.
|
|
||||||
"""
|
"""
|
||||||
data: dict = {
|
data: Dict = {
|
||||||
"path": module.path,
|
"path": module.path,
|
||||||
"docstring": module.docstring,
|
"docstring": module.docstring,
|
||||||
"objects": {},
|
"objects": {},
|
||||||
@@ -115,19 +76,11 @@ class MCPRenderer:
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _render_object(self, obj: DocObject) -> dict:
|
def _render_object(self, obj: DocObject) -> Dict:
|
||||||
"""
|
"""
|
||||||
Recursively convert a DocObject into structured MCP data.
|
Recursively render a DocObject into structured MCP data.
|
||||||
|
|
||||||
Args:
|
|
||||||
obj (DocObject):
|
|
||||||
Documentation object to convert.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict:
|
|
||||||
Dictionary describing the object and any nested members.
|
|
||||||
"""
|
"""
|
||||||
data: dict = {
|
data: Dict = {
|
||||||
"name": obj.name,
|
"name": obj.name,
|
||||||
"kind": obj.kind,
|
"kind": obj.kind,
|
||||||
"path": obj.path,
|
"path": obj.path,
|
||||||
@@ -138,22 +91,12 @@ class MCPRenderer:
|
|||||||
members = list(obj.get_all_members())
|
members = list(obj.get_all_members())
|
||||||
if members:
|
if members:
|
||||||
data["members"] = {
|
data["members"] = {
|
||||||
member.name: self._render_object(member) for member in members
|
member.name: self._render_object(member)
|
||||||
|
for member in members
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _json(data: dict) -> str:
|
def _json(data: Dict) -> str:
|
||||||
"""
|
|
||||||
Serialize data to formatted JSON.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
data (dict):
|
|
||||||
Dictionary to serialize.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str:
|
|
||||||
JSON string formatted with indentation and UTF-8 compatibility.
|
|
||||||
"""
|
|
||||||
return json.dumps(data, indent=2, ensure_ascii=False)
|
return json.dumps(data, indent=2, ensure_ascii=False)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Dict, List
|
||||||
|
|
||||||
|
from docforge.models import Project, Module, DocObject
|
||||||
|
|
||||||
from docforge.models import DocObject, Module, Project
|
|
||||||
|
|
||||||
class MCPRenderer:
|
class MCPRenderer:
|
||||||
"""Renderer that emits MCP-native JSON resources from docforge models."""
|
"""Renderer that emits MCP-native JSON resources from docforge models."""
|
||||||
@@ -14,12 +15,12 @@ class MCPRenderer:
|
|||||||
def _write_module(self, module: Module, modules_dir: Path) -> None:
|
def _write_module(self, module: Module, modules_dir: Path) -> None:
|
||||||
"""Serialize a module into an MCP JSON resource."""
|
"""Serialize a module into an MCP JSON resource."""
|
||||||
|
|
||||||
def _render_module(self, module: Module) -> dict[str, Any]:
|
def _render_module(self, module: Module) -> Dict:
|
||||||
"""Render a Module into MCP-friendly structured data."""
|
"""Render a Module into MCP-friendly structured data."""
|
||||||
|
|
||||||
def _render_object(self, obj: DocObject) -> dict[str, Any]:
|
def _render_object(self, obj: DocObject) -> Dict:
|
||||||
"""Recursively render a DocObject into structured MCP data."""
|
"""Recursively render a DocObject into structured MCP data."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _json(data: dict[str, Any]) -> str:
|
def _json(data: Dict) -> str:
|
||||||
"""Serialize structured data to formatted JSON."""
|
"""Serialize structured data to formatted JSON."""
|
||||||
|
|||||||
@@ -1,306 +1,91 @@
|
|||||||
"""
|
"""
|
||||||
# Summary
|
This module implements the MkDocsRenderer, which generates Markdown source files
|
||||||
|
compatible with the MkDocs 'material' theme and 'mkdocstrings' extension.
|
||||||
MkDocs renderer implementation.
|
|
||||||
|
|
||||||
This module defines the `MkDocsRenderer` class, which generates Markdown
|
|
||||||
documentation sources compatible with MkDocs Material and the mkdocstrings
|
|
||||||
plugin.
|
|
||||||
|
|
||||||
The renderer ensures a consistent documentation structure by:
|
|
||||||
|
|
||||||
- Creating a root `index.md` if one does not exist
|
|
||||||
- Generating package index pages automatically
|
|
||||||
- Linking child modules within parent package pages
|
|
||||||
- Optionally generating `README.md` from the root package docstring
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from docforge.models import Module, Project
|
from docforge.models import Project
|
||||||
|
|
||||||
|
|
||||||
class MkDocsRenderer:
|
class MkDocsRenderer:
|
||||||
"""
|
"""
|
||||||
Renderer that produces Markdown documentation for MkDocs.
|
Renderer that generates Markdown source files formatted for the MkDocs
|
||||||
|
'mkdocstrings' plugin.
|
||||||
Generated pages use mkdocstrings directives to reference Python modules,
|
|
||||||
allowing MkDocs to render API documentation dynamically.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = "mkdocs"
|
name = "mkdocs"
|
||||||
|
|
||||||
# -------------------------
|
def generate_sources(self, project: Project, out_dir: Path) -> None:
|
||||||
# Public API
|
|
||||||
# -------------------------
|
|
||||||
|
|
||||||
def generate_sources(
|
|
||||||
self,
|
|
||||||
project: Project,
|
|
||||||
out_dir: Path,
|
|
||||||
module_is_source: bool | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""
|
"""
|
||||||
Generate Markdown documentation files for a project.
|
Produce a set of Markdown files in the output directory based on the
|
||||||
|
provided Project models.
|
||||||
This method renders a documentation structure from the provided
|
|
||||||
project model and writes the resulting Markdown files to the
|
|
||||||
specified output directory.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
project (Project):
|
project: The project models to render.
|
||||||
Project model containing modules to document.
|
out_dir: Target directory for documentation files.
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Directory where generated Markdown files will be written.
|
|
||||||
|
|
||||||
module_is_source (bool | None):
|
|
||||||
If True, treat the specified module as the documentation root
|
|
||||||
rather than nesting it inside a folder.
|
|
||||||
"""
|
"""
|
||||||
out_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
self._ensure_root_index(project, out_dir)
|
|
||||||
|
|
||||||
modules = list(project.get_all_modules())
|
modules = list(project.get_all_modules())
|
||||||
paths = {m.path for m in modules}
|
paths = {m.path for m in modules}
|
||||||
|
|
||||||
# Detect packages (modules with children)
|
# Package detection (level-agnostic)
|
||||||
packages = {
|
packages = {
|
||||||
p for p in paths if any(other.startswith(p + ".") for other in paths)
|
p for p in paths
|
||||||
|
if any(other.startswith(p + ".") for other in paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
for module in modules:
|
for module in modules:
|
||||||
self._write_module(
|
self._write_module(module, packages, out_dir)
|
||||||
module,
|
|
||||||
packages,
|
|
||||||
out_dir,
|
|
||||||
module_is_source,
|
|
||||||
)
|
|
||||||
|
|
||||||
def generate_readme(
|
|
||||||
self,
|
|
||||||
project: Project,
|
|
||||||
docs_dir: Path,
|
|
||||||
module_is_source: bool | None = None,
|
|
||||||
readme_dir: Path | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Generate a `README.md` file from the root module docstring.
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- If `module_is_source` is True, `README.md` is written to the
|
|
||||||
project root directory.
|
|
||||||
- If False, README generation is currently not implemented.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
project (Project):
|
|
||||||
Project model containing documentation metadata.
|
|
||||||
|
|
||||||
docs_dir (Path):
|
|
||||||
Directory containing generated documentation sources.
|
|
||||||
|
|
||||||
module_is_source (bool | None):
|
|
||||||
Whether the module is treated as the project source root.
|
|
||||||
|
|
||||||
readme_dir (Path | None):
|
|
||||||
Directory where the generated README.md should be written.
|
|
||||||
Defaults to the parent of `docs_dir`.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not module_is_source:
|
|
||||||
# Future: support README generation per module
|
|
||||||
return
|
|
||||||
|
|
||||||
readme_root = readme_dir if readme_dir is not None else docs_dir.parent
|
|
||||||
readme_path = readme_root / "README.md"
|
|
||||||
|
|
||||||
root_module = None
|
|
||||||
for module in project.get_all_modules():
|
|
||||||
if module.path == project.name:
|
|
||||||
root_module = module
|
|
||||||
break
|
|
||||||
|
|
||||||
if root_module is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
doc = ""
|
|
||||||
|
|
||||||
if root_module.docstring:
|
|
||||||
doc = getattr(
|
|
||||||
root_module.docstring,
|
|
||||||
"value",
|
|
||||||
str(root_module.docstring),
|
|
||||||
)
|
|
||||||
|
|
||||||
content = f"# {project.name}\n\n" f"{doc.strip()}\n"
|
|
||||||
|
|
||||||
if (
|
|
||||||
not readme_path.exists()
|
|
||||||
or readme_path.read_text(encoding="utf-8") != content
|
|
||||||
):
|
|
||||||
readme_path.write_text(
|
|
||||||
content,
|
|
||||||
encoding="utf-8",
|
|
||||||
)
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Internal helpers
|
# Internal helpers
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
def _write_module(self, module, packages: set[str], out_dir: Path) -> None:
|
||||||
def _find_root_module(self, project: Project) -> Module | None:
|
|
||||||
"""
|
"""
|
||||||
Locate the root module corresponding to the project name.
|
Write a single module's documentation file. Packages are written as
|
||||||
|
'index.md' inside their respective directories.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
project (Project):
|
module: The module to write.
|
||||||
Project model to inspect.
|
packages: A set of module paths that are identified as packages.
|
||||||
|
out_dir: The base output directory.
|
||||||
Returns:
|
|
||||||
Module | None:
|
|
||||||
The root `Module` if found, otherwise `None`.
|
|
||||||
"""
|
"""
|
||||||
for module in project.get_all_modules():
|
|
||||||
if module.path == project.name:
|
|
||||||
return module
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _write_module(
|
|
||||||
self,
|
|
||||||
module: Module,
|
|
||||||
packages: set[str],
|
|
||||||
out_dir: Path,
|
|
||||||
module_is_source: bool | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Write documentation for a single module.
|
|
||||||
|
|
||||||
Package modules are rendered as `index.md` files inside their
|
|
||||||
corresponding directories, while leaf modules are written as
|
|
||||||
standalone Markdown pages.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
module (Module):
|
|
||||||
Module to render.
|
|
||||||
|
|
||||||
packages (set[str]):
|
|
||||||
Set of module paths identified as packages.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Base directory for generated documentation files.
|
|
||||||
|
|
||||||
module_is_source (bool | None):
|
|
||||||
Whether the module acts as the documentation root directory.
|
|
||||||
"""
|
|
||||||
|
|
||||||
parts = module.path.split(".")
|
parts = module.path.split(".")
|
||||||
|
|
||||||
if module_is_source:
|
|
||||||
module_name, parts = parts[0], parts[1:]
|
|
||||||
else:
|
|
||||||
module_name, parts = parts[0], parts
|
|
||||||
|
|
||||||
if module.path in packages:
|
if module.path in packages:
|
||||||
|
# package → index.md
|
||||||
dir_path = out_dir.joinpath(*parts)
|
dir_path = out_dir.joinpath(*parts)
|
||||||
dir_path.mkdir(parents=True, exist_ok=True)
|
dir_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
md_path = dir_path / "index.md"
|
md_path = dir_path / "index.md"
|
||||||
link_target = f"{parts[-1]}/" if parts else None
|
title = parts[-1].replace("_", " ").title()
|
||||||
else:
|
else:
|
||||||
|
# leaf module → <name>.md
|
||||||
dir_path = out_dir.joinpath(*parts[:-1])
|
dir_path = out_dir.joinpath(*parts[:-1])
|
||||||
dir_path.mkdir(parents=True, exist_ok=True)
|
dir_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
md_path = dir_path / f"{parts[-1]}.md"
|
md_path = dir_path / f"{parts[-1]}.md"
|
||||||
link_target = f"{parts[-1]}.md" if parts else None
|
title = parts[-1].replace("_", " ").title()
|
||||||
|
|
||||||
title = parts[-1].replace("_", " ").title() if parts else module_name
|
|
||||||
content = self._render_markdown(title, module.path)
|
content = self._render_markdown(title, module.path)
|
||||||
|
|
||||||
if not md_path.exists() or md_path.read_text(encoding="utf-8") != content:
|
if md_path.exists() and md_path.read_text(encoding="utf-8") == content:
|
||||||
md_path.write_text(content, encoding="utf-8")
|
return
|
||||||
|
|
||||||
if not module_is_source:
|
md_path.write_text(content, encoding="utf-8")
|
||||||
self._ensure_parent_index(parts, out_dir, link_target, title)
|
|
||||||
|
|
||||||
def _render_markdown(self, title: str, module_path: str) -> str:
|
def _render_markdown(self, title: str, module_path: str) -> str:
|
||||||
"""
|
"""
|
||||||
Generate Markdown content for a module documentation page.
|
Generate the Markdown content for a module file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
title (str):
|
title: The display title for the page.
|
||||||
Page title displayed in the documentation.
|
module_path: The dotted path of the module to document.
|
||||||
|
|
||||||
module_path (str):
|
|
||||||
Dotted import path of the module.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str:
|
A string containing the Markdown source.
|
||||||
Markdown source containing a mkdocstrings directive.
|
|
||||||
"""
|
"""
|
||||||
return f"# {title}\n\n" f"::: {module_path}\n"
|
return (
|
||||||
|
f"# {title}\n\n"
|
||||||
def _ensure_root_index(
|
f"::: {module_path}\n"
|
||||||
self,
|
)
|
||||||
project: Project,
|
|
||||||
out_dir: Path,
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Ensure that the root `index.md` page exists.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
project (Project):
|
|
||||||
Project model used for the page title.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Documentation output directory.
|
|
||||||
"""
|
|
||||||
root_index = out_dir / "index.md"
|
|
||||||
|
|
||||||
if not root_index.exists():
|
|
||||||
root_index.write_text(
|
|
||||||
f"# {project.name}\n\n" "## Modules\n\n",
|
|
||||||
encoding="utf-8",
|
|
||||||
)
|
|
||||||
|
|
||||||
def _ensure_parent_index(
|
|
||||||
self,
|
|
||||||
parts: list[str],
|
|
||||||
out_dir: Path,
|
|
||||||
link_target: str,
|
|
||||||
title: str,
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Ensure that parent package index files exist and contain links to
|
|
||||||
child modules.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
parts (list[str]):
|
|
||||||
Module path components.
|
|
||||||
|
|
||||||
out_dir (Path):
|
|
||||||
Documentation output directory.
|
|
||||||
|
|
||||||
link_target (str):
|
|
||||||
Link target used in the parent index.
|
|
||||||
|
|
||||||
title (str):
|
|
||||||
Display title for the link.
|
|
||||||
"""
|
|
||||||
if len(parts) == 1:
|
|
||||||
parent_index = out_dir / "index.md"
|
|
||||||
else:
|
|
||||||
parent_dir = out_dir.joinpath(*parts[:-1])
|
|
||||||
parent_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
parent_index = parent_dir / "index.md"
|
|
||||||
|
|
||||||
if not parent_index.exists():
|
|
||||||
parent_title = parts[-2].replace("_", " ").title()
|
|
||||||
parent_index.write_text(
|
|
||||||
f"# {parent_title}\n\n",
|
|
||||||
encoding="utf-8",
|
|
||||||
)
|
|
||||||
|
|
||||||
content = parent_index.read_text(encoding="utf-8")
|
|
||||||
|
|
||||||
link = f"- [{title}]({link_target})\n"
|
|
||||||
if link not in content:
|
|
||||||
parent_index.write_text(content + link, encoding="utf-8")
|
|
||||||
|
|||||||
@@ -1,31 +1,17 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Set
|
||||||
|
|
||||||
|
from docforge.models import Project, Module
|
||||||
|
|
||||||
from docforge.models import Module, Project
|
|
||||||
|
|
||||||
class MkDocsRenderer:
|
class MkDocsRenderer:
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
def generate_sources(
|
def generate_sources(self, project: Project, out_dir: Path) -> None: ...
|
||||||
self,
|
|
||||||
project: Project,
|
|
||||||
out_dir: Path,
|
|
||||||
module_is_source: bool | None = None,
|
|
||||||
) -> None: ...
|
|
||||||
def generate_readme(
|
|
||||||
self,
|
|
||||||
project: Project,
|
|
||||||
docs_dir: Path,
|
|
||||||
module_is_source: bool | None = None,
|
|
||||||
) -> None: ...
|
|
||||||
def _write_module(
|
def _write_module(
|
||||||
self,
|
self,
|
||||||
module: Module,
|
module: Module,
|
||||||
packages: set[str],
|
packages: Set[str],
|
||||||
out_dir: Path,
|
out_dir: Path,
|
||||||
module_is_source: bool | None = None,
|
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def _render_markdown(self, title: str, module_path: str) -> str: ...
|
def _render_markdown(self, title: str, module_path: str) -> str: ...
|
||||||
def _ensure_root_index(self, project: Project, out_dir: Path) -> None: ...
|
|
||||||
def _ensure_parent_index(
|
|
||||||
self, parts: list[str], out_dir: Path, link_target: str, title: str
|
|
||||||
) -> None: ...
|
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
Server layer for doc-forge.
|
|
||||||
|
|
||||||
This module exposes server implementations used to provide live access
|
|
||||||
to generated documentation resources. Currently, it includes the MCP
|
|
||||||
documentation server.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
|
||||||
|
|
||||||
from .mcp_server import MCPServer
|
from .mcp_server import MCPServer
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"MCPServer",
|
"MCPServer",
|
||||||
]
|
]
|
||||||
@@ -1,59 +1,25 @@
|
|||||||
"""
|
|
||||||
# Summary
|
|
||||||
|
|
||||||
MCP server implementation.
|
|
||||||
|
|
||||||
This module defines the `MCPServer` class, which serves pre-generated
|
|
||||||
documentation bundles through the Model Context Protocol (MCP).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- The served bundle is generated offline by `MCPRenderer`.
|
|
||||||
- Missing resources are reported as structured error dictionaries rather
|
|
||||||
than raising exceptions.
|
|
||||||
- The server exposes read-only resources and a single health-check tool.
|
|
||||||
|
|
||||||
---
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
|
from mcp.server.fastmcp import FastMCP
|
||||||
|
|
||||||
|
|
||||||
class MCPServer:
|
class MCPServer:
|
||||||
"""
|
"""
|
||||||
MCP server for serving a pre-generated documentation bundle.
|
MCP server for serving a pre-built MCP documentation bundle.
|
||||||
|
|
||||||
The server exposes documentation resources and diagnostic tools through
|
|
||||||
MCP endpoints backed by JSON files generated by the MCP renderer.
|
|
||||||
|
|
||||||
Attributes:
|
|
||||||
mcp_root (Path):
|
|
||||||
Directory containing the generated MCP documentation bundle.
|
|
||||||
|
|
||||||
app (FastMCP):
|
|
||||||
Underlying FastMCP application instance that registers resources
|
|
||||||
and tools.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, mcp_root: Path, name: str) -> None:
|
def __init__(self, mcp_root: Path, name: str) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize the MCP server.
|
Initialize the MCPServer.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
mcp_root (Path):
|
mcp_root: Path to the directory containing pre-built MCP JSON resources.
|
||||||
Directory containing the generated MCP documentation bundle
|
name: Name of the MCP server.
|
||||||
(for example `index.json`, `nav.json`, and `modules/`).
|
|
||||||
|
|
||||||
name (str):
|
|
||||||
Identifier used for the MCP server instance.
|
|
||||||
"""
|
"""
|
||||||
from mcp.server.fastmcp import FastMCP
|
|
||||||
|
|
||||||
self.mcp_root = mcp_root
|
self.mcp_root = mcp_root
|
||||||
self.app = FastMCP(name)
|
self.app = FastMCP(name)
|
||||||
|
|
||||||
@@ -66,26 +32,19 @@ class MCPServer:
|
|||||||
|
|
||||||
def _read_json(self, path: Path) -> Any:
|
def _read_json(self, path: Path) -> Any:
|
||||||
"""
|
"""
|
||||||
Load and parse a JSON file.
|
Read and parse a JSON file, returning diagnostic errors if missing.
|
||||||
|
|
||||||
If the file does not exist, a structured error response is returned
|
|
||||||
instead of raising an exception.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
path (Path):
|
path: Path to the JSON file.
|
||||||
Path to the JSON file to read.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Any:
|
The parsed JSON data or an error dictionary.
|
||||||
Parsed JSON data if the file exists, otherwise an error dictionary
|
|
||||||
describing the missing resource.
|
|
||||||
"""
|
"""
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
return {
|
return {
|
||||||
"error": "not_found",
|
"error": "not_found",
|
||||||
"path": str(path),
|
"path": str(path),
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.loads(path.read_text(encoding="utf-8"))
|
return json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@@ -94,16 +53,8 @@ class MCPServer:
|
|||||||
|
|
||||||
def _register_resources(self) -> None:
|
def _register_resources(self) -> None:
|
||||||
"""
|
"""
|
||||||
Register MCP resource endpoints.
|
Register MCP resources for index, nav, and individual modules.
|
||||||
|
|
||||||
The server exposes documentation resources through the following
|
|
||||||
endpoints:
|
|
||||||
|
|
||||||
- `docs://index` – Project metadata
|
|
||||||
- `docs://nav` – Navigation structure
|
|
||||||
- `docs://modules/{module}` – Individual module documentation
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@self.app.resource("docs://index")
|
@self.app.resource("docs://index")
|
||||||
def index():
|
def index():
|
||||||
return self._read_json(self.mcp_root / "index.json")
|
return self._read_json(self.mcp_root / "index.json")
|
||||||
@@ -114,39 +65,31 @@ class MCPServer:
|
|||||||
|
|
||||||
@self.app.resource("docs://modules/{module}")
|
@self.app.resource("docs://modules/{module}")
|
||||||
def module(module: str):
|
def module(module: str):
|
||||||
return self._read_json(self.mcp_root / "modules" / f"{module}.json")
|
return self._read_json(
|
||||||
|
self.mcp_root / "modules" / f"{module}.json"
|
||||||
|
)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# MCP tools
|
# MCP tools (optional / diagnostic)
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def _register_tools(self) -> None:
|
def _register_tools(self) -> None:
|
||||||
"""
|
"""
|
||||||
Register optional MCP diagnostic tools.
|
Register high-level MCP tools for diagnostics.
|
||||||
|
|
||||||
These tools provide lightweight endpoints useful for verifying that
|
|
||||||
the MCP server is operational.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@self.app.tool()
|
@self.app.tool()
|
||||||
def ping() -> str:
|
def ping() -> str:
|
||||||
"""Return a simple health check response."""
|
|
||||||
return "pong"
|
return "pong"
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Server lifecycle
|
# Server lifecycle
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def run(
|
def run(self, transport: Literal["stdio", "sse", "streamable-http"] = "streamable-http") -> None:
|
||||||
self,
|
|
||||||
transport: Literal["stdio", "sse", "streamable-http"] = "streamable-http",
|
|
||||||
) -> None:
|
|
||||||
"""
|
"""
|
||||||
Start the MCP server.
|
Start the MCP server.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
transport (Literal["stdio", "sse", "streamable-http"]):
|
transport: MCP transport (default: streamable-http)
|
||||||
Transport mechanism used by the MCP server. Supported options
|
|
||||||
include `stdio`, `sse`, and `streamable-http`.
|
|
||||||
"""
|
"""
|
||||||
self.app.run(transport=transport)
|
self.app.run(transport=transport)
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Literal
|
from typing import Literal, Any
|
||||||
|
|
||||||
from mcp.server.fastmcp import FastMCP
|
from mcp.server.fastmcp import FastMCP
|
||||||
|
|
||||||
class MCPServer:
|
|
||||||
"""MCP server serving a pre-generated documentation bundle.
|
|
||||||
|
|
||||||
Exposes read-only documentation resources and a health-check tool.
|
class MCPServer:
|
||||||
"""
|
"""MCP server for serving documentation."""
|
||||||
|
|
||||||
mcp_root: Path
|
mcp_root: Path
|
||||||
app: FastMCP
|
app: FastMCP
|
||||||
|
|
||||||
def __init__(self, mcp_root: Path, name: str) -> None: ...
|
def __init__(self, mcp_root: Path, name: str) -> None: ...
|
||||||
|
|
||||||
def _read_json(self, path: Path) -> Any: ...
|
def _read_json(self, path: Path) -> Any: ...
|
||||||
|
|
||||||
def _register_resources(self) -> None: ...
|
def _register_resources(self) -> None: ...
|
||||||
|
|
||||||
def _register_tools(self) -> None: ...
|
def _register_tools(self) -> None: ...
|
||||||
|
|
||||||
def run(self, transport: Literal["stdio", "sse", "streamable-http"] = ...) -> None:
|
def run(self, transport: Literal["stdio", "sse", "streamable-http"] = ...) -> None:
|
||||||
"""Start the MCP server."""
|
"""Start the MCP server."""
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
theme:
|
|
||||||
features:
|
|
||||||
- toc.integrate
|
|
||||||
- header.autohide
|
|
||||||
- announce.dismiss
|
|
||||||
- footer.social
|
|
||||||
|
|
||||||
- content.code.select
|
|
||||||
- content.code.line_numbers
|
|
||||||
- content.tooltips
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
- search
|
|
||||||
- swagger-ui-tag
|
|
||||||
- neoteroi.mkdocsoad:
|
|
||||||
use_pymdownx: true
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
theme:
|
|
||||||
name: material
|
|
||||||
palette:
|
|
||||||
- scheme: slate
|
|
||||||
primary: deep purple
|
|
||||||
accent: cyan
|
|
||||||
|
|
||||||
font:
|
|
||||||
text: Inter
|
|
||||||
code: JetBrains Mono
|
|
||||||
|
|
||||||
features:
|
|
||||||
# Navigation
|
|
||||||
- navigation.sections
|
|
||||||
- navigation.expand
|
|
||||||
- navigation.top
|
|
||||||
- navigation.instant
|
|
||||||
- navigation.tracking
|
|
||||||
- navigation.indexes
|
|
||||||
|
|
||||||
# Content
|
|
||||||
- content.code.copy
|
|
||||||
- content.code.annotate
|
|
||||||
- content.tabs.link
|
|
||||||
- content.action.edit
|
|
||||||
|
|
||||||
# Search UX
|
|
||||||
- search.highlight
|
|
||||||
- search.share
|
|
||||||
- search.suggest
|
|
||||||
|
|
||||||
markdown_extensions:
|
|
||||||
- pymdownx.superfences
|
|
||||||
- pymdownx.inlinehilite
|
|
||||||
- pymdownx.snippets
|
|
||||||
|
|
||||||
- admonition
|
|
||||||
- pymdownx.details
|
|
||||||
|
|
||||||
- pymdownx.highlight:
|
|
||||||
linenums: true
|
|
||||||
anchor_linenums: true
|
|
||||||
line_spans: __span
|
|
||||||
pygments_lang_class: true
|
|
||||||
|
|
||||||
- pymdownx.tabbed:
|
|
||||||
alternate_style: true
|
|
||||||
|
|
||||||
- pymdownx.tasklist:
|
|
||||||
custom_checkbox: true
|
|
||||||
|
|
||||||
- tables
|
|
||||||
- footnotes
|
|
||||||
|
|
||||||
- pymdownx.caret
|
|
||||||
- pymdownx.tilde
|
|
||||||
- pymdownx.mark
|
|
||||||
|
|
||||||
extra_css:
|
|
||||||
- https://unpkg.com/dracula-prism/dist/css/dracula-prism.css
|
|
||||||
@@ -1,9 +1,26 @@
|
|||||||
|
theme:
|
||||||
|
name: material
|
||||||
|
palette:
|
||||||
|
- scheme: slate
|
||||||
|
primary: deep purple
|
||||||
|
accent: cyan
|
||||||
|
font:
|
||||||
|
text: Inter
|
||||||
|
code: JetBrains Mono
|
||||||
|
features:
|
||||||
|
- navigation.tabs
|
||||||
|
- navigation.expand
|
||||||
|
- navigation.top
|
||||||
|
- navigation.instant
|
||||||
|
- content.code.copy
|
||||||
|
- content.code.annotate
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- search
|
- search
|
||||||
- mkdocstrings:
|
- mkdocstrings:
|
||||||
handlers:
|
handlers:
|
||||||
python:
|
python:
|
||||||
paths: [".."]
|
paths: ["."]
|
||||||
options:
|
options:
|
||||||
docstring_style: google
|
docstring_style: google
|
||||||
show_source: false
|
show_source: false
|
||||||
@@ -14,6 +31,3 @@ plugins:
|
|||||||
annotations_path: brief
|
annotations_path: brief
|
||||||
show_root_heading: true
|
show_root_heading: true
|
||||||
group_by_category: true
|
group_by_category: true
|
||||||
show_category_heading: true
|
|
||||||
show_object_full_path: false
|
|
||||||
show_symbol_type_heading: true
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
theme:
|
|
||||||
features:
|
|
||||||
# Horizontal tab navigation (mongo-ops style)
|
|
||||||
- navigation.tabs
|
|
||||||
# Navigation UX
|
|
||||||
- toc.integrate
|
|
||||||
- header.autohide
|
|
||||||
- announce.dismiss
|
|
||||||
- footer.social
|
|
||||||
# Content & Code
|
|
||||||
- content.code.select
|
|
||||||
- content.code.line_numbers
|
|
||||||
- content.tooltips
|
|
||||||
palette:
|
|
||||||
scheme: slate
|
|
||||||
primary: blue grey
|
|
||||||
accent: teal
|
|
||||||
font:
|
|
||||||
text: Roboto
|
|
||||||
code: JetBrains Mono
|
|
||||||
icon:
|
|
||||||
logo: material/database
|
|
||||||
repo: fontawesome/brands/github
|
|
||||||
plugins:
|
|
||||||
- search
|
|
||||||
- docforge-linkfix
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
# docforge
|
# Docforge
|
||||||
|
|
||||||
::: docforge
|
::: docforge
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Api Utils
|
|
||||||
|
|
||||||
::: docforge.cli.api_utils
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Wiki
|
|
||||||
|
|
||||||
::: docforge.nav.wiki
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.cli.api_utils",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.cli.api_utils",
|
|
||||||
"docstring": "# Summary\n\nUtilities for building API documentation from an OpenAPI specification.",
|
|
||||||
"objects": {
|
|
||||||
"SWAGGER_SPEC_FILENAME": {
|
|
||||||
"name": "SWAGGER_SPEC_FILENAME",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.SWAGGER_SPEC_FILENAME",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"OpenAPIMetadata": {
|
|
||||||
"name": "OpenAPIMetadata",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata",
|
|
||||||
"signature": "OpenAPIMetadata(site_name: str, site_description: str | None, site_author: str | None)",
|
|
||||||
"docstring": "Metadata derived from the ``info`` block of an OpenAPI specification.\n\nAttributes:\n site_name: Spec title, used as the MkDocs site name.\n site_description: Spec description, used as the site description.\n site_author: Contact name (fallback: contact email), used as the\n site author.",
|
|
||||||
"members": {
|
|
||||||
"site_name": {
|
|
||||||
"name": "site_name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata.site_name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_description": {
|
|
||||||
"name": "site_description",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata.site_description",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_author": {
|
|
||||||
"name": "site_author",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata.site_author",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_openapi_spec": {
|
|
||||||
"name": "load_openapi_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.api_utils.load_openapi_spec",
|
|
||||||
"signature": "load_openapi_spec(spec_path: Path) -> dict[Any, Any]",
|
|
||||||
"docstring": "Load and validate an OpenAPI specification from a JSON file.\n\nArgs:\n spec_path (Path):\n Path to the OpenAPI JSON specification file.\n\nReturns:\n dict:\n The parsed OpenAPI specification.\n\nRaises:\n click.ClickException:\n If the file cannot be read or the ``info`` block is invalid."
|
|
||||||
},
|
|
||||||
"derive_metadata": {
|
|
||||||
"name": "derive_metadata",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.api_utils.derive_metadata",
|
|
||||||
"signature": "derive_metadata(spec: dict[Any, Any]) -> OpenAPIMetadata",
|
|
||||||
"docstring": "Derive MkDocs site metadata from an OpenAPI spec ``info`` block.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n\nReturns:\n OpenAPIMetadata:\n Site name, description, and author derived from the spec."
|
|
||||||
},
|
|
||||||
"generate_api_sources": {
|
|
||||||
"name": "generate_api_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.api_utils.generate_api_sources",
|
|
||||||
"signature": "generate_api_sources(spec: dict[Any, Any], docs_dir: Path) -> None",
|
|
||||||
"docstring": "Generate swagger-enabled Markdown sources and the spec copy.\n\nThe specification is written as ``openapi.json`` inside ``docs_dir`` and\nan ``index.md`` embedding the swagger UI is generated alongside it.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n docs_dir (Path):\n Directory (for example ``docs/api``) where the swagger\n sources are written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,460 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.cli.commands",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.cli.commands",
|
|
||||||
"docstring": "# Summary\n\nCommand definitions for the doc-forge CLI.\n\nProvides the CLI structure using Click, including build, serve, and tree commands.\n\n---\n\nNotes:\n - The `build` command validates requested modes before generating anything.\n - `--mkdocs`, `--api`, and `--wiki` each emit their own MkDocs config and\n build (`docs/mkdocs.{kind}.yml` into `site/{kind}`); `--mcp` generates a\n machine-readable bundle independently.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"api_utils": {
|
|
||||||
"name": "api_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands.api_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for building API documentation from an OpenAPI specification.",
|
|
||||||
"members": {
|
|
||||||
"SWAGGER_SPEC_FILENAME": {
|
|
||||||
"name": "SWAGGER_SPEC_FILENAME",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.SWAGGER_SPEC_FILENAME",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"OpenAPIMetadata": {
|
|
||||||
"name": "OpenAPIMetadata",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata",
|
|
||||||
"signature": "OpenAPIMetadata(site_name: str, site_description: str | None, site_author: str | None)",
|
|
||||||
"docstring": "Metadata derived from the ``info`` block of an OpenAPI specification.\n\nAttributes:\n site_name: Spec title, used as the MkDocs site name.\n site_description: Spec description, used as the site description.\n site_author: Contact name (fallback: contact email), used as the\n site author.",
|
|
||||||
"members": {
|
|
||||||
"site_name": {
|
|
||||||
"name": "site_name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata.site_name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_description": {
|
|
||||||
"name": "site_description",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata.site_description",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_author": {
|
|
||||||
"name": "site_author",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata.site_author",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_openapi_spec": {
|
|
||||||
"name": "load_openapi_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.api_utils.load_openapi_spec",
|
|
||||||
"signature": "load_openapi_spec(spec_path: Path)",
|
|
||||||
"docstring": "Load and validate an OpenAPI specification from a JSON file.\n\nArgs:\n spec_path (Path):\n Path to the OpenAPI JSON specification file.\n\nReturns:\n dict:\n The parsed OpenAPI specification.\n\nRaises:\n click.ClickException:\n If the file cannot be read or the ``info`` block is invalid."
|
|
||||||
},
|
|
||||||
"derive_metadata": {
|
|
||||||
"name": "derive_metadata",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.api_utils.derive_metadata",
|
|
||||||
"signature": "derive_metadata(spec: dict[Any, Any])",
|
|
||||||
"docstring": "Derive MkDocs site metadata from an OpenAPI spec ``info`` block.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n\nReturns:\n OpenAPIMetadata:\n Site name, description, and author derived from the spec."
|
|
||||||
},
|
|
||||||
"generate_api_sources": {
|
|
||||||
"name": "generate_api_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.api_utils.generate_api_sources",
|
|
||||||
"signature": "generate_api_sources(spec: dict[Any, Any], docs_dir: Path)",
|
|
||||||
"docstring": "Generate swagger-enabled Markdown sources and the spec copy.\n\nThe specification is written as ``openapi.json`` inside ``docs_dir`` and\nan ``index.md`` embedding the swagger UI is generated alongside it.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n docs_dir (Path):\n Directory (for example ``docs/api``) where the swagger\n sources are written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mcp_utils": {
|
|
||||||
"name": "mcp_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MCP in the doc-forge CLI.\n\n---\n\nNotes:\n - `generate_resources` produces the bundle consumed by `MCPServer`:\n `index.json`, `nav.json`, and per-module resources under `modules/`.\n - Resource URIs use the `docs://` scheme: `docs://index`, `docs://nav`,\n and `docs://modules/{module}`.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MCPRenderer": {
|
|
||||||
"name": "MCPRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that generates MCP-compatible documentation resources.\n\nThis renderer converts doc-forge project models into structured JSON\nresources suitable for consumption by systems implementing the Model\nContext Protocol (MCP).",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path)",
|
|
||||||
"docstring": "Generate MCP documentation resources for a project.\n\nThe renderer serializes each module into a JSON resource and produces\nsupporting metadata files such as `nav.json` and `index.json`.\n\nArgs:\n project (Project):\n Documentation project model to render.\n\n out_dir (Path):\n Directory where MCP resources will be written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MCPServer": {
|
|
||||||
"name": "MCPServer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer",
|
|
||||||
"signature": "MCPServer(mcp_root: Path, name: str)",
|
|
||||||
"docstring": "MCP server for serving a pre-generated documentation bundle.\n\nThe server exposes documentation resources and diagnostic tools through\nMCP endpoints backed by JSON files generated by the MCP renderer.\n\nAttributes:\n mcp_root (Path):\n Directory containing the generated MCP documentation bundle.\n\n app (FastMCP):\n Underlying FastMCP application instance that registers resources\n and tools.",
|
|
||||||
"members": {
|
|
||||||
"mcp_root": {
|
|
||||||
"name": "mcp_root",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer.mcp_root",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"app": {
|
|
||||||
"name": "app",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer.app",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"run": {
|
|
||||||
"name": "run",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer.run",
|
|
||||||
"signature": "run(transport: Literal['stdio', 'sse', 'streamable-http'] = 'streamable-http')",
|
|
||||||
"docstring": "Start the MCP server.\n\nArgs:\n transport (Literal[\"stdio\", \"sse\", \"streamable-http\"]):\n Transport mechanism used by the MCP server. Supported options\n include `stdio`, `sse`, and `streamable-http`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_resources": {
|
|
||||||
"name": "generate_resources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.generate_resources",
|
|
||||||
"signature": "generate_resources(module: str, project_name: str | None, out_dir: Path)",
|
|
||||||
"docstring": "Generate MCP documentation resources from a Python module.\n\nThe function performs project introspection, builds the internal\ndocumentation model, and renders MCP-compatible JSON resources\nto the specified output directory.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n project_name (str | None):\n Optional override for the project name used in generated\n documentation metadata.\n\n out_dir (Path):\n Directory where MCP resources (index.json, nav.json, and module data)\n will be written."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.serve",
|
|
||||||
"signature": "serve(module: str, mcp_root: Path)",
|
|
||||||
"docstring": "Start an MCP server for a pre-generated documentation bundle.\n\nThe server exposes documentation resources such as project metadata,\nnavigation structure, and module documentation through MCP endpoints.\n\nArgs:\n module (str):\n Python module import path used to identify the served\n documentation instance.\n\n mcp_root (Path):\n Path to the directory containing the MCP documentation\n bundle (index.json, nav.json, and modules/).\n\nRaises:\n click.ClickException:\n If the MCP documentation bundle is missing required files or directories."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mkdocs_utils": {
|
|
||||||
"name": "mkdocs_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MkDocs in the doc-forge CLI.\n\n---\n\nNotes:\n - A separate `mkdocs.{kind}.yml` configuration and build is emitted per\n enabled kind (lib, api, wiki), each scoped to its own `docs_dir` and\n written into its own `site_dir` (`site/lib`, `site/api`, `site/wiki`).\n - Navigation blocks are re-rooted per kind: the wiki navigation drops its\n leading `wiki/` scope and the resolved nav spec drops its `lib/` scope.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav)",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build_wiki_nav": {
|
|
||||||
"name": "build_wiki_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_wiki_nav",
|
|
||||||
"signature": "build_wiki_nav(wiki_dir: Path)",
|
|
||||||
"docstring": "Derive an MkDocs navigation block from a wiki directory.\n\nReturned paths are relative to the parent of ``wiki_dir`` and carry the\nwiki directory name as their leading component (for example\n``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes\nthe result directly usable in an MkDocs ``nav`` block with\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries compatible with the MkDocs ``nav`` configuration.\n The list is empty if the wiki contains no Markdown files.\n\nRaises:\n FileNotFoundError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path)",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
},
|
|
||||||
"MkDocsRenderer": {
|
|
||||||
"name": "MkDocsRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that produces Markdown documentation for MkDocs.\n\nGenerated pages use mkdocstrings directives to reference Python modules,\nallowing MkDocs to render API documentation dynamically.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path, module_is_source: bool | None = None)",
|
|
||||||
"docstring": "Generate Markdown documentation files for a project.\n\nThis method renders a documentation structure from the provided\nproject model and writes the resulting Markdown files to the\nspecified output directory.\n\nArgs:\n project (Project):\n Project model containing modules to document.\n\n out_dir (Path):\n Directory where generated Markdown files will be written.\n\n module_is_source (bool | None):\n If True, treat the specified module as the documentation root\n rather than nesting it inside a folder."
|
|
||||||
},
|
|
||||||
"generate_readme": {
|
|
||||||
"name": "generate_readme",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer.generate_readme",
|
|
||||||
"signature": "generate_readme(project: Project, docs_dir: Path, module_is_source: bool | None = None, readme_dir: Path | None = None)",
|
|
||||||
"docstring": "Generate a `README.md` file from the root module docstring.\n\nNotes:\n - If `module_is_source` is True, `README.md` is written to the\n project root directory.\n - If False, README generation is currently not implemented.\n\nArgs:\n project (Project):\n Project model containing documentation metadata.\n\n docs_dir (Path):\n Directory containing generated documentation sources.\n\n module_is_source (bool | None):\n Whether the module is treated as the project source root.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written.\n Defaults to the parent of `docs_dir`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.generate_sources",
|
|
||||||
"signature": "generate_sources(module: str, docs_dir: Path, project_name: str | None = None, module_is_source: bool | None = None, readme_dir: Path | None = None)",
|
|
||||||
"docstring": "Generate MkDocs Markdown sources for a Python module.\n\nThis function introspects the specified module, builds the internal\ndocumentation model, and renders Markdown documentation files for\nuse with MkDocs.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n docs_dir (Path):\n Directory where the generated Markdown files will be written.\n\n project_name (str | None):\n Optional override for the project name used in documentation metadata.\n\n module_is_source (bool | None):\n If True, treat the specified module directory as the project root\n rather than a nested module.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written. If not\n provided, defaults to the parent of ``docs_dir``."
|
|
||||||
},
|
|
||||||
"build_lib_nav": {
|
|
||||||
"name": "build_lib_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_lib_nav",
|
|
||||||
"signature": "build_lib_nav(nav_file: Path, docs_root: Path)",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a lib site.\n\nThe navigation specification is resolved against the shared documentation\nroot and every resulting path is re-rooted relative to the ``lib``\nsubdirectory by stripping its leading ``lib/`` scope component.\n\nArgs:\n nav_file (Path):\n Path to the `docforge.nav.yml` navigation specification.\n\n docs_root (Path):\n Shared documentation root containing the ``lib`` sources.\n\nReturns:\n tuple[list[dict[str, Any]], dict[str, str] | None]:\n The re-rooted navigation block and the optional theme icon\n mapping from the specification.\n\nRaises:\n click.FileError:\n If the navigation specification cannot be found."
|
|
||||||
},
|
|
||||||
"build_wiki_nav_block": {
|
|
||||||
"name": "build_wiki_nav_block",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_wiki_nav_block",
|
|
||||||
"signature": "build_wiki_nav_block(wiki_dir: Path)",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a wiki site.\n\nThe wiki navigation derived from the wiki file structure is re-rooted\nrelative to the wiki directory itself by stripping the leading ``wiki/``\nscope component.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries relative to the wiki directory.\n\nRaises:\n click.FileError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_spec_icon": {
|
|
||||||
"name": "load_spec_icon",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.load_spec_icon",
|
|
||||||
"signature": "load_spec_icon(nav_file: Path)",
|
|
||||||
"docstring": "Load the theme icon mapping from a navigation specification.\n\nArgs:\n nav_file (Path):\n Path to the navigation specification file.\n\nReturns:\n dict[str, str] | None:\n The icon mapping, or ``None`` when the specification file is\n absent or cannot be parsed."
|
|
||||||
},
|
|
||||||
"generate_site_config": {
|
|
||||||
"name": "generate_site_config",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.generate_site_config",
|
|
||||||
"signature": "generate_site_config(kind: str, kind_root: Path, nav_block: list[dict[str, Any]], out: Path, site_name: str, docs_dir: str, site_dir: str, template: Path | None = None, site_description: str | None = None, site_author: str | None = None, theme_icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Generate a per-kind `mkdocs.{kind}.yml` configuration file.\n\nThe configuration is created by merging the shared ``mkdocs.common.yml``\ntemplate with the fragment contributed by the kind (``lib``, ``api``, or\n``wiki``). Both ``docs_dir`` and ``site_dir`` are written relative to the\nconfiguration file's directory: the kind's sources when expressed as a\nsibling path (for example ``lib``) and the per-kind site output (for\nexample ``../site/lib``).\n\nArgs:\n kind (str):\n Documentation kind, one of ``lib``, ``api``, or ``wiki``.\n\n kind_root (Path):\n Directory scoped to the kind (for example ``docs/lib``) that\n serves as the MkDocs ``docs_dir``.\n\n nav_block (list[dict[str, Any]]):\n Re-rooted navigation entries for the kind's site.\n\n out (Path):\n Destination path where the generated ``mkdocs.{kind}.yml`` file\n is written.\n\n site_name (str):\n Display name for the generated documentation site.\n\n docs_dir (str):\n MkDocs ``docs_dir`` value, relative to the configuration\n file's directory.\n\n site_dir (str):\n MkDocs ``site_dir`` value, relative to the configuration\n file's directory.\n\n template (Path | None):\n Optional path to a fully custom MkDocs configuration template\n that replaces the built-in templates entirely.\n\n site_description (str | None):\n Optional site description written into the configuration.\n\n site_author (str | None):\n Optional site author written into the configuration.\n\n theme_icon (dict[str, str] | None):\n Optional mapping of theme icon entries injected as\n ``theme.icon``."
|
|
||||||
},
|
|
||||||
"build_configs": {
|
|
||||||
"name": "build_configs",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_configs",
|
|
||||||
"signature": "build_configs(yml_paths: Iterable[Path])",
|
|
||||||
"docstring": "Build the MkDocs documentation site for every given configuration.\n\nEach configuration file is loaded and built in turn, producing the\nper-kind static sites (``site/lib``, ``site/api``, ``site/wiki``).\n\nArgs:\n yml_paths (Iterable[Path]):\n Configuration files to build, in order.\n\nRaises:\n click.ClickException:\n If a configuration file does not exist."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.serve",
|
|
||||||
"signature": "serve(mkdocs_yml: Path)",
|
|
||||||
"docstring": "Start an MkDocs development server with live reload.\n\nThe server watches documentation files and automatically reloads\nthe site when changes are detected.\n\nArgs:\n mkdocs_yml (Path):\n Path to the `mkdocs.yml` configuration file.\n\nRaises:\n click.ClickException:\n If the configuration file does not exist."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"cli": {
|
|
||||||
"name": "cli",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.cli",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"name": "build",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.build",
|
|
||||||
"signature": "build(mcp: bool, mkdocs: bool, api: bool, wiki: bool, refresh: bool, module_is_source: bool, module: str | None, openapi_spec: Path | None, project_name: str | None, site_name: str | None, docs_dir: Path, wiki_dir: Path, nav_file: Path, template: Path | None, out_dir: Path) -> None",
|
|
||||||
"docstring": "Build documentation artifacts.\n\nThis command runs the full documentation pipeline: it loads Python\nmodules, generates renderer-specific documentation sources, and\noptionally builds the final output.\n\nDepending on the selected options, the build can target:\n\n- A lib MkDocs site (`--mkdocs`) for library reference docs\n- A swagger-enabled API MkDocs site (`--api`) built from an OpenAPI spec\n- A wiki MkDocs site (`--wiki`) built from hand-written markdown\n- MCP structured documentation resources (`--mcp`)\n\nEach enabled site kind produces its own MkDocs configuration\n(`docs/mkdocs.{kind}.yml`) and its own build (`site/{kind}`).\n\nNotes:\n - At least one of `--mcp`, `--mkdocs`, `--wiki`, or `--api` must be\n provided.\n - `--mkdocs`, `--api`, and `--wiki` emit independent MkDocs builds,\n while `--mcp` emits a machine-readable bundle.\n - Configuration files are generated only when absent; an existing\n `docs/mkdocs.{kind}.yml` is used as-is. Pass `--refresh` to\n rebaseline it from the templates.\n\nArgs:\n mcp (bool):\n Enable MCP documentation generation.\n\n mkdocs (bool):\n Enable the lib MkDocs documentation generation.\n\n api (bool):\n Enable API documentation generation from an OpenAPI spec.\n\n wiki (bool):\n Build a hand-written wiki directory as its own MkDocs site.\n\n refresh (bool):\n Regenerate ``docs/mkdocs.{kind}.yml`` from templates even when\n it already exists. By default, existing configs are used as-is.\n\n module_is_source (bool):\n Treat the specified module directory as the project root.\n\n module (str | None):\n Python module import path to document.\n\n openapi_spec (Path | None):\n Path to the OpenAPI JSON specification used for API docs.\n\n project_name (str | None):\n Optional override for the project name.\n\n site_name (str | None):\n Display name for the lib and wiki MkDocs sites.\n\n docs_dir (Path):\n Shared documentation root used for generated sources.\n wiki_dir (Path):\n Directory containing hand-written wiki markdown files.\n\n nav_file (Path):\n Path to the navigation specification file.\n\n template (Path | None):\n Optional custom MkDocs configuration template.\n\n out_dir (Path):\n Output directory for generated MCP resources.\n\nRaises:\n click.UsageError:\n If required options are missing or conflicting."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.serve",
|
|
||||||
"signature": "serve(mcp: bool, mkdocs: bool, lib: bool, api: bool, wiki: bool, module: str | None, mkdocs_yml: Path, out_dir: Path) -> None",
|
|
||||||
"docstring": "Serve generated documentation locally.\n\nDepending on the selected mode, this command starts either:\n\n- A MkDocs development server for browsing a site, or\n- An MCP server exposing structured documentation resources\n\nThe kind flags (`--lib`, `--api`, `--wiki`) select the generated\nper-kind config (`docs/mkdocs.{kind}.yml`); `--mkdocs` serves the config\npassed via `--mkdocs-yml`.\n\nArgs:\n mcp (bool):\n Serve documentation using the MCP server.\n\n mkdocs (bool):\n Serve the MkDocs development site from ``--mkdocs-yml``.\n\n lib (bool):\n Serve the lib MkDocs site.\n\n api (bool):\n Serve the API MkDocs site.\n\n wiki (bool):\n Serve the wiki MkDocs site.\n\n module (str | None):\n Python module import path to serve via MCP.\n\n mkdocs_yml (Path):\n Path to the MkDocs configuration file.\n\n out_dir (Path):\n Root directory containing MCP documentation resources.\n\nRaises:\n click.UsageError:\n If invalid or conflicting options are provided."
|
|
||||||
},
|
|
||||||
"tree": {
|
|
||||||
"name": "tree",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.tree",
|
|
||||||
"signature": "tree(module: str, project_name: str | None) -> None",
|
|
||||||
"docstring": "Display the documentation object tree for a module.\n\nThis command introspects the specified module and prints a\nhierarchical representation of the discovered documentation\nobjects, including modules, classes, functions, and members.\n\nArgs:\n module (str):\n Python module import path to introspect.\n\n project_name (str | None):\n Optional name to display as the project root."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,820 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.cli",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.cli",
|
|
||||||
"docstring": "# Summary\n\nCommand line interface entry point for doc-forge.\n\nThis module exposes the primary CLI entry function used by the\n`doc-forge` command. The actual command implementation resides in\n`docforge.cli.main`, while this module provides a stable import path\nfor external tools and the package entry point configuration.\n\nThe CLI is responsible for orchestrating documentation workflows such as\ngenerating renderer sources, building documentation sites, exporting\nmachine-readable documentation bundles, and starting development or MCP\nservers.\n\n---\n\n# Typical usage\n\nThe CLI is normally invoked through the installed command:\n\n```bash\ndoc-forge <command> [options]\n```\n\nProgrammatic invocation is also possible:\n\nExample:\n\n ```python\n from docforge.cli import main\n main()\n ```\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"main": {
|
|
||||||
"name": "main",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.main",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nCommand-line entry point for the doc-forge CLI.\n\nThis module exposes the executable entry point that initializes the\nClick command group defined in `docforge.cli.commands`.",
|
|
||||||
"members": {
|
|
||||||
"cli": {
|
|
||||||
"name": "cli",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.main.cli",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"main": {
|
|
||||||
"name": "main",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.main.main",
|
|
||||||
"signature": "main() -> None",
|
|
||||||
"docstring": "Run the doc-forge command-line interface.\n\nThis function initializes and executes the Click CLI application.\nIt is used as the console entry point when invoking `doc-forge`\nfrom the command line."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"api_utils": {
|
|
||||||
"name": "api_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.api_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for building API documentation from an OpenAPI specification.",
|
|
||||||
"members": {
|
|
||||||
"SWAGGER_SPEC_FILENAME": {
|
|
||||||
"name": "SWAGGER_SPEC_FILENAME",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.SWAGGER_SPEC_FILENAME",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"OpenAPIMetadata": {
|
|
||||||
"name": "OpenAPIMetadata",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata",
|
|
||||||
"signature": "OpenAPIMetadata(site_name: str, site_description: str | None, site_author: str | None)",
|
|
||||||
"docstring": "Metadata derived from the ``info`` block of an OpenAPI specification.\n\nAttributes:\n site_name: Spec title, used as the MkDocs site name.\n site_description: Spec description, used as the site description.\n site_author: Contact name (fallback: contact email), used as the\n site author.",
|
|
||||||
"members": {
|
|
||||||
"site_name": {
|
|
||||||
"name": "site_name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata.site_name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_description": {
|
|
||||||
"name": "site_description",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata.site_description",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_author": {
|
|
||||||
"name": "site_author",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.api_utils.OpenAPIMetadata.site_author",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_openapi_spec": {
|
|
||||||
"name": "load_openapi_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.api_utils.load_openapi_spec",
|
|
||||||
"signature": "load_openapi_spec(spec_path: Path) -> dict[Any, Any]",
|
|
||||||
"docstring": "Load and validate an OpenAPI specification from a JSON file.\n\nArgs:\n spec_path (Path):\n Path to the OpenAPI JSON specification file.\n\nReturns:\n dict:\n The parsed OpenAPI specification.\n\nRaises:\n click.ClickException:\n If the file cannot be read or the ``info`` block is invalid."
|
|
||||||
},
|
|
||||||
"derive_metadata": {
|
|
||||||
"name": "derive_metadata",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.api_utils.derive_metadata",
|
|
||||||
"signature": "derive_metadata(spec: dict[Any, Any]) -> OpenAPIMetadata",
|
|
||||||
"docstring": "Derive MkDocs site metadata from an OpenAPI spec ``info`` block.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n\nReturns:\n OpenAPIMetadata:\n Site name, description, and author derived from the spec."
|
|
||||||
},
|
|
||||||
"generate_api_sources": {
|
|
||||||
"name": "generate_api_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.api_utils.generate_api_sources",
|
|
||||||
"signature": "generate_api_sources(spec: dict[Any, Any], docs_dir: Path) -> None",
|
|
||||||
"docstring": "Generate swagger-enabled Markdown sources and the spec copy.\n\nThe specification is written as ``openapi.json`` inside ``docs_dir`` and\nan ``index.md`` embedding the swagger UI is generated alongside it.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n docs_dir (Path):\n Directory (for example ``docs/api``) where the swagger\n sources are written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"commands": {
|
|
||||||
"name": "commands",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nCommand definitions for the doc-forge CLI.\n\nProvides the CLI structure using Click, including build, serve, and tree commands.\n\n---\n\nNotes:\n - The `build` command validates requested modes before generating anything.\n - `--mkdocs`, `--api`, and `--wiki` each emit their own MkDocs config and\n build (`docs/mkdocs.{kind}.yml` into `site/{kind}`); `--mcp` generates a\n machine-readable bundle independently.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"api_utils": {
|
|
||||||
"name": "api_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands.api_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for building API documentation from an OpenAPI specification.",
|
|
||||||
"members": {
|
|
||||||
"SWAGGER_SPEC_FILENAME": {
|
|
||||||
"name": "SWAGGER_SPEC_FILENAME",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.SWAGGER_SPEC_FILENAME",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"OpenAPIMetadata": {
|
|
||||||
"name": "OpenAPIMetadata",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata",
|
|
||||||
"signature": "OpenAPIMetadata(site_name: str, site_description: str | None, site_author: str | None)",
|
|
||||||
"docstring": "Metadata derived from the ``info`` block of an OpenAPI specification.\n\nAttributes:\n site_name: Spec title, used as the MkDocs site name.\n site_description: Spec description, used as the site description.\n site_author: Contact name (fallback: contact email), used as the\n site author.",
|
|
||||||
"members": {
|
|
||||||
"site_name": {
|
|
||||||
"name": "site_name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata.site_name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_description": {
|
|
||||||
"name": "site_description",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata.site_description",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"site_author": {
|
|
||||||
"name": "site_author",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.api_utils.OpenAPIMetadata.site_author",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_openapi_spec": {
|
|
||||||
"name": "load_openapi_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.api_utils.load_openapi_spec",
|
|
||||||
"signature": "load_openapi_spec(spec_path: Path)",
|
|
||||||
"docstring": "Load and validate an OpenAPI specification from a JSON file.\n\nArgs:\n spec_path (Path):\n Path to the OpenAPI JSON specification file.\n\nReturns:\n dict:\n The parsed OpenAPI specification.\n\nRaises:\n click.ClickException:\n If the file cannot be read or the ``info`` block is invalid."
|
|
||||||
},
|
|
||||||
"derive_metadata": {
|
|
||||||
"name": "derive_metadata",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.api_utils.derive_metadata",
|
|
||||||
"signature": "derive_metadata(spec: dict[Any, Any])",
|
|
||||||
"docstring": "Derive MkDocs site metadata from an OpenAPI spec ``info`` block.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n\nReturns:\n OpenAPIMetadata:\n Site name, description, and author derived from the spec."
|
|
||||||
},
|
|
||||||
"generate_api_sources": {
|
|
||||||
"name": "generate_api_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.api_utils.generate_api_sources",
|
|
||||||
"signature": "generate_api_sources(spec: dict[Any, Any], docs_dir: Path)",
|
|
||||||
"docstring": "Generate swagger-enabled Markdown sources and the spec copy.\n\nThe specification is written as ``openapi.json`` inside ``docs_dir`` and\nan ``index.md`` embedding the swagger UI is generated alongside it.\n\nArgs:\n spec (dict):\n Parsed OpenAPI specification.\n docs_dir (Path):\n Directory (for example ``docs/api``) where the swagger\n sources are written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mcp_utils": {
|
|
||||||
"name": "mcp_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MCP in the doc-forge CLI.\n\n---\n\nNotes:\n - `generate_resources` produces the bundle consumed by `MCPServer`:\n `index.json`, `nav.json`, and per-module resources under `modules/`.\n - Resource URIs use the `docs://` scheme: `docs://index`, `docs://nav`,\n and `docs://modules/{module}`.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MCPRenderer": {
|
|
||||||
"name": "MCPRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that generates MCP-compatible documentation resources.\n\nThis renderer converts doc-forge project models into structured JSON\nresources suitable for consumption by systems implementing the Model\nContext Protocol (MCP).",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path)",
|
|
||||||
"docstring": "Generate MCP documentation resources for a project.\n\nThe renderer serializes each module into a JSON resource and produces\nsupporting metadata files such as `nav.json` and `index.json`.\n\nArgs:\n project (Project):\n Documentation project model to render.\n\n out_dir (Path):\n Directory where MCP resources will be written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MCPServer": {
|
|
||||||
"name": "MCPServer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer",
|
|
||||||
"signature": "MCPServer(mcp_root: Path, name: str)",
|
|
||||||
"docstring": "MCP server for serving a pre-generated documentation bundle.\n\nThe server exposes documentation resources and diagnostic tools through\nMCP endpoints backed by JSON files generated by the MCP renderer.\n\nAttributes:\n mcp_root (Path):\n Directory containing the generated MCP documentation bundle.\n\n app (FastMCP):\n Underlying FastMCP application instance that registers resources\n and tools.",
|
|
||||||
"members": {
|
|
||||||
"mcp_root": {
|
|
||||||
"name": "mcp_root",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer.mcp_root",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"app": {
|
|
||||||
"name": "app",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer.app",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"run": {
|
|
||||||
"name": "run",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.MCPServer.run",
|
|
||||||
"signature": "run(transport: Literal['stdio', 'sse', 'streamable-http'] = 'streamable-http')",
|
|
||||||
"docstring": "Start the MCP server.\n\nArgs:\n transport (Literal[\"stdio\", \"sse\", \"streamable-http\"]):\n Transport mechanism used by the MCP server. Supported options\n include `stdio`, `sse`, and `streamable-http`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_resources": {
|
|
||||||
"name": "generate_resources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.generate_resources",
|
|
||||||
"signature": "generate_resources(module: str, project_name: str | None, out_dir: Path)",
|
|
||||||
"docstring": "Generate MCP documentation resources from a Python module.\n\nThe function performs project introspection, builds the internal\ndocumentation model, and renders MCP-compatible JSON resources\nto the specified output directory.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n project_name (str | None):\n Optional override for the project name used in generated\n documentation metadata.\n\n out_dir (Path):\n Directory where MCP resources (index.json, nav.json, and module data)\n will be written."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mcp_utils.serve",
|
|
||||||
"signature": "serve(module: str, mcp_root: Path)",
|
|
||||||
"docstring": "Start an MCP server for a pre-generated documentation bundle.\n\nThe server exposes documentation resources such as project metadata,\nnavigation structure, and module documentation through MCP endpoints.\n\nArgs:\n module (str):\n Python module import path used to identify the served\n documentation instance.\n\n mcp_root (Path):\n Path to the directory containing the MCP documentation\n bundle (index.json, nav.json, and modules/).\n\nRaises:\n click.ClickException:\n If the MCP documentation bundle is missing required files or directories."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mkdocs_utils": {
|
|
||||||
"name": "mkdocs_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MkDocs in the doc-forge CLI.\n\n---\n\nNotes:\n - A separate `mkdocs.{kind}.yml` configuration and build is emitted per\n enabled kind (lib, api, wiki), each scoped to its own `docs_dir` and\n written into its own `site_dir` (`site/lib`, `site/api`, `site/wiki`).\n - Navigation blocks are re-rooted per kind: the wiki navigation drops its\n leading `wiki/` scope and the resolved nav spec drops its `lib/` scope.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav)",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build_wiki_nav": {
|
|
||||||
"name": "build_wiki_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_wiki_nav",
|
|
||||||
"signature": "build_wiki_nav(wiki_dir: Path)",
|
|
||||||
"docstring": "Derive an MkDocs navigation block from a wiki directory.\n\nReturned paths are relative to the parent of ``wiki_dir`` and carry the\nwiki directory name as their leading component (for example\n``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes\nthe result directly usable in an MkDocs ``nav`` block with\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries compatible with the MkDocs ``nav`` configuration.\n The list is empty if the wiki contains no Markdown files.\n\nRaises:\n FileNotFoundError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path)",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
},
|
|
||||||
"MkDocsRenderer": {
|
|
||||||
"name": "MkDocsRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that produces Markdown documentation for MkDocs.\n\nGenerated pages use mkdocstrings directives to reference Python modules,\nallowing MkDocs to render API documentation dynamically.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path, module_is_source: bool | None = None)",
|
|
||||||
"docstring": "Generate Markdown documentation files for a project.\n\nThis method renders a documentation structure from the provided\nproject model and writes the resulting Markdown files to the\nspecified output directory.\n\nArgs:\n project (Project):\n Project model containing modules to document.\n\n out_dir (Path):\n Directory where generated Markdown files will be written.\n\n module_is_source (bool | None):\n If True, treat the specified module as the documentation root\n rather than nesting it inside a folder."
|
|
||||||
},
|
|
||||||
"generate_readme": {
|
|
||||||
"name": "generate_readme",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.MkDocsRenderer.generate_readme",
|
|
||||||
"signature": "generate_readme(project: Project, docs_dir: Path, module_is_source: bool | None = None, readme_dir: Path | None = None)",
|
|
||||||
"docstring": "Generate a `README.md` file from the root module docstring.\n\nNotes:\n - If `module_is_source` is True, `README.md` is written to the\n project root directory.\n - If False, README generation is currently not implemented.\n\nArgs:\n project (Project):\n Project model containing documentation metadata.\n\n docs_dir (Path):\n Directory containing generated documentation sources.\n\n module_is_source (bool | None):\n Whether the module is treated as the project source root.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written.\n Defaults to the parent of `docs_dir`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.generate_sources",
|
|
||||||
"signature": "generate_sources(module: str, docs_dir: Path, project_name: str | None = None, module_is_source: bool | None = None, readme_dir: Path | None = None)",
|
|
||||||
"docstring": "Generate MkDocs Markdown sources for a Python module.\n\nThis function introspects the specified module, builds the internal\ndocumentation model, and renders Markdown documentation files for\nuse with MkDocs.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n docs_dir (Path):\n Directory where the generated Markdown files will be written.\n\n project_name (str | None):\n Optional override for the project name used in documentation metadata.\n\n module_is_source (bool | None):\n If True, treat the specified module directory as the project root\n rather than a nested module.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written. If not\n provided, defaults to the parent of ``docs_dir``."
|
|
||||||
},
|
|
||||||
"build_lib_nav": {
|
|
||||||
"name": "build_lib_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_lib_nav",
|
|
||||||
"signature": "build_lib_nav(nav_file: Path, docs_root: Path)",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a lib site.\n\nThe navigation specification is resolved against the shared documentation\nroot and every resulting path is re-rooted relative to the ``lib``\nsubdirectory by stripping its leading ``lib/`` scope component.\n\nArgs:\n nav_file (Path):\n Path to the `docforge.nav.yml` navigation specification.\n\n docs_root (Path):\n Shared documentation root containing the ``lib`` sources.\n\nReturns:\n tuple[list[dict[str, Any]], dict[str, str] | None]:\n The re-rooted navigation block and the optional theme icon\n mapping from the specification.\n\nRaises:\n click.FileError:\n If the navigation specification cannot be found."
|
|
||||||
},
|
|
||||||
"build_wiki_nav_block": {
|
|
||||||
"name": "build_wiki_nav_block",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_wiki_nav_block",
|
|
||||||
"signature": "build_wiki_nav_block(wiki_dir: Path)",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a wiki site.\n\nThe wiki navigation derived from the wiki file structure is re-rooted\nrelative to the wiki directory itself by stripping the leading ``wiki/``\nscope component.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries relative to the wiki directory.\n\nRaises:\n click.FileError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_spec_icon": {
|
|
||||||
"name": "load_spec_icon",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.load_spec_icon",
|
|
||||||
"signature": "load_spec_icon(nav_file: Path)",
|
|
||||||
"docstring": "Load the theme icon mapping from a navigation specification.\n\nArgs:\n nav_file (Path):\n Path to the navigation specification file.\n\nReturns:\n dict[str, str] | None:\n The icon mapping, or ``None`` when the specification file is\n absent or cannot be parsed."
|
|
||||||
},
|
|
||||||
"generate_site_config": {
|
|
||||||
"name": "generate_site_config",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.generate_site_config",
|
|
||||||
"signature": "generate_site_config(kind: str, kind_root: Path, nav_block: list[dict[str, Any]], out: Path, site_name: str, docs_dir: str, site_dir: str, template: Path | None = None, site_description: str | None = None, site_author: str | None = None, theme_icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Generate a per-kind `mkdocs.{kind}.yml` configuration file.\n\nThe configuration is created by merging the shared ``mkdocs.common.yml``\ntemplate with the fragment contributed by the kind (``lib``, ``api``, or\n``wiki``). Both ``docs_dir`` and ``site_dir`` are written relative to the\nconfiguration file's directory: the kind's sources when expressed as a\nsibling path (for example ``lib``) and the per-kind site output (for\nexample ``../site/lib``).\n\nArgs:\n kind (str):\n Documentation kind, one of ``lib``, ``api``, or ``wiki``.\n\n kind_root (Path):\n Directory scoped to the kind (for example ``docs/lib``) that\n serves as the MkDocs ``docs_dir``.\n\n nav_block (list[dict[str, Any]]):\n Re-rooted navigation entries for the kind's site.\n\n out (Path):\n Destination path where the generated ``mkdocs.{kind}.yml`` file\n is written.\n\n site_name (str):\n Display name for the generated documentation site.\n\n docs_dir (str):\n MkDocs ``docs_dir`` value, relative to the configuration\n file's directory.\n\n site_dir (str):\n MkDocs ``site_dir`` value, relative to the configuration\n file's directory.\n\n template (Path | None):\n Optional path to a fully custom MkDocs configuration template\n that replaces the built-in templates entirely.\n\n site_description (str | None):\n Optional site description written into the configuration.\n\n site_author (str | None):\n Optional site author written into the configuration.\n\n theme_icon (dict[str, str] | None):\n Optional mapping of theme icon entries injected as\n ``theme.icon``."
|
|
||||||
},
|
|
||||||
"build_configs": {
|
|
||||||
"name": "build_configs",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.build_configs",
|
|
||||||
"signature": "build_configs(yml_paths: Iterable[Path])",
|
|
||||||
"docstring": "Build the MkDocs documentation site for every given configuration.\n\nEach configuration file is loaded and built in turn, producing the\nper-kind static sites (``site/lib``, ``site/api``, ``site/wiki``).\n\nArgs:\n yml_paths (Iterable[Path]):\n Configuration files to build, in order.\n\nRaises:\n click.ClickException:\n If a configuration file does not exist."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.mkdocs_utils.serve",
|
|
||||||
"signature": "serve(mkdocs_yml: Path)",
|
|
||||||
"docstring": "Start an MkDocs development server with live reload.\n\nThe server watches documentation files and automatically reloads\nthe site when changes are detected.\n\nArgs:\n mkdocs_yml (Path):\n Path to the `mkdocs.yml` configuration file.\n\nRaises:\n click.ClickException:\n If the configuration file does not exist."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.commands.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"cli": {
|
|
||||||
"name": "cli",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.commands.cli",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"name": "build",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.build",
|
|
||||||
"signature": "build(mcp: bool, mkdocs: bool, api: bool, wiki: bool, refresh: bool, module_is_source: bool, module: str | None, openapi_spec: Path | None, project_name: str | None, site_name: str | None, docs_dir: Path, wiki_dir: Path, nav_file: Path, template: Path | None, out_dir: Path) -> None",
|
|
||||||
"docstring": "Build documentation artifacts.\n\nThis command runs the full documentation pipeline: it loads Python\nmodules, generates renderer-specific documentation sources, and\noptionally builds the final output.\n\nDepending on the selected options, the build can target:\n\n- A lib MkDocs site (`--mkdocs`) for library reference docs\n- A swagger-enabled API MkDocs site (`--api`) built from an OpenAPI spec\n- A wiki MkDocs site (`--wiki`) built from hand-written markdown\n- MCP structured documentation resources (`--mcp`)\n\nEach enabled site kind produces its own MkDocs configuration\n(`docs/mkdocs.{kind}.yml`) and its own build (`site/{kind}`).\n\nNotes:\n - At least one of `--mcp`, `--mkdocs`, `--wiki`, or `--api` must be\n provided.\n - `--mkdocs`, `--api`, and `--wiki` emit independent MkDocs builds,\n while `--mcp` emits a machine-readable bundle.\n - Configuration files are generated only when absent; an existing\n `docs/mkdocs.{kind}.yml` is used as-is. Pass `--refresh` to\n rebaseline it from the templates.\n\nArgs:\n mcp (bool):\n Enable MCP documentation generation.\n\n mkdocs (bool):\n Enable the lib MkDocs documentation generation.\n\n api (bool):\n Enable API documentation generation from an OpenAPI spec.\n\n wiki (bool):\n Build a hand-written wiki directory as its own MkDocs site.\n\n refresh (bool):\n Regenerate ``docs/mkdocs.{kind}.yml`` from templates even when\n it already exists. By default, existing configs are used as-is.\n\n module_is_source (bool):\n Treat the specified module directory as the project root.\n\n module (str | None):\n Python module import path to document.\n\n openapi_spec (Path | None):\n Path to the OpenAPI JSON specification used for API docs.\n\n project_name (str | None):\n Optional override for the project name.\n\n site_name (str | None):\n Display name for the lib and wiki MkDocs sites.\n\n docs_dir (Path):\n Shared documentation root used for generated sources.\n wiki_dir (Path):\n Directory containing hand-written wiki markdown files.\n\n nav_file (Path):\n Path to the navigation specification file.\n\n template (Path | None):\n Optional custom MkDocs configuration template.\n\n out_dir (Path):\n Output directory for generated MCP resources.\n\nRaises:\n click.UsageError:\n If required options are missing or conflicting."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.serve",
|
|
||||||
"signature": "serve(mcp: bool, mkdocs: bool, lib: bool, api: bool, wiki: bool, module: str | None, mkdocs_yml: Path, out_dir: Path) -> None",
|
|
||||||
"docstring": "Serve generated documentation locally.\n\nDepending on the selected mode, this command starts either:\n\n- A MkDocs development server for browsing a site, or\n- An MCP server exposing structured documentation resources\n\nThe kind flags (`--lib`, `--api`, `--wiki`) select the generated\nper-kind config (`docs/mkdocs.{kind}.yml`); `--mkdocs` serves the config\npassed via `--mkdocs-yml`.\n\nArgs:\n mcp (bool):\n Serve documentation using the MCP server.\n\n mkdocs (bool):\n Serve the MkDocs development site from ``--mkdocs-yml``.\n\n lib (bool):\n Serve the lib MkDocs site.\n\n api (bool):\n Serve the API MkDocs site.\n\n wiki (bool):\n Serve the wiki MkDocs site.\n\n module (str | None):\n Python module import path to serve via MCP.\n\n mkdocs_yml (Path):\n Path to the MkDocs configuration file.\n\n out_dir (Path):\n Root directory containing MCP documentation resources.\n\nRaises:\n click.UsageError:\n If invalid or conflicting options are provided."
|
|
||||||
},
|
|
||||||
"tree": {
|
|
||||||
"name": "tree",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.commands.tree",
|
|
||||||
"signature": "tree(module: str, project_name: str | None) -> None",
|
|
||||||
"docstring": "Display the documentation object tree for a module.\n\nThis command introspects the specified module and prints a\nhierarchical representation of the discovered documentation\nobjects, including modules, classes, functions, and members.\n\nArgs:\n module (str):\n Python module import path to introspect.\n\n project_name (str | None):\n Optional name to display as the project root."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mcp_utils": {
|
|
||||||
"name": "mcp_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.mcp_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MCP in the doc-forge CLI.\n\n---\n\nNotes:\n - `generate_resources` produces the bundle consumed by `MCPServer`:\n `index.json`, `nav.json`, and per-module resources under `modules/`.\n - Resource URIs use the `docs://` scheme: `docs://index`, `docs://nav`,\n and `docs://modules/{module}`.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mcp_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MCPRenderer": {
|
|
||||||
"name": "MCPRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that generates MCP-compatible documentation resources.\n\nThis renderer converts doc-forge project models into structured JSON\nresources suitable for consumption by systems implementing the Model\nContext Protocol (MCP).",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path)",
|
|
||||||
"docstring": "Generate MCP documentation resources for a project.\n\nThe renderer serializes each module into a JSON resource and produces\nsupporting metadata files such as `nav.json` and `index.json`.\n\nArgs:\n project (Project):\n Documentation project model to render.\n\n out_dir (Path):\n Directory where MCP resources will be written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MCPServer": {
|
|
||||||
"name": "MCPServer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer",
|
|
||||||
"signature": "MCPServer(mcp_root: Path, name: str)",
|
|
||||||
"docstring": "MCP server for serving a pre-generated documentation bundle.\n\nThe server exposes documentation resources and diagnostic tools through\nMCP endpoints backed by JSON files generated by the MCP renderer.\n\nAttributes:\n mcp_root (Path):\n Directory containing the generated MCP documentation bundle.\n\n app (FastMCP):\n Underlying FastMCP application instance that registers resources\n and tools.",
|
|
||||||
"members": {
|
|
||||||
"mcp_root": {
|
|
||||||
"name": "mcp_root",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer.mcp_root",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"app": {
|
|
||||||
"name": "app",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer.app",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"run": {
|
|
||||||
"name": "run",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer.run",
|
|
||||||
"signature": "run(transport: Literal['stdio', 'sse', 'streamable-http'] = 'streamable-http')",
|
|
||||||
"docstring": "Start the MCP server.\n\nArgs:\n transport (Literal[\"stdio\", \"sse\", \"streamable-http\"]):\n Transport mechanism used by the MCP server. Supported options\n include `stdio`, `sse`, and `streamable-http`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_resources": {
|
|
||||||
"name": "generate_resources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.generate_resources",
|
|
||||||
"signature": "generate_resources(module: str, project_name: str | None, out_dir: Path) -> None",
|
|
||||||
"docstring": "Generate MCP documentation resources from a Python module.\n\nThe function performs project introspection, builds the internal\ndocumentation model, and renders MCP-compatible JSON resources\nto the specified output directory.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n project_name (str | None):\n Optional override for the project name used in generated\n documentation metadata.\n\n out_dir (Path):\n Directory where MCP resources (index.json, nav.json, and module data)\n will be written."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.serve",
|
|
||||||
"signature": "serve(module: str, mcp_root: Path) -> None",
|
|
||||||
"docstring": "Start an MCP server for a pre-generated documentation bundle.\n\nThe server exposes documentation resources such as project metadata,\nnavigation structure, and module documentation through MCP endpoints.\n\nArgs:\n module (str):\n Python module import path used to identify the served\n documentation instance.\n\n mcp_root (Path):\n Path to the directory containing the MCP documentation\n bundle (index.json, nav.json, and modules/).\n\nRaises:\n click.ClickException:\n If the MCP documentation bundle is missing required files or directories."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mkdocs_utils": {
|
|
||||||
"name": "mkdocs_utils",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.cli.mkdocs_utils",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MkDocs in the doc-forge CLI.\n\n---\n\nNotes:\n - A separate `mkdocs.{kind}.yml` configuration and build is emitted per\n enabled kind (lib, api, wiki), each scoped to its own `docs_dir` and\n written into its own `site_dir` (`site/lib`, `site/api`, `site/wiki`).\n - Navigation blocks are re-rooted per kind: the wiki navigation drops its\n leading `wiki/` scope and the resolved nav spec drops its `lib/` scope.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav)",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build_wiki_nav": {
|
|
||||||
"name": "build_wiki_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_wiki_nav",
|
|
||||||
"signature": "build_wiki_nav(wiki_dir: Path)",
|
|
||||||
"docstring": "Derive an MkDocs navigation block from a wiki directory.\n\nReturned paths are relative to the parent of ``wiki_dir`` and carry the\nwiki directory name as their leading component (for example\n``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes\nthe result directly usable in an MkDocs ``nav`` block with\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries compatible with the MkDocs ``nav`` configuration.\n The list is empty if the wiki contains no Markdown files.\n\nRaises:\n FileNotFoundError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path)",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
},
|
|
||||||
"MkDocsRenderer": {
|
|
||||||
"name": "MkDocsRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that produces Markdown documentation for MkDocs.\n\nGenerated pages use mkdocstrings directives to reference Python modules,\nallowing MkDocs to render API documentation dynamically.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path, module_is_source: bool | None = None)",
|
|
||||||
"docstring": "Generate Markdown documentation files for a project.\n\nThis method renders a documentation structure from the provided\nproject model and writes the resulting Markdown files to the\nspecified output directory.\n\nArgs:\n project (Project):\n Project model containing modules to document.\n\n out_dir (Path):\n Directory where generated Markdown files will be written.\n\n module_is_source (bool | None):\n If True, treat the specified module as the documentation root\n rather than nesting it inside a folder."
|
|
||||||
},
|
|
||||||
"generate_readme": {
|
|
||||||
"name": "generate_readme",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer.generate_readme",
|
|
||||||
"signature": "generate_readme(project: Project, docs_dir: Path, module_is_source: bool | None = None, readme_dir: Path | None = None)",
|
|
||||||
"docstring": "Generate a `README.md` file from the root module docstring.\n\nNotes:\n - If `module_is_source` is True, `README.md` is written to the\n project root directory.\n - If False, README generation is currently not implemented.\n\nArgs:\n project (Project):\n Project model containing documentation metadata.\n\n docs_dir (Path):\n Directory containing generated documentation sources.\n\n module_is_source (bool | None):\n Whether the module is treated as the project source root.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written.\n Defaults to the parent of `docs_dir`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.generate_sources",
|
|
||||||
"signature": "generate_sources(module: str, docs_dir: Path, project_name: str | None = None, module_is_source: bool | None = None, readme_dir: Path | None = None) -> None",
|
|
||||||
"docstring": "Generate MkDocs Markdown sources for a Python module.\n\nThis function introspects the specified module, builds the internal\ndocumentation model, and renders Markdown documentation files for\nuse with MkDocs.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n docs_dir (Path):\n Directory where the generated Markdown files will be written.\n\n project_name (str | None):\n Optional override for the project name used in documentation metadata.\n\n module_is_source (bool | None):\n If True, treat the specified module directory as the project root\n rather than a nested module.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written. If not\n provided, defaults to the parent of ``docs_dir``."
|
|
||||||
},
|
|
||||||
"build_lib_nav": {
|
|
||||||
"name": "build_lib_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_lib_nav",
|
|
||||||
"signature": "build_lib_nav(nav_file: Path, docs_root: Path) -> tuple[list[dict[str, Any]], dict[str, str] | None]",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a lib site.\n\nThe navigation specification is resolved against the shared documentation\nroot and every resulting path is re-rooted relative to the ``lib``\nsubdirectory by stripping its leading ``lib/`` scope component.\n\nArgs:\n nav_file (Path):\n Path to the `docforge.nav.yml` navigation specification.\n\n docs_root (Path):\n Shared documentation root containing the ``lib`` sources.\n\nReturns:\n tuple[list[dict[str, Any]], dict[str, str] | None]:\n The re-rooted navigation block and the optional theme icon\n mapping from the specification.\n\nRaises:\n click.FileError:\n If the navigation specification cannot be found."
|
|
||||||
},
|
|
||||||
"build_wiki_nav_block": {
|
|
||||||
"name": "build_wiki_nav_block",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_wiki_nav_block",
|
|
||||||
"signature": "build_wiki_nav_block(wiki_dir: Path) -> list[dict[str, Any]]",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a wiki site.\n\nThe wiki navigation derived from the wiki file structure is re-rooted\nrelative to the wiki directory itself by stripping the leading ``wiki/``\nscope component.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries relative to the wiki directory.\n\nRaises:\n click.FileError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_spec_icon": {
|
|
||||||
"name": "load_spec_icon",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.load_spec_icon",
|
|
||||||
"signature": "load_spec_icon(nav_file: Path) -> dict[str, str] | None",
|
|
||||||
"docstring": "Load the theme icon mapping from a navigation specification.\n\nArgs:\n nav_file (Path):\n Path to the navigation specification file.\n\nReturns:\n dict[str, str] | None:\n The icon mapping, or ``None`` when the specification file is\n absent or cannot be parsed."
|
|
||||||
},
|
|
||||||
"generate_site_config": {
|
|
||||||
"name": "generate_site_config",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.generate_site_config",
|
|
||||||
"signature": "generate_site_config(kind: str, kind_root: Path, nav_block: list[dict[str, Any]], out: Path, site_name: str, docs_dir: str, site_dir: str, template: Path | None = None, site_description: str | None = None, site_author: str | None = None, theme_icon: dict[str, str] | None = None) -> None",
|
|
||||||
"docstring": "Generate a per-kind `mkdocs.{kind}.yml` configuration file.\n\nThe configuration is created by merging the shared ``mkdocs.common.yml``\ntemplate with the fragment contributed by the kind (``lib``, ``api``, or\n``wiki``). Both ``docs_dir`` and ``site_dir`` are written relative to the\nconfiguration file's directory: the kind's sources when expressed as a\nsibling path (for example ``lib``) and the per-kind site output (for\nexample ``../site/lib``).\n\nArgs:\n kind (str):\n Documentation kind, one of ``lib``, ``api``, or ``wiki``.\n\n kind_root (Path):\n Directory scoped to the kind (for example ``docs/lib``) that\n serves as the MkDocs ``docs_dir``.\n\n nav_block (list[dict[str, Any]]):\n Re-rooted navigation entries for the kind's site.\n\n out (Path):\n Destination path where the generated ``mkdocs.{kind}.yml`` file\n is written.\n\n site_name (str):\n Display name for the generated documentation site.\n\n docs_dir (str):\n MkDocs ``docs_dir`` value, relative to the configuration\n file's directory.\n\n site_dir (str):\n MkDocs ``site_dir`` value, relative to the configuration\n file's directory.\n\n template (Path | None):\n Optional path to a fully custom MkDocs configuration template\n that replaces the built-in templates entirely.\n\n site_description (str | None):\n Optional site description written into the configuration.\n\n site_author (str | None):\n Optional site author written into the configuration.\n\n theme_icon (dict[str, str] | None):\n Optional mapping of theme icon entries injected as\n ``theme.icon``."
|
|
||||||
},
|
|
||||||
"build_configs": {
|
|
||||||
"name": "build_configs",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_configs",
|
|
||||||
"signature": "build_configs(yml_paths: Iterable[Path]) -> None",
|
|
||||||
"docstring": "Build the MkDocs documentation site for every given configuration.\n\nEach configuration file is loaded and built in turn, producing the\nper-kind static sites (``site/lib``, ``site/api``, ``site/wiki``).\n\nArgs:\n yml_paths (Iterable[Path]):\n Configuration files to build, in order.\n\nRaises:\n click.ClickException:\n If a configuration file does not exist."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.serve",
|
|
||||||
"signature": "serve(mkdocs_yml: Path) -> None",
|
|
||||||
"docstring": "Start an MkDocs development server with live reload.\n\nThe server watches documentation files and automatically reloads\nthe site when changes are detected.\n\nArgs:\n mkdocs_yml (Path):\n Path to the `mkdocs.yml` configuration file.\n\nRaises:\n click.ClickException:\n If the configuration file does not exist."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.cli.main",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.cli.main",
|
|
||||||
"docstring": "# Summary\n\nCommand-line entry point for the doc-forge CLI.\n\nThis module exposes the executable entry point that initializes the\nClick command group defined in `docforge.cli.commands`.",
|
|
||||||
"objects": {
|
|
||||||
"cli": {
|
|
||||||
"name": "cli",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.main.cli",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"main": {
|
|
||||||
"name": "main",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.main.main",
|
|
||||||
"signature": "main() -> None",
|
|
||||||
"docstring": "Run the doc-forge command-line interface.\n\nThis function initializes and executes the Click CLI application.\nIt is used as the console entry point when invoking `doc-forge`\nfrom the command line."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.cli.mcp_utils",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.cli.mcp_utils",
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MCP in the doc-forge CLI.\n\n---\n\nNotes:\n - `generate_resources` produces the bundle consumed by `MCPServer`:\n `index.json`, `nav.json`, and per-module resources under `modules/`.\n - Resource URIs use the `docs://` scheme: `docs://index`, `docs://nav`,\n and `docs://modules/{module}`.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mcp_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MCPRenderer": {
|
|
||||||
"name": "MCPRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that generates MCP-compatible documentation resources.\n\nThis renderer converts doc-forge project models into structured JSON\nresources suitable for consumption by systems implementing the Model\nContext Protocol (MCP).",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path)",
|
|
||||||
"docstring": "Generate MCP documentation resources for a project.\n\nThe renderer serializes each module into a JSON resource and produces\nsupporting metadata files such as `nav.json` and `index.json`.\n\nArgs:\n project (Project):\n Documentation project model to render.\n\n out_dir (Path):\n Directory where MCP resources will be written."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MCPServer": {
|
|
||||||
"name": "MCPServer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer",
|
|
||||||
"signature": "MCPServer(mcp_root: Path, name: str)",
|
|
||||||
"docstring": "MCP server for serving a pre-generated documentation bundle.\n\nThe server exposes documentation resources and diagnostic tools through\nMCP endpoints backed by JSON files generated by the MCP renderer.\n\nAttributes:\n mcp_root (Path):\n Directory containing the generated MCP documentation bundle.\n\n app (FastMCP):\n Underlying FastMCP application instance that registers resources\n and tools.",
|
|
||||||
"members": {
|
|
||||||
"mcp_root": {
|
|
||||||
"name": "mcp_root",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer.mcp_root",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"app": {
|
|
||||||
"name": "app",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer.app",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"run": {
|
|
||||||
"name": "run",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.MCPServer.run",
|
|
||||||
"signature": "run(transport: Literal['stdio', 'sse', 'streamable-http'] = 'streamable-http')",
|
|
||||||
"docstring": "Start the MCP server.\n\nArgs:\n transport (Literal[\"stdio\", \"sse\", \"streamable-http\"]):\n Transport mechanism used by the MCP server. Supported options\n include `stdio`, `sse`, and `streamable-http`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_resources": {
|
|
||||||
"name": "generate_resources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.generate_resources",
|
|
||||||
"signature": "generate_resources(module: str, project_name: str | None, out_dir: Path) -> None",
|
|
||||||
"docstring": "Generate MCP documentation resources from a Python module.\n\nThe function performs project introspection, builds the internal\ndocumentation model, and renders MCP-compatible JSON resources\nto the specified output directory.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n project_name (str | None):\n Optional override for the project name used in generated\n documentation metadata.\n\n out_dir (Path):\n Directory where MCP resources (index.json, nav.json, and module data)\n will be written."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mcp_utils.serve",
|
|
||||||
"signature": "serve(module: str, mcp_root: Path) -> None",
|
|
||||||
"docstring": "Start an MCP server for a pre-generated documentation bundle.\n\nThe server exposes documentation resources such as project metadata,\nnavigation structure, and module documentation through MCP endpoints.\n\nArgs:\n module (str):\n Python module import path used to identify the served\n documentation instance.\n\n mcp_root (Path):\n Path to the directory containing the MCP documentation\n bundle (index.json, nav.json, and modules/).\n\nRaises:\n click.ClickException:\n If the MCP documentation bundle is missing required files or directories."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.cli.mkdocs_utils",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.cli.mkdocs_utils",
|
|
||||||
"docstring": "# Summary\n\nUtilities for working with MkDocs in the doc-forge CLI.\n\n---\n\nNotes:\n - A separate `mkdocs.{kind}.yml` configuration and build is emitted per\n enabled kind (lib, api, wiki), each scoped to its own `docs_dir` and\n written into its own `site_dir` (`site/lib`, `site/api`, `site/wiki`).\n - Navigation blocks are re-rooted per kind: the wiki navigation drops its\n leading `wiki/` scope and the resolved nav spec drops its `lib/` scope.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav)",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build_wiki_nav": {
|
|
||||||
"name": "build_wiki_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_wiki_nav",
|
|
||||||
"signature": "build_wiki_nav(wiki_dir: Path)",
|
|
||||||
"docstring": "Derive an MkDocs navigation block from a wiki directory.\n\nReturned paths are relative to the parent of ``wiki_dir`` and carry the\nwiki directory name as their leading component (for example\n``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes\nthe result directly usable in an MkDocs ``nav`` block with\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries compatible with the MkDocs ``nav`` configuration.\n The list is empty if the wiki contains no Markdown files.\n\nRaises:\n FileNotFoundError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path)",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
},
|
|
||||||
"MkDocsRenderer": {
|
|
||||||
"name": "MkDocsRenderer",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Renderer that produces Markdown documentation for MkDocs.\n\nGenerated pages use mkdocstrings directives to reference Python modules,\nallowing MkDocs to render API documentation dynamically.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer.generate_sources",
|
|
||||||
"signature": "generate_sources(project: Project, out_dir: Path, module_is_source: bool | None = None)",
|
|
||||||
"docstring": "Generate Markdown documentation files for a project.\n\nThis method renders a documentation structure from the provided\nproject model and writes the resulting Markdown files to the\nspecified output directory.\n\nArgs:\n project (Project):\n Project model containing modules to document.\n\n out_dir (Path):\n Directory where generated Markdown files will be written.\n\n module_is_source (bool | None):\n If True, treat the specified module as the documentation root\n rather than nesting it inside a folder."
|
|
||||||
},
|
|
||||||
"generate_readme": {
|
|
||||||
"name": "generate_readme",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.MkDocsRenderer.generate_readme",
|
|
||||||
"signature": "generate_readme(project: Project, docs_dir: Path, module_is_source: bool | None = None, readme_dir: Path | None = None)",
|
|
||||||
"docstring": "Generate a `README.md` file from the root module docstring.\n\nNotes:\n - If `module_is_source` is True, `README.md` is written to the\n project root directory.\n - If False, README generation is currently not implemented.\n\nArgs:\n project (Project):\n Project model containing documentation metadata.\n\n docs_dir (Path):\n Directory containing generated documentation sources.\n\n module_is_source (bool | None):\n Whether the module is treated as the project source root.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written.\n Defaults to the parent of `docs_dir`."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"generate_sources": {
|
|
||||||
"name": "generate_sources",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.generate_sources",
|
|
||||||
"signature": "generate_sources(module: str, docs_dir: Path, project_name: str | None = None, module_is_source: bool | None = None, readme_dir: Path | None = None) -> None",
|
|
||||||
"docstring": "Generate MkDocs Markdown sources for a Python module.\n\nThis function introspects the specified module, builds the internal\ndocumentation model, and renders Markdown documentation files for\nuse with MkDocs.\n\nArgs:\n module (str):\n Python module import path used as the entry point for\n documentation generation.\n\n docs_dir (Path):\n Directory where the generated Markdown files will be written.\n\n project_name (str | None):\n Optional override for the project name used in documentation metadata.\n\n module_is_source (bool | None):\n If True, treat the specified module directory as the project root\n rather than a nested module.\n\n readme_dir (Path | None):\n Directory where the generated README.md should be written. If not\n provided, defaults to the parent of ``docs_dir``."
|
|
||||||
},
|
|
||||||
"build_lib_nav": {
|
|
||||||
"name": "build_lib_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_lib_nav",
|
|
||||||
"signature": "build_lib_nav(nav_file: Path, docs_root: Path) -> tuple[list[dict[str, Any]], dict[str, str] | None]",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a lib site.\n\nThe navigation specification is resolved against the shared documentation\nroot and every resulting path is re-rooted relative to the ``lib``\nsubdirectory by stripping its leading ``lib/`` scope component.\n\nArgs:\n nav_file (Path):\n Path to the `docforge.nav.yml` navigation specification.\n\n docs_root (Path):\n Shared documentation root containing the ``lib`` sources.\n\nReturns:\n tuple[list[dict[str, Any]], dict[str, str] | None]:\n The re-rooted navigation block and the optional theme icon\n mapping from the specification.\n\nRaises:\n click.FileError:\n If the navigation specification cannot be found."
|
|
||||||
},
|
|
||||||
"build_wiki_nav_block": {
|
|
||||||
"name": "build_wiki_nav_block",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_wiki_nav_block",
|
|
||||||
"signature": "build_wiki_nav_block(wiki_dir: Path) -> list[dict[str, Any]]",
|
|
||||||
"docstring": "Build the re-rooted navigation block for a wiki site.\n\nThe wiki navigation derived from the wiki file structure is re-rooted\nrelative to the wiki directory itself by stripping the leading ``wiki/``\nscope component.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries relative to the wiki directory.\n\nRaises:\n click.FileError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"load_spec_icon": {
|
|
||||||
"name": "load_spec_icon",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.load_spec_icon",
|
|
||||||
"signature": "load_spec_icon(nav_file: Path) -> dict[str, str] | None",
|
|
||||||
"docstring": "Load the theme icon mapping from a navigation specification.\n\nArgs:\n nav_file (Path):\n Path to the navigation specification file.\n\nReturns:\n dict[str, str] | None:\n The icon mapping, or ``None`` when the specification file is\n absent or cannot be parsed."
|
|
||||||
},
|
|
||||||
"generate_site_config": {
|
|
||||||
"name": "generate_site_config",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.generate_site_config",
|
|
||||||
"signature": "generate_site_config(kind: str, kind_root: Path, nav_block: list[dict[str, Any]], out: Path, site_name: str, docs_dir: str, site_dir: str, template: Path | None = None, site_description: str | None = None, site_author: str | None = None, theme_icon: dict[str, str] | None = None) -> None",
|
|
||||||
"docstring": "Generate a per-kind `mkdocs.{kind}.yml` configuration file.\n\nThe configuration is created by merging the shared ``mkdocs.common.yml``\ntemplate with the fragment contributed by the kind (``lib``, ``api``, or\n``wiki``). Both ``docs_dir`` and ``site_dir`` are written relative to the\nconfiguration file's directory: the kind's sources when expressed as a\nsibling path (for example ``lib``) and the per-kind site output (for\nexample ``../site/lib``).\n\nArgs:\n kind (str):\n Documentation kind, one of ``lib``, ``api``, or ``wiki``.\n\n kind_root (Path):\n Directory scoped to the kind (for example ``docs/lib``) that\n serves as the MkDocs ``docs_dir``.\n\n nav_block (list[dict[str, Any]]):\n Re-rooted navigation entries for the kind's site.\n\n out (Path):\n Destination path where the generated ``mkdocs.{kind}.yml`` file\n is written.\n\n site_name (str):\n Display name for the generated documentation site.\n\n docs_dir (str):\n MkDocs ``docs_dir`` value, relative to the configuration\n file's directory.\n\n site_dir (str):\n MkDocs ``site_dir`` value, relative to the configuration\n file's directory.\n\n template (Path | None):\n Optional path to a fully custom MkDocs configuration template\n that replaces the built-in templates entirely.\n\n site_description (str | None):\n Optional site description written into the configuration.\n\n site_author (str | None):\n Optional site author written into the configuration.\n\n theme_icon (dict[str, str] | None):\n Optional mapping of theme icon entries injected as\n ``theme.icon``."
|
|
||||||
},
|
|
||||||
"build_configs": {
|
|
||||||
"name": "build_configs",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.build_configs",
|
|
||||||
"signature": "build_configs(yml_paths: Iterable[Path]) -> None",
|
|
||||||
"docstring": "Build the MkDocs documentation site for every given configuration.\n\nEach configuration file is loaded and built in turn, producing the\nper-kind static sites (``site/lib``, ``site/api``, ``site/wiki``).\n\nArgs:\n yml_paths (Iterable[Path]):\n Configuration files to build, in order.\n\nRaises:\n click.ClickException:\n If a configuration file does not exist."
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"name": "serve",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.cli.mkdocs_utils.serve",
|
|
||||||
"signature": "serve(mkdocs_yml: Path) -> None",
|
|
||||||
"docstring": "Start an MkDocs development server with live reload.\n\nThe server watches documentation files and automatically reloads\nthe site when changes are detected.\n\nArgs:\n mkdocs_yml (Path):\n Path to the `mkdocs.yml` configuration file.\n\nRaises:\n click.ClickException:\n If the configuration file does not exist."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,220 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.loaders.griffe_loader",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.loaders.griffe_loader",
|
|
||||||
"docstring": "# Summary\n\nUtilities for loading and introspecting Python modules using Griffe.\n\nThis module provides the `GriffeLoader` class and helper utilities used to\ndiscover Python modules, introspect their structure, and convert the results\ninto doc-forge documentation models.\n\n---\n\nNotes:\n - All analysis is static; analyzed modules are never executed.\n - Private members (names starting with `_`) are skipped during conversion.\n - Imported aliases that cannot be resolved (stdlib/third-party names) are\n skipped; aliases that resolve within the documented project are kept.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject)",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.get_object",
|
|
||||||
"signature": "get_object(name: str)",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects()",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Project": {
|
|
||||||
"name": "Project",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project",
|
|
||||||
"signature": "Project(name: str)",
|
|
||||||
"docstring": "Representation of a documentation project.\n\nA `Project` serves as the root container for all modules discovered during\nintrospection. Each module is stored by its dotted import path.\n\nAttributes:\n name (str):\n Name of the project.\n\n modules (dict[str, Module]):\n Mapping of module paths to `Module` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"modules": {
|
|
||||||
"name": "modules",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.modules",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_module": {
|
|
||||||
"name": "add_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.add_module",
|
|
||||||
"signature": "add_module(module: Module)",
|
|
||||||
"docstring": "Register a module in the project.\n\nArgs:\n module (Module):\n Module instance to add to the project."
|
|
||||||
},
|
|
||||||
"get_module": {
|
|
||||||
"name": "get_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.get_module",
|
|
||||||
"signature": "get_module(path: str)",
|
|
||||||
"docstring": "Retrieve a module by its dotted path.\n\nArgs:\n path (str):\n Fully qualified dotted module path (for example `pkg.module`).\n\nReturns:\n Module:\n The corresponding `Module` instance.\n\nRaises:\n KeyError:\n If the module does not exist in the project."
|
|
||||||
},
|
|
||||||
"get_all_modules": {
|
|
||||||
"name": "get_all_modules",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.get_all_modules",
|
|
||||||
"signature": "get_all_modules()",
|
|
||||||
"docstring": "Return all modules contained in the project.\n\nReturns:\n Iterable[Module]:\n An iterable of `Module` instances."
|
|
||||||
},
|
|
||||||
"get_module_list": {
|
|
||||||
"name": "get_module_list",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.get_module_list",
|
|
||||||
"signature": "get_module_list()",
|
|
||||||
"docstring": "Return the list of module import paths.\n\nReturns:\n list[str]:\n A list containing the dotted paths of all modules in the project."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"logger": {
|
|
||||||
"name": "logger",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.logger",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None) -> list[str]",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None) -> Project",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str) -> Module",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,259 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.loaders",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.loaders",
|
|
||||||
"docstring": "# Summary\n\nLoader layer for doc-forge.\n\nThe `docforge.loaders` package is responsible for discovering Python modules\nand extracting documentation data using static analysis.\n\n---\n\n# Overview\n\nThis layer converts Python source code into an intermediate documentation\nmodel used by doc-forge. It performs module discovery, introspection, and\ninitial filtering before the data is passed to the core documentation models.\n\nCore capabilities include:\n\n- **Module discovery** – Locate Python modules and packages within a project.\n- **Static introspection** – Parse docstrings, signatures, and object\n hierarchies using the `griffe` library without executing the code.\n- **Public API filtering** – Exclude private members (names prefixed with\n `_`) to produce clean public documentation structures.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None)",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str)",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None)",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"griffe_loader": {
|
|
||||||
"name": "griffe_loader",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.loaders.griffe_loader",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nUtilities for loading and introspecting Python modules using Griffe.\n\nThis module provides the `GriffeLoader` class and helper utilities used to\ndiscover Python modules, introspect their structure, and convert the results\ninto doc-forge documentation models.\n\n---\n\nNotes:\n - All analysis is static; analyzed modules are never executed.\n - Private members (names starting with `_`) are skipped during conversion.\n - Imported aliases that cannot be resolved (stdlib/third-party names) are\n skipped; aliases that resolve within the documented project are kept.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject)",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.get_object",
|
|
||||||
"signature": "get_object(name: str)",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects()",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Project": {
|
|
||||||
"name": "Project",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project",
|
|
||||||
"signature": "Project(name: str)",
|
|
||||||
"docstring": "Representation of a documentation project.\n\nA `Project` serves as the root container for all modules discovered during\nintrospection. Each module is stored by its dotted import path.\n\nAttributes:\n name (str):\n Name of the project.\n\n modules (dict[str, Module]):\n Mapping of module paths to `Module` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"modules": {
|
|
||||||
"name": "modules",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.modules",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_module": {
|
|
||||||
"name": "add_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.add_module",
|
|
||||||
"signature": "add_module(module: Module)",
|
|
||||||
"docstring": "Register a module in the project.\n\nArgs:\n module (Module):\n Module instance to add to the project."
|
|
||||||
},
|
|
||||||
"get_module": {
|
|
||||||
"name": "get_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.get_module",
|
|
||||||
"signature": "get_module(path: str)",
|
|
||||||
"docstring": "Retrieve a module by its dotted path.\n\nArgs:\n path (str):\n Fully qualified dotted module path (for example `pkg.module`).\n\nReturns:\n Module:\n The corresponding `Module` instance.\n\nRaises:\n KeyError:\n If the module does not exist in the project."
|
|
||||||
},
|
|
||||||
"get_all_modules": {
|
|
||||||
"name": "get_all_modules",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.get_all_modules",
|
|
||||||
"signature": "get_all_modules()",
|
|
||||||
"docstring": "Return all modules contained in the project.\n\nReturns:\n Iterable[Module]:\n An iterable of `Module` instances."
|
|
||||||
},
|
|
||||||
"get_module_list": {
|
|
||||||
"name": "get_module_list",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.Project.get_module_list",
|
|
||||||
"signature": "get_module_list()",
|
|
||||||
"docstring": "Return the list of module import paths.\n\nReturns:\n list[str]:\n A list containing the dotted paths of all modules in the project."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"logger": {
|
|
||||||
"name": "logger",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.loaders.griffe_loader.logger",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"discover_module_paths": {
|
|
||||||
"name": "discover_module_paths",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.discover_module_paths",
|
|
||||||
"signature": "discover_module_paths(module_name: str, project_root: Path | None = None) -> list[str]",
|
|
||||||
"docstring": "Discover Python modules within a package directory.\n\nThe function scans the filesystem for `.py` files inside the specified\npackage and converts them into dotted module import paths.\n\nDiscovery rules:\n\n- Directories containing `__init__.py` are treated as packages.\n- Each `.py` file is treated as a module.\n- Results are returned as dotted import paths.\n\nArgs:\n module_name (str):\n Top-level package name to discover modules from.\n\n project_root (Path | None):\n Root directory used to resolve module paths. If not provided, the\n current working directory is used.\n\nReturns:\n list[str]:\n A sorted list of unique dotted module import paths.\n\nRaises:\n FileNotFoundError:\n If the specified package directory does not exist."
|
|
||||||
},
|
|
||||||
"GriffeLoader": {
|
|
||||||
"name": "GriffeLoader",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.loaders.griffe_loader.GriffeLoader",
|
|
||||||
"signature": "GriffeLoader()",
|
|
||||||
"docstring": "Load Python modules using Griffe and convert them into doc-forge models.\n\nThis loader uses the Griffe introspection engine to analyze Python source\ncode and transform the extracted information into `Project`, `Module`,\nand `DocObject` instances used by doc-forge.\n\nAttributes:\n _loader (_GriffeLoader):\n Internal Griffe loader with dedicated module and line collections.",
|
|
||||||
"members": {
|
|
||||||
"load_project": {
|
|
||||||
"name": "load_project",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.GriffeLoader.load_project",
|
|
||||||
"signature": "load_project(module_paths: list[str], project_name: str | None = None, skip_import_errors: bool | None = None) -> Project",
|
|
||||||
"docstring": "Load multiple modules and assemble them into a Project model.\n\nEach module path is introspected and converted into a `Module`\ninstance. All modules are then aggregated into a single `Project`\nobject.\n\nArgs:\n module_paths (list[str]):\n List of dotted module import paths to load.\n\n project_name (str | None):\n Optional override for the project name. Defaults to the top-level\n name of the first module.\n\n skip_import_errors (bool | None):\n If True, modules that fail to load will be skipped instead of raising an error.\n\nReturns:\n Project:\n A populated `Project` instance containing the loaded modules.\n\nRaises:\n ValueError:\n If no module paths are provided.\n\n ImportError:\n If a module fails to load and `skip_import_errors` is False."
|
|
||||||
},
|
|
||||||
"load_module": {
|
|
||||||
"name": "load_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.loaders.griffe_loader.GriffeLoader.load_module",
|
|
||||||
"signature": "load_module(path: str) -> Module",
|
|
||||||
"docstring": "Load and convert a single Python module.\n\nThe module is introspected using Griffe and then transformed into\na doc-forge `Module` model.\n\nArgs:\n path (str):\n Dotted import path of the module.\n\nReturns:\n Module:\n A populated `Module` instance.\n\nRaises:\n ImportError:\n If the module cannot be loaded by Griffe.\n\n KeyError:\n If the loaded module is missing from the module collection.\n\nExample:\n Load a single module:\n\n ```python\n loader = GriffeLoader()\n module = loader.load_module(\"mypackage.submodule\")\n ```"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,507 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.models",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.models",
|
|
||||||
"docstring": "# Summary\n\nModel layer for doc-forge.\n\nThe `docforge.models` package defines the core data structures used to\nrepresent Python source code as a structured documentation model.\n\n---\n\n# Overview\n\nThe model layer forms the central intermediate representation used throughout\ndoc-forge. Python modules and objects discovered during introspection are\nconverted into a hierarchy of documentation models that can later be rendered\ninto different documentation formats.\n\nKey components:\n\n- **Project** – Root container representing an entire documented codebase.\n- **Module** – Representation of a Python module or package containing\n documented members.\n- **DocObject** – Recursive structure representing Python objects such as\n classes, functions, methods, and attributes.\n\nThese models are intentionally **renderer-agnostic**, allowing the same\ndocumentation structure to be transformed into multiple output formats\n(e.g., MkDocs, MCP, or other renderers).\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"Project": {
|
|
||||||
"name": "Project",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.Project",
|
|
||||||
"signature": "Project(name: str)",
|
|
||||||
"docstring": "Representation of a documentation project.\n\nA `Project` serves as the root container for all modules discovered during\nintrospection. Each module is stored by its dotted import path.\n\nAttributes:\n name (str):\n Name of the project.\n\n modules (dict[str, Module]):\n Mapping of module paths to `Module` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.Project.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"modules": {
|
|
||||||
"name": "modules",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.Project.modules",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_module": {
|
|
||||||
"name": "add_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Project.add_module",
|
|
||||||
"signature": "add_module(module: Module)",
|
|
||||||
"docstring": "Register a module in the project.\n\nArgs:\n module (Module):\n Module instance to add to the project."
|
|
||||||
},
|
|
||||||
"get_module": {
|
|
||||||
"name": "get_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Project.get_module",
|
|
||||||
"signature": "get_module(path: str)",
|
|
||||||
"docstring": "Retrieve a module by its dotted path.\n\nArgs:\n path (str):\n Fully qualified dotted module path (for example `pkg.module`).\n\nReturns:\n Module:\n The corresponding `Module` instance.\n\nRaises:\n KeyError:\n If the module does not exist in the project."
|
|
||||||
},
|
|
||||||
"get_all_modules": {
|
|
||||||
"name": "get_all_modules",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Project.get_all_modules",
|
|
||||||
"signature": "get_all_modules()",
|
|
||||||
"docstring": "Return all modules contained in the project.\n\nReturns:\n Iterable[Module]:\n An iterable of `Module` instances."
|
|
||||||
},
|
|
||||||
"get_module_list": {
|
|
||||||
"name": "get_module_list",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Project.get_module_list",
|
|
||||||
"signature": "get_module_list()",
|
|
||||||
"docstring": "Return the list of module import paths.\n\nReturns:\n list[str]:\n A list containing the dotted paths of all modules in the project."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject)",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Module.get_object",
|
|
||||||
"signature": "get_object(name: str)",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects()",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"module": {
|
|
||||||
"name": "module",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.models.module",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nDocumentation model representing a Python module or package.\n\nThis module defines the `Module` class used in the doc-forge documentation\nmodel. A `Module` acts as a container for top-level documented objects\n(classes, functions, variables, and other members) discovered during\nintrospection.\n\n---\n\nNotes:\n - Only public members are stored; private names are filtered by the loader.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.module.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.module.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject) -> None",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.Module.get_object",
|
|
||||||
"signature": "get_object(name: str) -> DocObject",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects() -> Iterable[DocObject]",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"object": {
|
|
||||||
"name": "object",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.models.object",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nDocumentation model representing individual Python objects.\n\nThis module defines the `DocObject` class, the fundamental recursive unit of\nthe doc-forge documentation model. Each `DocObject` represents a Python\nentity such as a class, function, method, or attribute, and may contain nested\nmembers that form a hierarchical documentation structure.\n\n---\n\nNotes:\n - `DocObject` instances form a tree mirroring the Python import hierarchy.\n - Objects are renderer-agnostic and may be consumed by any renderer.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.object.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.object.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject) -> None",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.object.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str) -> DocObject",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.object.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members() -> Iterable[DocObject]",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"project": {
|
|
||||||
"name": "project",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.models.project",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nDocumentation model representing a project.\n\nThis module defines the `Project` class, the top-level container used by\ndoc-forge to represent a documented codebase. A `Project` aggregates multiple\nmodules and provides access to them through a unified interface.\n\n---\n\nNotes:\n - Modules are keyed by their dotted import path.\n - Objects are renderer-agnostic; the same model feeds every renderer.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.project.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject)",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Module.get_object",
|
|
||||||
"signature": "get_object(name: str)",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects()",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Project": {
|
|
||||||
"name": "Project",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.project.Project",
|
|
||||||
"signature": "Project(name: str)",
|
|
||||||
"docstring": "Representation of a documentation project.\n\nA `Project` serves as the root container for all modules discovered during\nintrospection. Each module is stored by its dotted import path.\n\nAttributes:\n name (str):\n Name of the project.\n\n modules (dict[str, Module]):\n Mapping of module paths to `Module` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Project.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"modules": {
|
|
||||||
"name": "modules",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Project.modules",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_module": {
|
|
||||||
"name": "add_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.add_module",
|
|
||||||
"signature": "add_module(module: Module) -> None",
|
|
||||||
"docstring": "Register a module in the project.\n\nArgs:\n module (Module):\n Module instance to add to the project."
|
|
||||||
},
|
|
||||||
"get_module": {
|
|
||||||
"name": "get_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.get_module",
|
|
||||||
"signature": "get_module(path: str) -> Module",
|
|
||||||
"docstring": "Retrieve a module by its dotted path.\n\nArgs:\n path (str):\n Fully qualified dotted module path (for example `pkg.module`).\n\nReturns:\n Module:\n The corresponding `Module` instance.\n\nRaises:\n KeyError:\n If the module does not exist in the project."
|
|
||||||
},
|
|
||||||
"get_all_modules": {
|
|
||||||
"name": "get_all_modules",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.get_all_modules",
|
|
||||||
"signature": "get_all_modules() -> Iterable[Module]",
|
|
||||||
"docstring": "Return all modules contained in the project.\n\nReturns:\n Iterable[Module]:\n An iterable of `Module` instances."
|
|
||||||
},
|
|
||||||
"get_module_list": {
|
|
||||||
"name": "get_module_list",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.get_module_list",
|
|
||||||
"signature": "get_module_list() -> list[str]",
|
|
||||||
"docstring": "Return the list of module import paths.\n\nReturns:\n list[str]:\n A list containing the dotted paths of all modules in the project."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.models.module",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.models.module",
|
|
||||||
"docstring": "# Summary\n\nDocumentation model representing a Python module or package.\n\nThis module defines the `Module` class used in the doc-forge documentation\nmodel. A `Module` acts as a container for top-level documented objects\n(classes, functions, variables, and other members) discovered during\nintrospection.\n\n---\n\nNotes:\n - Only public members are stored; private names are filtered by the loader.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.module.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject)",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str)",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members()",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.module.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.module.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject) -> None",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.Module.get_object",
|
|
||||||
"signature": "get_object(name: str) -> DocObject",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.module.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects() -> Iterable[DocObject]",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.models.object",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.models.object",
|
|
||||||
"docstring": "# Summary\n\nDocumentation model representing individual Python objects.\n\nThis module defines the `DocObject` class, the fundamental recursive unit of\nthe doc-forge documentation model. Each `DocObject` represents a Python\nentity such as a class, function, method, or attribute, and may contain nested\nmembers that form a hierarchical documentation structure.\n\n---\n\nNotes:\n - `DocObject` instances form a tree mirroring the Python import hierarchy.\n - Objects are renderer-agnostic and may be consumed by any renderer.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"DocObject": {
|
|
||||||
"name": "DocObject",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.object.DocObject",
|
|
||||||
"signature": "DocObject(name: str, kind: str, path: str, signature: str | None = None, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python object.\n\nA `DocObject` models a single Python entity discovered during\nintrospection. Objects may contain nested members, allowing the structure\nof modules, classes, and other containers to be represented recursively.\n\nAttributes:\n name (str):\n Local name of the object.\n\n kind (str):\n Type of object (for example `class`, `function`, `method`, or `attribute`).\n\n path (str):\n Fully qualified dotted path to the object.\n\n signature (str | None):\n Callable signature if the object represents a callable.\n\n docstring (str | None):\n Raw docstring text extracted from the source code.\n\n members (dict[str, DocObject]):\n Mapping of member names to child `DocObject` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"name": "kind",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.kind",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"signature": {
|
|
||||||
"name": "signature",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.signature",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.object.DocObject.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_member": {
|
|
||||||
"name": "add_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.object.DocObject.add_member",
|
|
||||||
"signature": "add_member(obj: DocObject) -> None",
|
|
||||||
"docstring": "Add a child documentation object.\n\nThis is typically used when attaching methods to classes or\nnested objects to their parent containers.\n\nArgs:\n obj (DocObject):\n Documentation object to add as a member."
|
|
||||||
},
|
|
||||||
"get_member": {
|
|
||||||
"name": "get_member",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.object.DocObject.get_member",
|
|
||||||
"signature": "get_member(name: str) -> DocObject",
|
|
||||||
"docstring": "Retrieve a member object by name.\n\nArgs:\n name (str):\n Name of the member to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If the member does not exist."
|
|
||||||
},
|
|
||||||
"get_all_members": {
|
|
||||||
"name": "get_all_members",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.object.DocObject.get_all_members",
|
|
||||||
"signature": "get_all_members() -> Iterable[DocObject]",
|
|
||||||
"docstring": "Return all child members of the object.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing nested members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.models.project",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.models.project",
|
|
||||||
"docstring": "# Summary\n\nDocumentation model representing a project.\n\nThis module defines the `Project` class, the top-level container used by\ndoc-forge to represent a documented codebase. A `Project` aggregates multiple\nmodules and provides access to them through a unified interface.\n\n---\n\nNotes:\n - Modules are keyed by their dotted import path.\n - Objects are renderer-agnostic; the same model feeds every renderer.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"Module": {
|
|
||||||
"name": "Module",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.project.Module",
|
|
||||||
"signature": "Module(path: str, docstring: str | None = None)",
|
|
||||||
"docstring": "Representation of a documented Python module or package.\n\nA `Module` stores metadata about the module itself and maintains a\ncollection of top-level documentation objects discovered during\nintrospection.\n\nAttributes:\n path (str):\n Dotted import path of the module.\n\n docstring (str | None):\n Module-level documentation string, if present.\n\n members (dict[str, DocObject]):\n Mapping of object names to their corresponding `DocObject` representations.",
|
|
||||||
"members": {
|
|
||||||
"path": {
|
|
||||||
"name": "path",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Module.path",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"docstring": {
|
|
||||||
"name": "docstring",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Module.docstring",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"members": {
|
|
||||||
"name": "members",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Module.members",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_object": {
|
|
||||||
"name": "add_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Module.add_object",
|
|
||||||
"signature": "add_object(obj: DocObject)",
|
|
||||||
"docstring": "Add a documented object to the module.\n\nArgs:\n obj (DocObject):\n Documentation object to register as a top-level member of the module."
|
|
||||||
},
|
|
||||||
"get_object": {
|
|
||||||
"name": "get_object",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Module.get_object",
|
|
||||||
"signature": "get_object(name: str)",
|
|
||||||
"docstring": "Retrieve a documented object by name.\n\nArgs:\n name (str):\n Name of the object to retrieve.\n\nReturns:\n DocObject:\n The corresponding `DocObject` instance.\n\nRaises:\n KeyError:\n If no object with the given name exists."
|
|
||||||
},
|
|
||||||
"get_all_objects": {
|
|
||||||
"name": "get_all_objects",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Module.get_all_objects",
|
|
||||||
"signature": "get_all_objects()",
|
|
||||||
"docstring": "Return all top-level documentation objects in the module.\n\nReturns:\n Iterable[DocObject]:\n An iterable of `DocObject` instances representing the module's public members."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Project": {
|
|
||||||
"name": "Project",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.models.project.Project",
|
|
||||||
"signature": "Project(name: str)",
|
|
||||||
"docstring": "Representation of a documentation project.\n\nA `Project` serves as the root container for all modules discovered during\nintrospection. Each module is stored by its dotted import path.\n\nAttributes:\n name (str):\n Name of the project.\n\n modules (dict[str, Module]):\n Mapping of module paths to `Module` instances.",
|
|
||||||
"members": {
|
|
||||||
"name": {
|
|
||||||
"name": "name",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Project.name",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"modules": {
|
|
||||||
"name": "modules",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.models.project.Project.modules",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"add_module": {
|
|
||||||
"name": "add_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.add_module",
|
|
||||||
"signature": "add_module(module: Module) -> None",
|
|
||||||
"docstring": "Register a module in the project.\n\nArgs:\n module (Module):\n Module instance to add to the project."
|
|
||||||
},
|
|
||||||
"get_module": {
|
|
||||||
"name": "get_module",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.get_module",
|
|
||||||
"signature": "get_module(path: str) -> Module",
|
|
||||||
"docstring": "Retrieve a module by its dotted path.\n\nArgs:\n path (str):\n Fully qualified dotted module path (for example `pkg.module`).\n\nReturns:\n Module:\n The corresponding `Module` instance.\n\nRaises:\n KeyError:\n If the module does not exist in the project."
|
|
||||||
},
|
|
||||||
"get_all_modules": {
|
|
||||||
"name": "get_all_modules",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.get_all_modules",
|
|
||||||
"signature": "get_all_modules() -> Iterable[Module]",
|
|
||||||
"docstring": "Return all modules contained in the project.\n\nReturns:\n Iterable[Module]:\n An iterable of `Module` instances."
|
|
||||||
},
|
|
||||||
"get_module_list": {
|
|
||||||
"name": "get_module_list",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.models.project.Project.get_module_list",
|
|
||||||
"signature": "get_module_list() -> list[str]",
|
|
||||||
"docstring": "Return the list of module import paths.\n\nReturns:\n list[str]:\n A list containing the dotted paths of all modules in the project."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,341 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.nav",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.nav",
|
|
||||||
"docstring": "Navigation layer for doc-forge.\n\nThe ``docforge.nav`` package manages the relationship between the logical\ndocumentation structure defined by the user and the physical documentation\nfiles generated on disk.\n\n---\n\nWorkflow\n--------\n\n1. **Specification** – Users define navigation intent in ``docforge.nav.yml``.\n2. **Resolution** – ``resolve_nav`` expands patterns and matches them against\n generated Markdown files.\n3. **Emission** – ``MkDocsNavEmitter`` converts the resolved structure into\n the YAML navigation format required by ``mkdocs.yml``.\n\nThis layer separates documentation organization from the underlying source\ncode layout, enabling flexible grouping, ordering, and navigation structures\nindependent of module hierarchy.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"NavSpec": {
|
|
||||||
"name": "NavSpec",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.NavSpec",
|
|
||||||
"signature": "NavSpec(home: str | None, groups: dict[str, list[str]], icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Parsed representation of a navigation specification.\n\nA ``NavSpec`` describes the intended documentation navigation layout before\nit is resolved against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page (for example\n ``index.md``).\n groups: Mapping of navigation group titles to lists of file patterns\n or glob expressions.\n icon: Optional mapping of theme icon entries (for example\n ``{\"logo\": \"material/code-tags\"}``) injected into the MkDocs\n theme as ``theme.icon``.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.NavSpec.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.NavSpec.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"name": "icon",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.NavSpec.icon",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"load": {
|
|
||||||
"name": "load",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.NavSpec.load",
|
|
||||||
"signature": "load(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification from a YAML file.\n\nArgs:\n path (Path):\n Filesystem path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed configuration.\n\nRaises:\n FileNotFoundError: If the specified file does not exist.\n ValueError: If the file contents are not a valid navigation\n specification."
|
|
||||||
},
|
|
||||||
"all_patterns": {
|
|
||||||
"name": "all_patterns",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.NavSpec.all_patterns",
|
|
||||||
"signature": "all_patterns()",
|
|
||||||
"docstring": "Return all path patterns referenced by the specification.\n\nReturns:\n list[str]:\n A list containing the home document (if defined) and all\n group pattern entries."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
},
|
|
||||||
"ResolvedNav": {
|
|
||||||
"name": "ResolvedNav",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.ResolvedNav",
|
|
||||||
"signature": "ResolvedNav(home: str | None, groups: dict[str, list[Path]], docs_root: Path | None = None)",
|
|
||||||
"docstring": "Resolved navigation structure.\n\nA ``ResolvedNav`` represents navigation data after glob patterns have been\nexpanded and paths validated against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page.\n groups: Mapping of navigation group titles to lists of resolved\n documentation file paths.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.ResolvedNav.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.ResolvedNav.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"all_files": {
|
|
||||||
"name": "all_files",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.ResolvedNav.all_files",
|
|
||||||
"signature": "all_files()",
|
|
||||||
"docstring": "Iterate over all files referenced by the navigation structure.\n\nYields:\n Path:\n A documentation file referenced by the navigation, including\n the home page when defined.\n\nRaises:\n RuntimeError: If the home page is defined but the documentation\n root is not available for resolution."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path)",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav)",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"build_wiki_nav": {
|
|
||||||
"name": "build_wiki_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.build_wiki_nav",
|
|
||||||
"signature": "build_wiki_nav(wiki_dir: Path)",
|
|
||||||
"docstring": "Derive an MkDocs navigation block from a wiki directory.\n\nReturned paths are relative to the parent of ``wiki_dir`` and carry the\nwiki directory name as their leading component (for example\n``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes\nthe result directly usable in an MkDocs ``nav`` block with\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries compatible with the MkDocs ``nav`` configuration.\n The list is empty if the wiki contains no Markdown files.\n\nRaises:\n FileNotFoundError:\n If the wiki directory does not exist."
|
|
||||||
},
|
|
||||||
"mkdocs": {
|
|
||||||
"name": "mkdocs",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.nav.mkdocs",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "MkDocs navigation emitter.\n\nThis module provides the ``MkDocsNavEmitter`` class, which converts a\n``ResolvedNav`` instance into the navigation structure required by the\nMkDocs ``nav`` configuration.\n\n---\n\nNotes:\n - The emitted structure is a list of dictionaries, one per top-level nav\n entry, matching the MkDocs ``nav`` YAML format.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"ResolvedNav": {
|
|
||||||
"name": "ResolvedNav",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav",
|
|
||||||
"signature": "ResolvedNav(home: str | None, groups: dict[str, list[Path]], docs_root: Path | None = None)",
|
|
||||||
"docstring": "Resolved navigation structure.\n\nA ``ResolvedNav`` represents navigation data after glob patterns have been\nexpanded and paths validated against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page.\n groups: Mapping of navigation group titles to lists of resolved\n documentation file paths.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"all_files": {
|
|
||||||
"name": "all_files",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav.all_files",
|
|
||||||
"signature": "all_files()",
|
|
||||||
"docstring": "Iterate over all files referenced by the navigation structure.\n\nYields:\n Path:\n A documentation file referenced by the navigation, including\n the home page when defined.\n\nRaises:\n RuntimeError: If the home page is defined but the documentation\n root is not available for resolution."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.mkdocs.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.mkdocs.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav) -> list[dict[str, Any]]",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resolver": {
|
|
||||||
"name": "resolver",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.nav.resolver",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Navigation resolution utilities.\n\nThis module resolves a ``NavSpec`` against the filesystem by expanding glob\npatterns and validating that referenced documentation files exist.\n\n---\n\nNotes:\n - Glob resolution is recursive and returns paths in sorted order.\n - Unmatched patterns raise ``FileNotFoundError`` to fail fast on typos.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"NavSpec": {
|
|
||||||
"name": "NavSpec",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec",
|
|
||||||
"signature": "NavSpec(home: str | None, groups: dict[str, list[str]], icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Parsed representation of a navigation specification.\n\nA ``NavSpec`` describes the intended documentation navigation layout before\nit is resolved against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page (for example\n ``index.md``).\n groups: Mapping of navigation group titles to lists of file patterns\n or glob expressions.\n icon: Optional mapping of theme icon entries (for example\n ``{\"logo\": \"material/code-tags\"}``) injected into the MkDocs\n theme as ``theme.icon``.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"name": "icon",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.icon",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"load": {
|
|
||||||
"name": "load",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.load",
|
|
||||||
"signature": "load(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification from a YAML file.\n\nArgs:\n path (Path):\n Filesystem path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed configuration.\n\nRaises:\n FileNotFoundError: If the specified file does not exist.\n ValueError: If the file contents are not a valid navigation\n specification."
|
|
||||||
},
|
|
||||||
"all_patterns": {
|
|
||||||
"name": "all_patterns",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.all_patterns",
|
|
||||||
"signature": "all_patterns()",
|
|
||||||
"docstring": "Return all path patterns referenced by the specification.\n\nReturns:\n list[str]:\n A list containing the home document (if defined) and all\n group pattern entries."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ResolvedNav": {
|
|
||||||
"name": "ResolvedNav",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav",
|
|
||||||
"signature": "ResolvedNav(home: str | None, groups: dict[str, list[Path]], docs_root: Path | None = None)",
|
|
||||||
"docstring": "Resolved navigation structure.\n\nA ``ResolvedNav`` represents navigation data after glob patterns have been\nexpanded and paths validated against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page.\n groups: Mapping of navigation group titles to lists of resolved\n documentation file paths.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"all_files": {
|
|
||||||
"name": "all_files",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav.all_files",
|
|
||||||
"signature": "all_files() -> Iterable[Path]",
|
|
||||||
"docstring": "Iterate over all files referenced by the navigation structure.\n\nYields:\n Path:\n A documentation file referenced by the navigation, including\n the home page when defined.\n\nRaises:\n RuntimeError: If the home page is defined but the documentation\n root is not available for resolution."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path) -> ResolvedNav",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"spec": {
|
|
||||||
"name": "spec",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.nav.spec",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Navigation specification model.\n\nThis module defines the ``NavSpec`` class, which represents the navigation\nstructure defined by the user in the doc-forge navigation specification\n(typically ``docforge.nav.yml``).\n\n---\n\nNotes:\n - The spec file supports an optional ``icon`` mapping for MkDocs theme\n customization.\n - All file references in ``groups`` are relative to the documentation root.\n\n---",
|
|
||||||
"members": {
|
|
||||||
"NavSpec": {
|
|
||||||
"name": "NavSpec",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.spec.NavSpec",
|
|
||||||
"signature": "NavSpec(home: str | None, groups: dict[str, list[str]], icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Parsed representation of a navigation specification.\n\nA ``NavSpec`` describes the intended documentation navigation layout before\nit is resolved against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page (for example\n ``index.md``).\n groups: Mapping of navigation group titles to lists of file patterns\n or glob expressions.\n icon: Optional mapping of theme icon entries (for example\n ``{\"logo\": \"material/code-tags\"}``) injected into the MkDocs\n theme as ``theme.icon``.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"name": "icon",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.icon",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"load": {
|
|
||||||
"name": "load",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.load",
|
|
||||||
"signature": "load(path: Path) -> NavSpec",
|
|
||||||
"docstring": "Load a navigation specification from a YAML file.\n\nArgs:\n path (Path):\n Filesystem path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed configuration.\n\nRaises:\n FileNotFoundError: If the specified file does not exist.\n ValueError: If the file contents are not a valid navigation\n specification."
|
|
||||||
},
|
|
||||||
"all_patterns": {
|
|
||||||
"name": "all_patterns",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.all_patterns",
|
|
||||||
"signature": "all_patterns() -> list[str]",
|
|
||||||
"docstring": "Return all path patterns referenced by the specification.\n\nReturns:\n list[str]:\n A list containing the home document (if defined) and all\n group pattern entries."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.spec.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path) -> NavSpec",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"wiki": {
|
|
||||||
"name": "wiki",
|
|
||||||
"kind": "module",
|
|
||||||
"path": "docforge.nav.wiki",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "# Summary\n\nWiki navigation derivation.\n\nThis module provides ``build_wiki_nav``, which derives an MkDocs-ready\nnavigation block from the file structure of a hand-written wiki directory\n(typically ``docs/wiki``). wiki content is authored by hand and is never\nmodified by doc-forge; only the navigation layout is inferred.\n\n# Notes\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.",
|
|
||||||
"members": {
|
|
||||||
"build_wiki_nav": {
|
|
||||||
"name": "build_wiki_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.wiki.build_wiki_nav",
|
|
||||||
"signature": "build_wiki_nav(wiki_dir: Path) -> list[dict[str, Any]]",
|
|
||||||
"docstring": "Derive an MkDocs navigation block from a wiki directory.\n\nReturned paths are relative to the parent of ``wiki_dir`` and carry the\nwiki directory name as their leading component (for example\n``wiki/01_overview.md`` when the wiki lives at ``docs/wiki``). This makes\nthe result directly usable in an MkDocs ``nav`` block with\n\n- ``index.md`` at the wiki root becomes the ``Home`` entry.\n- Page labels are derived from filenames: numeric order prefixes such as\n ``01_`` or ``02-`` are stripped, separators are replaced with spaces, and\n names are title-cased (``01_overview.md`` becomes ``Overview``).\n- Subdirectories become nested navigation groups. A nested ``index.md`` is\n rendered as the section root placed first inside the group.\n- Only ``.md`` files are considered; hidden entries are ignored.\n\nArgs:\n wiki_dir (Path):\n Path to the hand-written wiki directory, for example ``docs/wiki``.\n\nReturns:\n list[dict[str, Any]]:\n Navigation entries compatible with the MkDocs ``nav`` configuration.\n The list is empty if the wiki contains no Markdown files.\n\nRaises:\n FileNotFoundError:\n If the wiki directory does not exist."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.nav.mkdocs",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.nav.mkdocs",
|
|
||||||
"docstring": "MkDocs navigation emitter.\n\nThis module provides the ``MkDocsNavEmitter`` class, which converts a\n``ResolvedNav`` instance into the navigation structure required by the\nMkDocs ``nav`` configuration.\n\n---\n\nNotes:\n - The emitted structure is a list of dictionaries, one per top-level nav\n entry, matching the MkDocs ``nav`` YAML format.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"ResolvedNav": {
|
|
||||||
"name": "ResolvedNav",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav",
|
|
||||||
"signature": "ResolvedNav(home: str | None, groups: dict[str, list[Path]], docs_root: Path | None = None)",
|
|
||||||
"docstring": "Resolved navigation structure.\n\nA ``ResolvedNav`` represents navigation data after glob patterns have been\nexpanded and paths validated against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page.\n groups: Mapping of navigation group titles to lists of resolved\n documentation file paths.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"all_files": {
|
|
||||||
"name": "all_files",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.mkdocs.ResolvedNav.all_files",
|
|
||||||
"signature": "all_files()",
|
|
||||||
"docstring": "Iterate over all files referenced by the navigation structure.\n\nYields:\n Path:\n A documentation file referenced by the navigation, including\n the home page when defined.\n\nRaises:\n RuntimeError: If the home page is defined but the documentation\n root is not available for resolution."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MkDocsNavEmitter": {
|
|
||||||
"name": "MkDocsNavEmitter",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.mkdocs.MkDocsNavEmitter",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": "Emit MkDocs navigation structures from resolved navigation data.\n\nThe emitter transforms a ``ResolvedNav`` object into the YAML-compatible\nlist structure expected by the MkDocs ``nav`` configuration field.",
|
|
||||||
"members": {
|
|
||||||
"emit": {
|
|
||||||
"name": "emit",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.mkdocs.MkDocsNavEmitter.emit",
|
|
||||||
"signature": "emit(nav: ResolvedNav) -> list[dict[str, Any]]",
|
|
||||||
"docstring": "Generate a navigation structure for ``mkdocs.yml``.\n\nArgs:\n nav (ResolvedNav):\n Resolved navigation data describing documentation groups\n and their associated Markdown files.\n\nReturns:\n list[dict[str, Any]]:\n A list of dictionaries representing the MkDocs navigation layout.\n Each dictionary maps a navigation label to a page or a list of\n pages."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.nav.resolver",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.nav.resolver",
|
|
||||||
"docstring": "Navigation resolution utilities.\n\nThis module resolves a ``NavSpec`` against the filesystem by expanding glob\npatterns and validating that referenced documentation files exist.\n\n---\n\nNotes:\n - Glob resolution is recursive and returns paths in sorted order.\n - Unmatched patterns raise ``FileNotFoundError`` to fail fast on typos.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"NavSpec": {
|
|
||||||
"name": "NavSpec",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec",
|
|
||||||
"signature": "NavSpec(home: str | None, groups: dict[str, list[str]], icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Parsed representation of a navigation specification.\n\nA ``NavSpec`` describes the intended documentation navigation layout before\nit is resolved against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page (for example\n ``index.md``).\n groups: Mapping of navigation group titles to lists of file patterns\n or glob expressions.\n icon: Optional mapping of theme icon entries (for example\n ``{\"logo\": \"material/code-tags\"}``) injected into the MkDocs\n theme as ``theme.icon``.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"name": "icon",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.icon",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"load": {
|
|
||||||
"name": "load",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.load",
|
|
||||||
"signature": "load(path: Path)",
|
|
||||||
"docstring": "Load a navigation specification from a YAML file.\n\nArgs:\n path (Path):\n Filesystem path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed configuration.\n\nRaises:\n FileNotFoundError: If the specified file does not exist.\n ValueError: If the file contents are not a valid navigation\n specification."
|
|
||||||
},
|
|
||||||
"all_patterns": {
|
|
||||||
"name": "all_patterns",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.NavSpec.all_patterns",
|
|
||||||
"signature": "all_patterns()",
|
|
||||||
"docstring": "Return all path patterns referenced by the specification.\n\nReturns:\n list[str]:\n A list containing the home document (if defined) and all\n group pattern entries."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ResolvedNav": {
|
|
||||||
"name": "ResolvedNav",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav",
|
|
||||||
"signature": "ResolvedNav(home: str | None, groups: dict[str, list[Path]], docs_root: Path | None = None)",
|
|
||||||
"docstring": "Resolved navigation structure.\n\nA ``ResolvedNav`` represents navigation data after glob patterns have been\nexpanded and paths validated against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page.\n groups: Mapping of navigation group titles to lists of resolved\n documentation file paths.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"all_files": {
|
|
||||||
"name": "all_files",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.ResolvedNav.all_files",
|
|
||||||
"signature": "all_files() -> Iterable[Path]",
|
|
||||||
"docstring": "Iterate over all files referenced by the navigation structure.\n\nYields:\n Path:\n A documentation file referenced by the navigation, including\n the home page when defined.\n\nRaises:\n RuntimeError: If the home page is defined but the documentation\n root is not available for resolution."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resolve_nav": {
|
|
||||||
"name": "resolve_nav",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.resolver.resolve_nav",
|
|
||||||
"signature": "resolve_nav(spec: NavSpec, docs_root: Path) -> ResolvedNav",
|
|
||||||
"docstring": "Resolve a navigation specification against the filesystem.\n\nThe function expands glob patterns defined in a ``NavSpec`` and verifies\nthat referenced documentation files exist within the documentation root.\n\nArgs:\n spec (NavSpec):\n Navigation specification describing documentation layout.\n docs_root (Path):\n Root directory containing documentation Markdown files.\n\nReturns:\n ResolvedNav:\n A `ResolvedNav` instance containing validated navigation paths.\n\nRaises:\n FileNotFoundError: If the documentation root does not exist or a\n navigation pattern does not match any files."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
{
|
|
||||||
"module": "docforge.nav.spec",
|
|
||||||
"content": {
|
|
||||||
"path": "docforge.nav.spec",
|
|
||||||
"docstring": "Navigation specification model.\n\nThis module defines the ``NavSpec`` class, which represents the navigation\nstructure defined by the user in the doc-forge navigation specification\n(typically ``docforge.nav.yml``).\n\n---\n\nNotes:\n - The spec file supports an optional ``icon`` mapping for MkDocs theme\n customization.\n - All file references in ``groups`` are relative to the documentation root.\n\n---",
|
|
||||||
"objects": {
|
|
||||||
"NavSpec": {
|
|
||||||
"name": "NavSpec",
|
|
||||||
"kind": "class",
|
|
||||||
"path": "docforge.nav.spec.NavSpec",
|
|
||||||
"signature": "NavSpec(home: str | None, groups: dict[str, list[str]], icon: dict[str, str] | None = None)",
|
|
||||||
"docstring": "Parsed representation of a navigation specification.\n\nA ``NavSpec`` describes the intended documentation navigation layout before\nit is resolved against the filesystem.\n\nAttributes:\n home: Relative path to the documentation home page (for example\n ``index.md``).\n groups: Mapping of navigation group titles to lists of file patterns\n or glob expressions.\n icon: Optional mapping of theme icon entries (for example\n ``{\"logo\": \"material/code-tags\"}``) injected into the MkDocs\n theme as ``theme.icon``.",
|
|
||||||
"members": {
|
|
||||||
"home": {
|
|
||||||
"name": "home",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.home",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"groups": {
|
|
||||||
"name": "groups",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.groups",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"name": "icon",
|
|
||||||
"kind": "attribute",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.icon",
|
|
||||||
"signature": null,
|
|
||||||
"docstring": null
|
|
||||||
},
|
|
||||||
"load": {
|
|
||||||
"name": "load",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.load",
|
|
||||||
"signature": "load(path: Path) -> NavSpec",
|
|
||||||
"docstring": "Load a navigation specification from a YAML file.\n\nArgs:\n path (Path):\n Filesystem path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed configuration.\n\nRaises:\n FileNotFoundError: If the specified file does not exist.\n ValueError: If the file contents are not a valid navigation\n specification."
|
|
||||||
},
|
|
||||||
"all_patterns": {
|
|
||||||
"name": "all_patterns",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.spec.NavSpec.all_patterns",
|
|
||||||
"signature": "all_patterns() -> list[str]",
|
|
||||||
"docstring": "Return all path patterns referenced by the specification.\n\nReturns:\n list[str]:\n A list containing the home document (if defined) and all\n group pattern entries."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_nav_spec": {
|
|
||||||
"name": "load_nav_spec",
|
|
||||||
"kind": "function",
|
|
||||||
"path": "docforge.nav.spec.load_nav_spec",
|
|
||||||
"signature": "load_nav_spec(path: Path) -> NavSpec",
|
|
||||||
"docstring": "Load a navigation specification file.\n\nThis helper function reads a YAML navigation file and constructs a\ncorresponding ``NavSpec`` instance.\n\nArgs:\n path (Path):\n Path to the navigation specification file.\n\nReturns:\n NavSpec:\n A ``NavSpec`` instance representing the parsed specification.\n\nRaises:\n FileNotFoundError: If the specification file does not exist.\n ValueError: If the YAML structure is invalid."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user