API Reference Documentation
This directory contains auto-generated API reference documentation for DiracX packages.
Structure
The API reference is organized by package:
- core/ - Core functionality (models, settings, configuration)
- routers/ - FastAPI routers and endpoints
- logic/ - Business logic layer
- db/ - Database models and access layers
- cli/ - Command-line interface
Maintaining Documentation
Checking Coverage
To ensure all modules are documented, run the coverage check script:
This will report any Python modules that are missing documentation pages.
Adding Documentation for New Modules
When you add a new Python module, you need to add corresponding documentation:
-
Create a new .md file in the appropriate section directory (core/, routers/, logic/, db/, or cli/)
-
Add module references using the
:::syntax: -
Update the navigation in
mkdocs.yml: -
Update the index page (e.g.,
logic/index.md) to link to your new page -
Run the coverage check to verify your documentation is complete
Documentation Options
The ::: directive supports various options to control how documentation is rendered:
show_root_heading: true- Show the module name as a headingshow_source: true- Show source code linksmembers_order: source- Order members as they appear in sourcegroup_by_category: true- Group by functions, classes, etc.show_if_no_docstring: true- Show members even without docstringsfilters: ["!^_"]- Hide private members (starting with _)
For more options, see the mkdocstrings-python documentation.
Writing Good Docstrings
The API reference is auto-generated from docstrings in the source code. Follow these guidelines:
-
Use Google-style docstrings:
-
Document Pydantic models using Field descriptions:
-
Document FastAPI endpoints with clear descriptions:
@router.post("/jobs") async def submit_job(job: JobDefinition) -> InsertedJob: """Submit a new job to the system. This endpoint accepts a job definition and submits it to the task queue for processing. Args: job: The job definition to submit Returns: Information about the inserted job including job ID """
Troubleshooting
Module not showing up
If a module isn't rendering in the docs:
- Check that the module path is correct (must point to actual
.pyfiles, not empty__init__.py) - Verify the module is in the
pathslist inmkdocs.ymlunder the mkdocstrings config - Run
python check_coverage.pyto see if it's detected
Decorators not showing
FastAPI route decorators (like @router.post("/path")) are visible in the "Source code" section when you expand it. They are not displayed separately by default.
Empty documentation
If a module shows up but has no content:
- Check that the module actually has functions/classes (not just an empty
__init__.py) - Ensure docstrings are present in the source code
- Use
show_if_no_docstring: trueto show members even without docs
Setup
The API reference is generated using:
- mkdocstrings - Plugin for generating API documentation
- mkdocstrings-python - Python handler for mkdocstrings
- griffe - Python code parser
- griffe-pydantic - Extension for enhanced Pydantic model documentation
Configuration is in mkdocs.yml (search for mkdocstrings plugin).