feat: add wiki build kind with file-structure-derived navigation

- add build_wiki_nav deriving MkDocs nav from docs/wiki file structure
  (index.md -> Home, numeric prefixes stripped and title-cased, nested
  dirs become groups, natural ordering)
- add --wiki / --wiki-dir to build; wiki-only builds need no --module
- merge wiki nav before generated lib/api nav; wiki Home replaces the
  nav spec Home entry
- add mkdocs.wiki.yml template fragment and nav/cli tests
- dogfood doc-forge's own docs/wiki and regenerate site output
This commit is contained in:
2026-09-11 23:38:23 +05:30
parent bacf17b930
commit 8c6c46caf2
44 changed files with 798 additions and 17 deletions

View File

@@ -0,0 +1,3 @@
# Api Utils
::: docforge.cli.api_utils

View File

@@ -0,0 +1,3 @@
# Commands
::: docforge.cli.commands

View File

@@ -0,0 +1,8 @@
# Cli
::: docforge.cli
- [Api Utils](api_utils.md)
- [Commands](commands.md)
- [Main](main.md)
- [Mcp Utils](mcp_utils.md)
- [Mkdocs Utils](mkdocs_utils.md)

View File

@@ -0,0 +1,3 @@
# Main
::: docforge.cli.main

View File

@@ -0,0 +1,3 @@
# Mcp Utils
::: docforge.cli.mcp_utils

View File

@@ -0,0 +1,3 @@
# Mkdocs Utils
::: docforge.cli.mkdocs_utils

View File

@@ -0,0 +1,9 @@
# Docforge
::: docforge
- [Cli](cli/)
- [Loaders](loaders/)
- [Models](models/)
- [Nav](nav/)
- [Renderers](renderers/)
- [Servers](servers/)

View File

@@ -0,0 +1,3 @@
# Griffe Loader
::: docforge.loaders.griffe_loader

View File

@@ -0,0 +1,4 @@
# Loaders
::: docforge.loaders
- [Griffe Loader](griffe_loader.md)

View File

@@ -0,0 +1,6 @@
# Models
::: docforge.models
- [Module](module.md)
- [Object](object.md)
- [Project](project.md)

View File

@@ -0,0 +1,3 @@
# Module
::: docforge.models.module

View File

@@ -0,0 +1,3 @@
# Object
::: docforge.models.object

View File

@@ -0,0 +1,3 @@
# Project
::: docforge.models.project

View File

@@ -0,0 +1,7 @@
# Nav
::: docforge.nav
- [Mkdocs](mkdocs.md)
- [Resolver](resolver.md)
- [Spec](spec.md)
- [Wiki](wiki.md)

View File

@@ -0,0 +1,3 @@
# Mkdocs
::: docforge.nav.mkdocs

View File

@@ -0,0 +1,3 @@
# Resolver
::: docforge.nav.resolver

View File

@@ -0,0 +1,3 @@
# Spec
::: docforge.nav.spec

View File

@@ -0,0 +1,3 @@
# Wiki
::: docforge.nav.wiki

View File

@@ -0,0 +1,3 @@
# Base
::: docforge.renderers.base

View File

@@ -0,0 +1,6 @@
# Renderers
::: docforge.renderers
- [Base](base.md)
- [Mcp Renderer](mcp_renderer.md)
- [Mkdocs Renderer](mkdocs_renderer.md)

View File

@@ -0,0 +1,3 @@
# Mcp Renderer
::: docforge.renderers.mcp_renderer

View File

@@ -0,0 +1,3 @@
# Mkdocs Renderer
::: docforge.renderers.mkdocs_renderer

View File

@@ -0,0 +1,4 @@
# Servers
::: docforge.servers
- [Mcp Server](mcp_server.md)

View File

@@ -0,0 +1,3 @@
# Mcp Server
::: docforge.servers.mcp_server

View File

@@ -1,3 +1,4 @@
# docforge
::: docforge
- [Docforge](docforge/)

25
docs/wiki/01_overview.md Normal file
View File

@@ -0,0 +1,25 @@
# Overview
`docforge` turns GSDFC-compliant Python docstrings into maintainable reference
documentation. It never edits source docstrings; it reads them, renders them,
and assembles a single MkDocs site from all available material.
## What it generates
| Kind | Source | Output |
|-----------|----------------------------|---------------------------------|
| `lib` | GSDFC docstrings | `docs/lib/**` rendered markdown |
| `api` | OpenAPI JSON spec | `docs/api/**` rendered markdown |
| `wiki` | Hand-written markdown | `docs/wiki/**` (unchanged) |
| `mcp` | Griffe + renderers | `docs/mcp/**` structured files |
## Combined build
One `mkdocs.yml` and one MkDocs build serve all kinds:
1. Wiki navigation is derived from the `docs/wiki/` file structure.
2. Generated library/API navigation is appended after it.
3. The wiki `index.md` becomes the site `Home`.
Hand-written wiki content is never overwritten or regenerated — only its
navigation is derived automatically.

View File

