Skip to content

Auto-Generate Service API Docs from Source #204

@jonathanMLDev

Description

@jonathanMLDev

Problem

The project maintains per-app service_api/ reference docs by hand, documenting the public functions in each app's services.py. With 15 Django apps and a service layer convention that channels all database writes through services.py, keeping these references synchronized with the source is labor-intensive and error-prone. The review eval (Section 5.6) notes that the documentation corpus is "atypically mature" but the gap is in machine-verified freshness — there is no tooling to detect when a service function signature changes without a corresponding doc update. This creates a drift risk as the codebase grows.

Acceptance Criteria

  • A script (e.g., scripts/generate_service_docs.py) introspects all */services.py modules, extracts public function signatures and docstrings, and generates markdown reference pages
  • Generated output matches or improves upon the existing service_api/ format (function name, parameters, return type, docstring summary)
  • A CI step (or pre-commit hook) validates that generated docs are up-to-date; PR fails if services.py changes without a doc regeneration
  • Existing hand-written content in service_api/ is preserved where it adds context beyond what introspection captures (e.g., usage notes, cross-app dependency warnings)
  • README or docs/Contributing.md updated to document the generation workflow

Implementation Notes

Python's inspect module or AST parsing (ast.parse) can extract function signatures from each app's services.py. Consider using griffe or pdoc as a lightweight doc generator if custom AST walking is too brittle. The existing service_api/ docs follow a consistent markdown template — generate into the same format for a clean diff. A --check mode (exit non-zero if output differs from committed files) integrates cleanly into the existing CI pipeline at .github/workflows/actions.yml. The core.protocols module's @runtime_checkable DTO protocols (TrackerResult, ActivityRecord, IncrementalState) should also appear in the generated output since they define the service layer's data contracts.

References

  • Eval finding: Test 16 (Documentation Completeness)
  • Related files: service_api/*.md, */services.py (15 apps), docs/Core_public_API.md, docs/Contributing.md, .github/workflows/actions.yml

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions