|
| 1 | +--- |
| 2 | +description: Documentation standards for ArchiPy MkDocs pages |
| 3 | +globs: docs/**/*.md |
| 4 | +alwaysApply: false |
| 5 | +--- |
| 6 | + |
| 7 | +# Documentation Standards |
| 8 | + |
| 9 | +## File Naming |
| 10 | + |
| 11 | +- All filenames must be lowercase `snake_case` (e.g., `config_management.md`, `bdd_testing.md`). |
| 12 | +- Every directory must have an `index.md` overview file. |
| 13 | +- Adapter and helper filenames must match the Python module name exactly (e.g., `scylladb.md`, `metaclasses.md`). |
| 14 | + |
| 15 | +## Page Structure |
| 16 | + |
| 17 | +Every page must open with YAML frontmatter: |
| 18 | + |
| 19 | +```yaml |
| 20 | +--- |
| 21 | +title: <Short Human-Readable Title> |
| 22 | +description: <One-sentence description of the page> |
| 23 | +--- |
| 24 | +``` |
| 25 | + |
| 26 | +Heading hierarchy: `#` H1 (matches `title`) → `##` major sections → `###` subsections. Do not skip levels. |
| 27 | + |
| 28 | +### Adapter Example Pages — required sections (in order) |
| 29 | + |
| 30 | +1. `## Installation` — single `bash` block: `uv add "archipy[extra]"` |
| 31 | +2. `## Configuration` → `### Environment Variables` (bash block) + `### Direct Configuration` (python block) |
| 32 | +3. `## Basic Usage` — complete, runnable Python snippets |
| 33 | +4. `## Advanced <Feature>` — deeper patterns (add as needed) |
| 34 | +5. `## See Also` — 4–6 relative links to related docs |
| 35 | + |
| 36 | +### API Reference Pages — required sections |
| 37 | + |
| 38 | +H1 + intro prose → `## Ports`, `## Adapters`, `## Mocks`, each with an mkdocstrings directive: |
| 39 | + |
| 40 | +```markdown |
| 41 | +::: archipy.adapters.<name>.ports |
| 42 | + options: |
| 43 | + show_root_toc_entry: false |
| 44 | + heading_level: 3 |
| 45 | +``` |
| 46 | + |
| 47 | +## Code Example Standards |
| 48 | + |
| 49 | +- Always use `import logging` and `logger = logging.getLogger(__name__)`. Never use `print()`. |
| 50 | +- Full Python 3.14+ type hints: `list[str]`, `dict[str, Any]`, `X | Y` — never `Optional[X]` or `Union[X, Y]`. |
| 51 | +- Google-style docstrings on every defined function or class. |
| 52 | +- Catch specific exception types only; always chain with `raise ... from e`. |
| 53 | +- Every fenced code block must have a language tag (`python` or `bash`). |
| 54 | + |
| 55 | +```python |
| 56 | +# ✅ GOOD |
| 57 | +import logging |
| 58 | + |
| 59 | +logger = logging.getLogger(__name__) |
| 60 | + |
| 61 | +def get_item(key: str) -> str | None: |
| 62 | + """Retrieve an item by key. |
| 63 | + |
| 64 | + Args: |
| 65 | + key: The cache key to look up. |
| 66 | + |
| 67 | + Returns: |
| 68 | + The cached value, or None if not found. |
| 69 | + |
| 70 | + Raises: |
| 71 | + CacheError: If the cache is unreachable. |
| 72 | + """ |
| 73 | + try: |
| 74 | + return cache.get(key) |
| 75 | + except ConnectionError as e: |
| 76 | + raise CacheError("Cache unreachable") from e |
| 77 | +``` |
| 78 | + |
| 79 | +## Writing Style |
| 80 | + |
| 81 | +- **Admonitions**: use `!!! note`, `!!! tip`, `!!! warning`. `note` supports an optional inline title: `!!! note "Title"`. |
| 82 | +- **Cross-links**: always relative paths (e.g., `[Error Handling](../error_handling.md)`). |
| 83 | +- **Emphasis**: bold (`**term**`) for key terms on first mention. No emoji outside `index.md` and overview pages. |
| 84 | +- **Tables**: use for structured comparison data (extras matrix, config options). |
| 85 | +- **`## See Also`**: end every adapter example page with this section linking to error handling, config, BDD testing, related helpers, and the corresponding API reference page. |
| 86 | + |
| 87 | +## New Adapter Checklist |
| 88 | + |
| 89 | +When documenting a new adapter, create **both** files: |
| 90 | + |
| 91 | +- `docs/examples/adapters/<name>.md` — example guide with all 5 required sections |
| 92 | +- `docs/api_reference/adapters/<name>.md` — API reference with mkdocstrings directives |
| 93 | + |
| 94 | +Then add both entries under the appropriate `nav:` keys in `mkdocs.yml`. |
0 commit comments