Skip to content

Streamline docstrings and fix documentation rendering bugs - #234

Merged
azrael417 merged 2 commits into
mainfrom
tkurth/docstring-fixes
Aug 4, 2026
Merged

Streamline docstrings and fix documentation rendering bugs#234
azrael417 merged 2 commits into
mainfrom
tkurth/docstring-fixes

Conversation

@azrael417

@azrael417 azrael417 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

Docstring conventions had drifted across the package, and a few inconsistencies were actually breaking autodoc output. Since the docs have not been published yet, this is a good time to
normalize them.

Changes

Rendering bugs (visible in the built HTML)

  • examples/losses.py: two docstrings (incl. the public forward on the loss base class) were Google-style, but conf.py sets napoleon_google_docstring = False — they rendered as literal prose
    with no parameter table. Converted to NumPy style.
  • examples/models/sfno.py: Example: with a trailing colon isn't recognized by napoleon, so the header and its underline leaked into the page as raw text.
  • 10 API pages published PyTorch's boilerplate ("Define the computation performed at every call") because forward/to lack docstrings and autodoc inherits from nn.Module. Fixed with
    autodoc_inherit_docstrings = False.

Consistency (no rendering change)

  • 237 × name: type → name : type; 63 underline lengths corrected; 6 × Example → Examples.
  • Returns unified: single-value → bare type, multi-value → named entries (numpydoc convention).

Docs config

  • nitpicky = True with a small nitpick_ignore; with CI's existing -W, a broken cross-reference now fails the build instead of accumulating silently.
  • Added matplotlib to intersphinx_mapping; excluded jupyter_execute (myst-nb copies were rediscovered as source on rebuild).
  • Qualified one :class: reference in distributed_attention.py.

Testing

Full Sphinx build against the working tree: 0 warnings (down from 104 in nitpicky mode). Verified nitpicky is genuinely active by injecting a bogus reference — caught with the new config,
silent under -D nitpicky=0.

Rendered-output diff through napoleon is exactly 12 lines, all intended Returns changes — confirming the 237 colon and 63 underline edits are render-neutral. AST comparison with docstrings
stripped shows 0 non-docstring differences across all 27 files.

API / numerical behavior

None. Docstrings, docs/conf.py, and one cross-reference only; no code paths touched.

@azrael417
azrael417 requested review from apaaris and bonevbs August 4, 2026 05:38
@azrael417 azrael417 changed the title Doctoring Streamlining Docstring Streamlining Aug 4, 2026
@azrael417 azrael417 changed the title Docstring Streamlining Streamline docstrings and fix documentation rendering bugs Aug 4, 2026
@azrael417
azrael417 marked this pull request as ready for review August 4, 2026 06:24
@azrael417 azrael417 self-assigned this Aug 4, 2026
@albertocarpentieri
albertocarpentieri self-requested a review August 4, 2026 06:55

@albertocarpentieri albertocarpentieri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add build/ and *.egg-info to the .gitignore?

@albertocarpentieri albertocarpentieri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, mostly docs and formatting

@azrael417
azrael417 merged commit 887006c into main Aug 4, 2026
5 checks passed
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.

2 participants