Skip to content

Conversation

@ryuwd
Copy link
Contributor

@ryuwd ryuwd commented Nov 7, 2025

Description

This PR extends #698 (settings-doc) by adding comprehensive documentation infrastructure for DiracX's REST API routes and Python API reference using mkdocstrings, Griffe, and Griffe-Pydantic.

Changes Summary

OpenAPI Routes Documentation

  • scripts/generate_openapi_spec.py - Generates OpenAPI specification from FastAPI app (27 paths, 35 schemas)
  • docs/dev/reference/routes/index.md - REST API routes documentation using neoteroi plugin
  • Automatic OpenAPI spec generation before each docs build via pixi task dependency

Python API Reference Documentation

  • Created 93+ API reference pages covering all major DiracX modules:

    • Core: models, settings, preferences, config, exceptions, resources, S3, properties, extensions, utils
    • Routers: jobs, auth, configuration, health, access policies, dependencies, factory, FastAPI classes, otel, utils
    • Logic: jobs, auth, task queues
    • Database: job, job_logging, auth, sandbox_metadata, task_queue, pilot_agents, dummy, opensearch, utils, exceptions
    • CLI: jobs, auth, config, internal, utils
  • docs/dev/reference/api/writing-api-docs.md - Comprehensive guide for writing API documentation with Google-style docstrings

  • docs/dev/reference/api/CONTRIBUTING.md - Guidelines for maintaining API documentation

  • docs/dev/reference/api/check_coverage.py - Pre-commit hook ensuring complete API coverage

Extension Entry Points Documentation

  • Pre-commit hook (generate-entrypoints-docs) ensures entry point documentation stays synchronized with code
  • scripts/generate_entrypoints_docs.py - Automatically generates documentation for DiracX extension entry points
  • docs/dev/reference/entrypoints.md - Auto-generated reference cataloging all available entry points for creating DiracX extensions

Documentation Tooling

  • mkdocstrings + griffe + griffe-pydantic for automatic Python API documentation

    • Field-level Pydantic model documentation with constraints and defaults
    • Type annotations and docstring extraction
    • Source code links
    • Google-style docstring parsing
  • neoteroi-mkdocs for OpenAPI specification rendering

    • Renders all 27 API paths and 35 schemas
    • Interactive route browser with HTTP methods and parameters

Configuration Updates

  • Updated mkdocs.yml with:

    • mkdocstrings Python handler configuration with griffe-pydantic extension
    • Navigation structure for API Reference and Routes sections
    • neoteroi CSS styling for OpenAPI documentation
    • Global setting: show_if_no_docstring: true (see Open Questions)
  • Updated pixi.toml with:

    • generate-openapi-spec task for OpenAPI generation
    • mkdocs-build task now depends on OpenAPI generation
    • Separate mkdocs environment with all documentation dependencies
  • Updated .pre-commit-config.yaml:

    • settings-doc-check hook to validate settings documentation
    • api-doc-check hook to ensure API documentation coverage
    • Excluded docs/dev/reference/api/ from mdformat (preserves mkdocstrings directive indentation)

Example Documentation

  • Enhanced JobDB class in diracx-db/src/diracx/db/sql/job/db.py with comprehensive docstrings as a reference example showing:
    • Class-level documentation
    • Method parameter descriptions with types
    • Return type documentation
    • Exception documentation
    • Real-world usage examples

Open Questions & Discussion Points

1. Which docstring format to use?