@@ -0,0 +1,34 @@
# Architecture
`docforge` is split into four horizontal layers. Everything flows top to
bottom through the CLI.
## Loaders → Models
The `docforge/loaders` package wraps `griffe` to extract modules, functions,
classes, and Google-style docstring sections. Loaded data is normalized into
the object model under `docforge/models` (`Module`, `Object`, `Project`,
`Field`).
## Navigation
`docforge/nav` parses `docforge.nav.yml` specs (`NavSpec`, `Resolver`, and the
MkDocs nav emitter) and, since the wiki kind, derives wiki navigation from the
file structure via `build_wiki_nav`.
## Renderers
`docforge/renderers` turn model data into artifacts:
- `MkDocsRenderer``docs/lib/**` reference markdown
- `MCPRenderer``docs/mcp/**` structured documentation
## CLI
`docforge/cli` wires it all together:
- `commands.py` — the `build` command and its `--mkdocs` / `--api` / `--wiki`
/ `--mcp` modes
- `mkdocs_utils.py` — config generation (`mkdocs.yml`) including merged
wiki + lib + api navigation
- `api_utils.py` — OpenAPI loading and API docs generation

View File

@@ -0,0 +1,29 @@
# Conventions
## GSDFC docstrings
All documented source uses the Google-Styled Doc-Forge Convention (GSDFC):
`Args:`, `Returns:`, `Raises:`, and `Attributes:` sections with properly typed
signatures.
## `.pyi` stubs
Every module ships a matching `.pyi` stub kept in sync with the `.py`
implementation. When signatures change, update both files.
## Wiki pages
- Hand-written markdown lives in `docs/wiki/**` and is never generated.
- File names use a numeric prefix: `01_overview.md`, `02_components.md`.
- Nested directories become nested navigation groups:
`05_development/01_environment.md` → group *Development*.
- `index.md` is the site `Home` at the root, and a section root inside a
directory.
- Navigation labels are derived by stripping the numeric prefix and applying
title case on the remaining words.
## Templates
MkDocs config fragments live in `docforge/templates`. The `mkdocs.wiki.yml`
fragment carries only the `search` plugin, since wiki pages contain no
mkdocstrings directives.

View File

@@ -0,0 +1,33 @@
# Iterative Workflow
A docs build runs through the CLI in a single pass.
## Build commands
```bash
# Library reference only
doc-forge build --mkdocs --module docforge
# Wik + library combined (single MkDocs build)
doc-forge build --wiki --mkdocs --module docforge
# Wiki only — no module required
doc-forge build --wiki --site-name docforge
```
## What a combined build does
1. Validates the requested modes (`--mkdocs`, `--api`, `--wiki`, `--mcp`).
2. Generates library sources under `docs/lib/**` with `MkDocsRenderer`.
3. Generates API sources under `docs/api/**` when `--api` is given.
4. Derives wiki navigation from `docs/wiki/**`.
5. Writes `mkdocs.yml` with merged navigation — wiki first, generated groups
appended, and the wiki `Home` replacing any spec `Home` entry.
6. Runs `mkdocs build` once and emits the site.
## Explore the site
```bash
doc-forge build --wiki --mkdocs --module docforge
doc-forge serve --mkdocs-yml mkdocs.yml
```

View File

@@ -0,0 +1,20 @@
# Environment Setup
## Create the environment
```bash
python -m venv .venv
.venv\Scripts\activate
pip install -e .
```
Requires Python 3.11+.
## Dependencies
Development extras include:
- `pytest`, `pytest-cov` — test suite and coverage
- `ruff` — lint and format checking
- `black` — auto-formatting
- `mypy` — strict typing checks

View File

@@ -0,0 +1,22 @@
# Quality Gates
Run all checks before pushing:
```bash
.venv\Scripts\python.exe -m pytest
.venv\Scripts\python.exe -m ruff check docforge tests
.venv\Scripts\python.exe -m black --check docforge tests
.venv\Scripts\python.exe -m mypy docforge
```
## Test layout
| Path | Covers |
|--------------------------|------------------------------------|
| `tests/nav/` | Nav spec, resolver, wiki nav |
| `tests/cli/` | Build command flows and modes |
| `tests/renderers/` | MkDocs / MCP rendering |
CLI tests use the `cli_runner` fixture with `mock_mkdocs_build` and
`mock_mkdocs_load_config` so they exercise the full flow without invoking a
real MkDocs build.

39
docs/wiki/index.md Normal file
View File

@@ -0,0 +1,39 @@
# 🔨 docforge — Docstring-Driven Documentation Forge
`docforge` is an internal documentation tool that generates reference
documentation from Google-Styled Doc-Forge Convention (GSDFC) docstrings and
assembles it into a single MkDocs site, alongside hand-written wiki pages and
OpenAPI-based API docs.
---
## 🚀 Key Features
- 🧪 GSDFC docstring extraction via Griffe
- 🧭 Auto-derived navigation for hand-written wiki pages
- 🗂 Combined MkDocs build: wiki first, then generated library/API reference
- 🔌 Material MkDocs theming out of the box
- 📦 MCP structured documentation resources
---
## 📁 Documentation Structure
| Section | Description |
|----------------------------------------------| -------------------------------------------------- |
| [Overview](01_overview.md) | What docforge is and how it fits the pipeline |
| [Architecture](02_architecture.md) | Loaders, models, nav, renderers, CLI |
| [Conventions](03_conventions.md) | GSDFC, `.pyi` stubs, and template conventions |
| [Iterative Workflow](04_iterative_workflow.md) | How a docs build runs end to end |
| [Development](05_development/01_environment.md) | Environment setup and quality gates |
---
## 🔗 Related Resources
- **Source Code:** `C:\Users\vishe\WorkSpace\code\aetos\doc-forge`
- **Wiki Kind:** hand-written content lives in `docs/wiki/`
---
© Aetoskia Internal