Skip to content

[Docs]: Fix API Reference rendering — add model docstrings and tune mkdocstrings config #229

@Vraj1234

Description

@Vraj1234

Location of the issue

  • docs/api/datamodels.md — rendered from src/ca_biositing/datamodels/ca_biositing/datamodels/models/** (71 model files)
  • docs/api/pipeline.md — rendered from src/ca_biositing/pipeline/
  • mkdocs.yml lines 19–32 (mkdocstrings handler config)
  • docs/stylesheets/api-reference.css

Suggested fix or improvement

The API Reference pages for Datamodels and Pipeline render poorly — walls of nested headings with no explanatory text. The root cause is two compounding problems:


1. Missing class-level docstrings (primary cause)

71 model files across the datamodels package have no class-level docstrings. Every class is just a field list, for example:

```python
class EtlRun(SQLModel, table=True):
tablename = "etl_run"
id: Optional[int] = Field(default=None, primary_key=True)
run_id: Optional[str] = Field(default=None)
started_at: Optional[datetime] = Field(default=None)
...
```

When mkdocstrings renders this, it produces a heading with the class name and then a list of field headings, with zero prose between them. Multiply this across 50+ classes in 14 domain sections and the page becomes an unreadable sequence of headings.

Fix: Add a one-sentence docstring to each class explaining what it represents and when you'd use it. Example:

```python
class EtlRun(SQLModel, table=True):
"""Records a single execution of the ETL pipeline, including status, timing, and record counts."""
```

This is ~71 files, but most classes are simple — estimated 3–4 hours for someone with domain knowledge of the schema.


2. mkdocstrings config amplifies the problem

Three config issues make the sparse output worse:

  • heading_level: 2 in mkdocs.yml — classes render as ## (h2), their fields as #### (h4). With no prose between the levels, the nesting looks broken and is hard to scan.
  • show_if_no_docstring: true in docs/api/datamodels.md — forces every undocumented class to render, producing long pages of bare headings even when there is nothing useful to show.
  • Aggressive CSS in docs/stylesheets/api-reference.css — compresses margins and line-height to near-zero, making the already-dense output even harder to read.

Quick config fixes (~1 hour, no docstring work needed):

  • Change heading_level from 2 to 3 in mkdocs.yml to reduce nesting depth
  • Change show_if_no_docstring from true to false in both API markdown files so undocumented classes are hidden until they get docstrings
  • Loosen the spacing in api-reference.css — the current compression was added to work around the nesting problem but makes it worse

Recommended approach

Do the config fixes first (fast, immediate improvement), then tackle docstrings incrementally — even partial coverage is better than none, and show_if_no_docstring: false means undocumented classes simply won't appear until they're ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions