π¨ 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 per-kind MkDocs sites, 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
- π Independent MkDocs builds per kind (lib, api, wiki) into
site/{kind} - π Material MkDocs theming out of the box
- π¦ MCP structured documentation resources
π Documentation Structure
| Section | Description |
|---|---|
| Overview | What docforge is and how it fits the pipeline |
| Architecture | Loaders, models, nav, renderers, CLI, servers |
| Conventions | GSDFC, .pyi stubs, and template conventions |
| Iterative Workflow | How a docs build runs end to end |
| Development | Environment setup and quality gates |
| Docstring Guide | How to write GSDFC-conformant docstrings |
| MCP Guide | Building, serving, and consuming the MCP bundle |
π Related Resources
- Source Code: the
doc-forgerepository - MCP Bundle: generated by
doc-forge build --mcp --module docforgeintodocs/mcp/ - Wiki Kind: hand-written content lives in
docs/wiki/or use the prompt mentioned below1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
# AGENTS.md β Wiki Authoring Guide (Aetoskia) This file instructs AI agents how to create, extend, and maintain the wiki (`docs/wiki/**`) for any Aetoskia repository. The reference implementation is `mongo-ops` β its wiki went through several revisions to reach the structure below and should be treated as the canonical example. --- ## 1. Doc model β know the two sources of truth Every repo keeps two distinct kinds of documentation that must **not** bleed into each other: | Kind | Source | Where | Audience | |-------------------|-----------------------|------------------------------------------|------------------------------------| | **Wiki** | Hand-written markdown | `docs/wiki/**` | Humans (how-to, examples, testing) | | **API reference** | Docstrings (GSDFC) | Generated β `docs/lib/**`, `docs/mcp/**` | Consumers (exact contracts) | Rules: - The wiki is written **for humans** β how-to guides, recipes, and testing patterns. It is never generated. - API contracts (signatures, parameter types, exact behavior) live in the docstrings and the machine-readable bundle under `docs/mcp/`. **Never** duplicate full API documentation in the wiki β link to the lib site instead. - If a page starts to drift into contract territory, cut it down to usage and point at `docs/lib/`. - This doc model is stated on every index page as a blockquote; keep it there: > **Doc model:** this wiki is written for humans β howβto guides, examples, > and testing recipes. The authoritative API contracts live in the code > (docstrings) and the machineβreadable bundle under `docs/mcp/`. --- ## 2. Directory layout & file naming ``` docs/wiki/ βββ index.md # site Home βββ 01_overview.md βββ 02_components.md βββ 03_use_cases/ # nested directory β nav group β βββ 01_basic_crud.md β βββ 02_custom_repo.md β βββ ... βββ 04_best_practices.md βββ 06_error_handling.md βββ 07_testing_example.md ``` - Location: `docs/wiki/` (hand-written only). - File names: `NN_snake_case_name.md` with a **zero-padded two-digit** numeric prefix. e.g. `01_overview.md`, `03_use_cases/07_caching.md`. - Top-level pages use `NN_name.md` directly. High-volume sections get their own directory, e.g. `03_use_cases/NN_name.md` (nav group "Use Cases"). - **No frontmatter.** Every file opens directly with an H1 `# Title`. - Navigation labels are short human titles set explicitly in `docs/mkdocs.wiki.yml` (title case) β often **shorter** than the page H1. Example: nav label `Basic CRUD` vs page H1 `Use Case 1: Basic FastAPI CRUD API`. Never use the raw filename slug as the label. - Renumbering: prefixes order pages. When inserting a page, pick the next number in the relevant group (subgroup numbers stay grouped). --- ## 3. Navigation β `docs/mkdocs.wiki.yml` is the source of truth Every wiki page **must** be wired into the nav defined in `docs/mkdocs.wiki.yml`. If a page is not in the nav, it is orphaned. - The `nav:` block mirrors the directory tree; directories become nested groups. - When a section has many pages, group them **by theme** into nested subgroups. mongo-ops groups its use cases into: `Getting Started`, `Data & Queries`, `Caching`, `Population`, `Advanced Usage`. - Keep `index.md`'s **Documentation Structure** table in sync with the nav β it is the human-facing version of the same TOC. Every nav entry needs a row (or nested bullet group) there. - Nav label = human title (title case), not the filename slug. --- ## 4. Page anatomy ### 4.1 `index.md` (Home) ``` # π§© <package> β <slogan> <one-paragraph pitch> > **Doc model:** β¦ (see Β§1) --- ## π Key Features (bullet list, emoji per feature) ## π¦ Installation (code blocks: internal PyPI, extras, local source) ## π Documentation Structure (table = TOC, mirrors nav exactly) ## π Related Resources (bullets: source repo, internal PyPI, CI) --- Β© Aetoskia Internal β `<package>` <version> ``` ### 4.2 Overview page (`01_*`) - Opens with `# Library Overview`, one sentence about what the library does, then a line stating the page builds the mental model. - Sections: `## ποΈ Architecture` (ASCII diagram + numbered layer list), `## π Lifecycle Rules` (table: step / call / why), `## π§ Which β¦ Should You Use?` (decision table). - Ends with `## β‘οΈ Read Next` (cross-links to the next pages to read). ### 4.3 Components page (`02_*`) - Validated reference for the public API surface β describes what each component is for and how the pieces wire together. Keep it usage-level; exact signatures belong in `docs/lib/`. - Anatomy: numbered sections, one per component (`## 1. MongoConnectionManager`, `## 2. BaseDocument`, β¦), with `### 8.1`-style sub-numbering for related types under a component (e.g. the cache layer's backend / stats / config / in-memory / redis implementations). Ends with `## Related`. ### 4.4 Use-case page (the most common) Standard anatomy, in this order: ``` # Use Case N: <Human Title> **Scenario:** <one sentence: the problem this recipe solves> --- ## π¦ What's New? (table: Component | Description β new API used here) ## π Example (languaged code block, complete runnable-looking snippet) ## π‘ Tips (bullets: gotchas, ordering, common mistakes) ## Related (Β§5) ``` ### 4.5 Deep-dive / worked-example page For intricate flows (population shapes, cache round-trips), use numbered depth-first sections and comparison tables: ``` ## 1. <Write path> (### 1a., ### 1b., β¦ per sub-case) ## 2. <Read path> ## 3. <Round trip / tricky bit> ## 4. When to use which (comparison table) ## Related ``` ### 4.6 Best Practices page (`04_*`) - Flat themed `##` sections (e.g. Layering, Lifecycle, Data & Performance, Transactions & Errors, Testing), each a short list of numbered conventions. - Pure prose β no large code blocks. ### 4.7 Error Handling (`06_*`) / Testing pages - **Error Handling:** an exceptions table (`Exception | Source | Meaning / fix`), a `> ` note on which failures are by design, a `## π FastAPI Mapping Example` code block, then `## π‘ Tips` bullets, then `## Related`. - **Testing example (`07_*`):** `## π Mock-Based Quickstart` (focused code block), `## π‘ Notes` tip list, `## Related`. Common to all pages: no frontmatter, `---` between every major section, and a `## Related` (or variant) footer as the **last** section. --- ## 5. The `## Related` footer Every page ends with a cross-link footer. Rules: - Always the **last** section, always preceded by a `---`. - Standard heading: `## Related` (no emoji). - One bullet line; links separated by ` Β· ` (middle dot plus spaces). - Link label format: `[NN β Title](relative_path)` β en-dash, page number, title. - Paths are **relative**: same directory β `02_custom_repo.md`; parent β `../01_overview.md`; child β `03_use_cases/01_basic_crud.md`. - Link order follows nav order (each `Related` points to related next/sibling pages, plus the overview/components anchor). Examples (from mongo-ops): ``` ## Related - [02 β Custom repository](02_custom_repo.md) Β· [04 β Pagination](04_pagination.md) Β· [Overview](../01_overview.md) ``` Variants: - `## β‘οΈ Read Next` β used on the overview page (linear reading order). - `## π Related Resources` β only on `index.md`, one bullet per external resource. --- ## 6. Tone & formatting rules - **Written for humans**: short sentences, concrete examples, plain words. - Emoji-prefixed H2 headings for recognizable section types (`π¦ What's New?`, `π Example`, `π‘ Tips`, `π Key Features`). - `---` horizontal rule between every major section. - Code blocks always declare a language (```python, ```bash, etc.). - Use tables for comparisons and structured decisions; bullets for lists; ASCII diagrams for architecture. - Bold key terms inline. Use `inline code` for symbols/APIs. - Keep pages focused: one recipe/purpose per page. If a page balloons past ~10 KB, split it (add a numbered deep-dive page instead). - Match tone of existing pages in the repo before writing new ones. --- ## 7. Build & verify workflow After creating or editing wiki pages: ```bash # 1. Build the wiki (from the repo root) doc-forge build --wiki # wiki only doc-forge build --wiki --mkdocs --module <pkg> # wiki + lib together # 2. Preview locally doc-forge serve --wiki # 3. Collect into the hub (run from the docs/ service repo) python collect.py # copies site, regenerates index + nginx.conf python collect.py --dry-run # preview without writing ``` Verification checklist: - `doc-forge build --wiki` completes with no warnings about missing files. - Every new page is present in `docs/mkdocs.wiki.yml` **and** in the index Documentation Structure table. - Every page ends with a `## Related` block and no dead links (paths resolve). - After `collect.py`: the hub card links to both `/wiki/` and `/lib/` and the pages render (spot-check with the served site). - If code/docstrings changed (no change when wiki-only), run the repo gates: `black`, `ruff`, `mypy`, `pytest`. --- ## 8. Before/after checklist **Before creating a page:** - [ ] Confirm it is genuinely wiki material (how-to) and not API contract. - [ ] Find the right filename (`NN_snake_case.md`) and directory for its theme. - [ ] Outline the sections per Β§4 anatomy that fits the content. **After creating/editing a page:** - [ ] Page wired into `docs/mkdocs.wiki.yml` nav (themed subgroup if needed). - [ ] `index.md` Documentation Structure table updated. - [ ] `## Related` footer present, relative links, nav order. - [ ] `---` separators consistent; no frontmatter; emoji headings where apt. - [ ] Build passes; collect run; hub shows `/wiki/` + `/lib/` links. - [ ] No orphaned files, no dead links.
Β© Aetoskia Internal