This PR: Google-style docstrings (couldn't really find a consensus yet in the codebase)

Others are supported:
https://mkdocstrings.github.io/griffe/reference/docstrings/

2. API Documentation Coverage

Current approach: Pre-commit hook that checks all Python modules have corresponding .md files in docs/dev/reference/api/.

Is there a nicer way?

3. show_if_no_docstring: true

Current setting: Enabled globally in mkdocs.yml

Rationale:

  • Shows all public functions/classes even if undocumented
  • Makes it obvious what's missing docs

Trade-off:

  • May expose internal implementation details
  • Creates "pressure" to document everything (which might be good?)

Should undocumented members be visible in API docs, or should we require docstrings before showing them?

4. Documentation Organization

Current structure: Organized by package (core, routers, logic, db, cli)

It's a bit difficult to read the pages and navigate. Open to suggestions!

5. Example Documentation Density

Current approach: Added comprehensive examples to JobDB class as a reference

6. Pydantic Model Documentation

Griffe-Pydantic automatically extracts:

  • Field types and constraints
  • Default values
  • Validation rules (min/max length, regex patterns, numeric bounds)
  • Field descriptions from Field(description=...)

Do we need anything else?

7. Adding docstrings where missing

self explanatory

Dependencies

This PR builds on the settings documentation work from #698 and uses similar infrastructure (auto-discovery, validation).

@read-the-docs-community
Copy link

read-the-docs-community bot commented Nov 7, 2025

Documentation build overview

📚 diracx | 🛠️ Build #30250995 | 📁 Comparing fbc12ef against latest (c265a47)


🔍 Preview build

Show files changed (158 files in total): 📝 116 modified | ➕ 42 added | ➖ 0 deleted
File Status
404.html 📝 modified
index.html 📝 modified
REFERENCE/index.html 📝 modified
RUN_PROD/index.html 📝 modified
SECURITY/index.html 📝 modified
SSO/index.html 📝 modified
admin/index.html 📝 modified
dev/index.html 📝 modified
roadmap/index.html 📝 modified
user/index.html 📝 modified
admin/deploy_instance/index.html 📝 modified
admin/explanations/index.html 📝 modified
admin/how-to/index.html 📝 modified
admin/manage_dependencies/index.html 📝 modified
admin/manage_release/index.html 📝 modified
admin/reference/index.html 📝 modified
admin/tutorials/index.html 📝 modified
dev/explanations/index.html 📝 modified
dev/how-to/index.html 📝 modified
dev/manage_extension/index.html 📝 modified
dev/reference/index.html 📝 modified
dev/setup_environment/index.html 📝 modified
dev/tutorials/index.html 📝 modified
dev/web-arch/index.html 📝 modified
developer/contribute/index.html 📝 modified
developer/manage_extension/index.html 📝 modified
developer/setup_environment/index.html 📝 modified
user/explanations/index.html 📝 modified
user/how-to/index.html 📝 modified
user/reference/index.html 📝 modified
user/tutorials/index.html 📝 modified
user/web/index.html 📝 modified
admin/explanations/auth-with-diracx/index.html 📝 modified
admin/explanations/auth-with-external/index.html 📝 modified
admin/explanations/chart-structure/index.html 📝 modified
admin/explanations/configuration/index.html 📝 modified
admin/explanations/database-management/index.html 📝 modified
admin/explanations/opentelemetry/index.html 📝 modified
admin/explanations/sandbox-store/index.html 📝 modified
admin/explanations/user-management/index.html 📝 modified
admin/how-to/debugging/index.html 📝 modified
admin/how-to/install/index.html 📝 modified
admin/how-to/rotate-a-secret/index.html 📝 modified
admin/how-to/upgrading/index.html 📝 modified
admin/reference/env-variables/index.html 📝 modified
admin/reference/security_model/index.html 📝 modified
admin/reference/settings-and-preferences/index.html 📝 modified
admin/reference/values/index.html 📝 modified
admin/tutorials/authentication/index.html 📝 modified
admin/tutorials/run_locally/index.html 📝 modified
dev/explanations/components/index.html 📝 modified
dev/explanations/designing-functionality/index.html 📝 modified
dev/explanations/extensions/index.html 📝 modified
dev/explanations/run_demo/index.html 📝 modified
dev/explanations/testing/index.html 📝 modified
dev/how-to/add-a-cli-command/index.html 📝 modified
dev/how-to/add-a-db/index.html 📝 modified
dev/how-to/add-a-route/index.html 📝 modified
dev/how-to/add-a-setting/index.html 📝 modified
dev/how-to/add-a-task/index.html 📝 modified
dev/how-to/add-a-test/index.html 📝 modified
dev/how-to/add-functionality/index.html 📝 modified
dev/how-to/client-customization/index.html 📝 modified
dev/how-to/client-extension/index.html 📝 modified
dev/how-to/client-generation/index.html 📝 modified
dev/how-to/contribute/index.html 📝 modified
dev/how-to/create_application/index.html 📝 modified
dev/how-to/develop-legacy-dirac/index.html 📝 modified
dev/how-to/extend-diracx/index.html 📝 modified
dev/how-to/use-the-demo/index.html 📝 modified
dev/reference/api/index.html ➕ added
dev/reference/application-state/index.html 📝 modified
dev/reference/client-metapathfinder/index.html 📝 modified
dev/reference/coding-conventions/index.html 📝 modified
dev/reference/configuration/index.html 📝 modified
dev/reference/db-transaction-model/index.html 📝 modified
dev/reference/dependency-injection/index.html 📝 modified
dev/reference/entrypoints/index.html 📝 modified
dev/reference/env-variables/index.html 📝 modified
dev/reference/pixi-tasks/index.html 📝 modified
dev/reference/routes/index.html ➕ added
dev/reference/security-policies/index.html 📝 modified
dev/reference/security-properties/index.html 📝 modified
dev/reference/test-recipes/index.html 📝 modified
dev/reference/writing-tests/index.html 📝 modified
dev/tutorials/advanced-tutorial/index.html 📝 modified
dev/tutorials/develop-web/index.html 📝 modified
dev/tutorials/getting-started/index.html 📝 modified
dev/tutorials/larger-developments/index.html 📝 modified
dev/tutorials/making-changes/index.html 📝 modified
dev/tutorials/play-with-auth/index.html 📝 modified
dev/tutorials/run-locally/index.html 📝 modified
dev/tutorials/write-docs/index.html 📝 modified
user/reference/client-configuration/index.html 📝 modified
user/reference/known-installations/index.html 📝 modified
user/reference/programmatic-usage/index.html 📝 modified
user/tutorials/getting-started/index.html 📝 modified
user/web/list_and_share_applications/index.html 📝 modified
user/web/login_out/index.html 📝 modified
user/web/monitor_jobs/index.html 📝 modified
admin/how-to/install/connect/index.html 📝 modified
admin/how-to/install/convert-cs/index.html 📝 modified
admin/how-to/install/embracing/index.html 📝 modified
admin/how-to/install/install-kubernetes/index.html 📝 modified
admin/how-to/install/installing/index.html 📝 modified
admin/how-to/install/minimal-requirements/index.html 📝 modified
admin/how-to/install/register-a-vo/index.html 📝 modified
admin/how-to/install/register-the-admin-vo/index.html 📝 modified
dev/explanations/components/api/index.html 📝 modified
dev/explanations/components/cli/index.html 📝 modified
dev/explanations/components/client/index.html 📝 modified
dev/explanations/components/db/index.html 📝 modified
dev/explanations/components/routes/index.html 📝 modified
dev/how-to/use-the-demo/swagger/index.html 📝 modified
dev/how-to/use-the-demo/web/index.html 📝 modified
dev/reference/api/CONTRIBUTING/index.html ➕ added
dev/reference/api/cli/index.html ➕ added
dev/reference/api/core/index.html ➕ added
dev/reference/api/db/index.html ➕ added
dev/reference/api/logic/index.html ➕ added
dev/reference/api/routers/index.html ➕ added
dev/reference/api/writing-api-docs/index.html ➕ added
user/reference/programmatic-usage/command-line-interface/index.html 📝 modified
user/reference/programmatic-usage/https-interface/index.html 📝 modified
user/reference/programmatic-usage/python-interface/index.html 📝 modified
dev/reference/api/core/config/index.html ➕ added
dev/reference/api/core/exceptions/index.html ➕ added
dev/reference/api/core/extensions/index.html ➕ added
dev/reference/api/core/models/index.html ➕ added
dev/reference/api/core/preferences/index.html ➕ added
dev/reference/api/core/properties/index.html ➕ added
dev/reference/api/core/resources/index.html ➕ added
dev/reference/api/core/s3/index.html ➕ added
dev/reference/api/core/settings/index.html ➕ added
dev/reference/api/core/utils/index.html ➕ added
dev/reference/api/db/auth/index.html ➕ added
dev/reference/api/db/dummy/index.html ➕ added
dev/reference/api/db/exceptions/index.html ➕ added
dev/reference/api/db/job/index.html ➕ added
dev/reference/api/db/job_logging/index.html ➕ added
dev/reference/api/db/opensearch/index.html ➕ added
dev/reference/api/db/pilot_agents/index.html ➕ added
dev/reference/api/db/sandbox_metadata/index.html ➕ added
dev/reference/api/db/task_queue/index.html ➕ added
dev/reference/api/db/utils/index.html ➕ added
dev/reference/api/logic/auth/index.html ➕ added
dev/reference/api/logic/jobs/index.html ➕ added
dev/reference/api/logic/task_queues/index.html ➕ added
dev/reference/api/routers/access_policies/index.html ➕ added
dev/reference/api/routers/auth/index.html ➕ added
dev/reference/api/routers/configuration/index.html ➕ added
dev/reference/api/routers/dependencies/index.html ➕ added
dev/reference/api/routers/factory/index.html ➕ added
dev/reference/api/routers/fastapi_classes/index.html ➕ added
dev/reference/api/routers/health/index.html ➕ added
dev/reference/api/routers/jobs/index.html ➕ added
dev/reference/api/routers/otel/index.html ➕ added
dev/reference/api/routers/utils/index.html ➕ added

@ryuwd ryuwd changed the title docs: api reference using mkdocstrings, griffe and griffe-pydantic with coverage checker docs: add comprehensive API Reference documentation with mkdocstrings, griffe and griffe-Pydantic Nov 9, 2025
@ryuwd ryuwd changed the title docs: add comprehensive API Reference documentation with mkdocstrings, griffe and griffe-Pydantic docs: add comprehensive API Reference documentation with mkdocstrings, griffe and griffe-pydantic Nov 9, 2025
ryuwd added 3 commits November 9, 2025 01:15
Add comprehensive REST API route documentation automatically generated
from the OpenAPI specification using the neoteroi-mkdocs plugin.

Changes:
- Add neoteroi CSS styling (v1.1.3) for OpenAPI documentation rendering
- Create generate_openapi_spec.py script to generate docs/openapi.json
- Add docs/dev/reference/routes/index.md with route documentation page
- Integrate neoteroi.mkdocsoad plugin in mkdocs.yml configuration
- Add generate-openapi-spec pixi task for OpenAPI spec generation
- Make mkdocs-build depend on generate-openapi-spec task
- Add generate-entrypoints-docs pre-commit hook
- Exclude docs/dev/reference/api/ from mdformat to preserve indentation
- Ignore generated docs/openapi.json and Copilot instructions in git
- Update routers index page to clarify REST API vs infrastructure docs
- Fix mkdocstrings directive indentation across API reference docs
- Enhance router documentation with better descriptions and examples

The OpenAPI spec generation uses test fixtures similar to the test suite,
creating a minimal DiracX app with test auth settings, config repository,
and database URLs. The spec is generated before each documentation build.

The neoteroi plugin renders the OpenAPI spec into human-readable route
documentation with request/response examples, while mdformat exclusion
preserves the required indentation for mkdocstrings YAML options.
@ryuwd ryuwd changed the title docs: add comprehensive API Reference documentation with mkdocstrings, griffe and griffe-pydantic docs: add OpenAPI routes documentation and add autogenerated API reference with mkdocstrings Nov 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant