|
| 1 | +# Documentation Building Guidelines |
| 2 | + |
| 3 | +## Building Documentation with Strict Mode |
| 4 | + |
| 5 | +The project uses MkDocs with Material theme for documentation. All documentation builds **MUST** use strict mode to catch warnings as errors and ensure documentation quality. |
| 6 | + |
| 7 | +### Correct Build Command |
| 8 | + |
| 9 | +The documentation build command is defined in `pyproject.toml` and includes: |
| 10 | +- `--strict` flag to treat warnings as errors |
| 11 | +- Suppression of known deprecation warnings from mkdocs-autorefs |
| 12 | + |
| 13 | +**Always use:** |
| 14 | +```bash |
| 15 | +hatch run docs-build |
| 16 | +``` |
| 17 | + |
| 18 | +This executes: |
| 19 | +```bash |
| 20 | +python -W ignore::DeprecationWarning:mkdocs_autorefs -m mkdocs build --clean --strict |
| 21 | +``` |
| 22 | + |
| 23 | +### Why Strict Mode? |
| 24 | + |
| 25 | +Strict mode ensures: |
| 26 | +- All documentation links are valid |
| 27 | +- All API references resolve correctly |
| 28 | +- Type annotations are complete |
| 29 | +- No broken cross-references |
| 30 | +- Documentation quality is maintained |
| 31 | + |
| 32 | +### Common Issues and Solutions |
| 33 | + |
| 34 | +#### Issue: Missing Type Annotations for **kwargs |
| 35 | + |
| 36 | +**Error:** |
| 37 | +``` |
| 38 | +WARNING - griffe: janus_client\plugin_name.py:123: No type or annotation for parameter '**kwargs' |
| 39 | +``` |
| 40 | + |
| 41 | +**Solution:** |
| 42 | +Add `Any` type annotation to `**kwargs`: |
| 43 | +```python |
| 44 | +from typing import Any |
| 45 | + |
| 46 | +def __init__(self, **kwargs: Any) -> None: |
| 47 | + """Initialize the plugin.""" |
| 48 | + super().__init__(**kwargs) |
| 49 | +``` |
| 50 | + |
| 51 | +#### Issue: Broken API References |
| 52 | + |
| 53 | +**Error:** |
| 54 | +``` |
| 55 | +ERROR - mkdocstrings: janus_client.SomeClass could not be found |
| 56 | +``` |
| 57 | + |
| 58 | +**Solution:** |
| 59 | +- Verify the class/function exists in the codebase |
| 60 | +- Check the import path is correct |
| 61 | +- Ensure the class is exported in `__init__.py` if needed |
| 62 | +- Remove references to non-existent classes from `docs/reference.md` |
| 63 | + |
| 64 | +#### Issue: Deprecation Warnings |
| 65 | + |
| 66 | +**Error:** |
| 67 | +``` |
| 68 | +DeprecationWarning: ... from mkdocs_autorefs |
| 69 | +``` |
| 70 | + |
| 71 | +**Solution:** |
| 72 | +These are suppressed in the build command. If new deprecation warnings appear: |
| 73 | +1. Check if they're from mkdocs-autorefs (can be suppressed) |
| 74 | +2. If from our code, fix the deprecated usage |
| 75 | +3. Update the build command in `pyproject.toml` if needed |
| 76 | + |
| 77 | +### Local Development |
| 78 | + |
| 79 | +For local development without strict mode (faster iteration): |
| 80 | +```bash |
| 81 | +hatch run mkdocs serve |
| 82 | +``` |
| 83 | + |
| 84 | +Or build without strict mode: |
| 85 | +```bash |
| 86 | +hatch run mkdocs build |
| 87 | +``` |
| 88 | + |
| 89 | +**Note:** Always verify with strict mode before committing! |
| 90 | + |
| 91 | +### Serving Documentation Locally |
| 92 | + |
| 93 | +To preview documentation with live reload: |
| 94 | +```bash |
| 95 | +hatch run docs-serve |
| 96 | +``` |
| 97 | + |
| 98 | +This will start a local server at http://127.0.0.1:8000/ |
| 99 | + |
| 100 | +### Documentation Structure |
| 101 | + |
| 102 | +``` |
| 103 | +docs/ |
| 104 | +├── index.md # Home page with getting started |
| 105 | +├── plugins.md # Plugin usage examples |
| 106 | +├── reference.md # Auto-generated API reference |
| 107 | +├── session.md # Session management guide |
| 108 | +├── transport.md # Transport layer guide |
| 109 | +└── assets/ # Images and static files |
| 110 | +``` |
| 111 | + |
| 112 | +### Best Practices |
| 113 | + |
| 114 | +1. **Always build with strict mode before committing** |
| 115 | + ```bash |
| 116 | + hatch run docs-build |
| 117 | + ``` |
| 118 | + |
| 119 | +2. **Test documentation locally** |
| 120 | + ```bash |
| 121 | + hatch run docs-serve |
| 122 | + ``` |
| 123 | + |
| 124 | +3. **Keep type annotations complete** |
| 125 | + - All public functions must have type hints |
| 126 | + - Use `Any` for `**kwargs` parameters |
| 127 | + - Use `Optional` for optional parameters |
| 128 | + |
| 129 | +4. **Verify API references** |
| 130 | + - Check that all classes/functions referenced in `docs/reference.md` exist |
| 131 | + - Remove references to deleted or renamed classes |
| 132 | + - Update references when refactoring |
| 133 | + |
| 134 | +5. **Follow documentation philosophy** |
| 135 | + - Keep it simple and concise |
| 136 | + - Focus on common use cases |
| 137 | + - Don't clutter with advanced configuration details |
| 138 | + - See `.clinerules/documentation-philosophy.md` |
| 139 | + |
| 140 | +### CI/CD Integration |
| 141 | + |
| 142 | +The documentation build should be part of CI/CD pipeline: |
| 143 | +```yaml |
| 144 | +- name: Build documentation |
| 145 | + run: hatch run docs-build |
| 146 | +``` |
| 147 | +
|
| 148 | +This ensures documentation quality is maintained across all contributions. |
| 149 | +
|
| 150 | +### Troubleshooting |
| 151 | +
|
| 152 | +If documentation build fails: |
| 153 | +
|
| 154 | +1. **Read the error message carefully** - it usually points to the exact issue |
| 155 | +2. **Check the file and line number** mentioned in the error |
| 156 | +3. **Verify type annotations** are complete |
| 157 | +4. **Check API references** in `docs/reference.md` |
| 158 | +5. **Test locally** with `hatch run docs-serve` to see the issue in context |
| 159 | + |
| 160 | +### Summary |
| 161 | + |
| 162 | +- ✅ Always use `hatch run docs-build` for production builds |
| 163 | +- ✅ Strict mode is mandatory for quality assurance |
| 164 | +- ✅ Complete type annotations for all `**kwargs` |
| 165 | +- ✅ Verify all API references resolve correctly |
| 166 | +- ✅ Test locally before committing |
| 167 | +- ✅ Follow the documentation philosophy |
0 commit comments