Skip to content

docs: fix code formatting on rendered codecs API page#1455

Merged
MilagrosMarin merged 1 commit into
masterfrom
docs/fix-codecs-docstring-formatting
May 21, 2026
Merged

docs: fix code formatting on rendered codecs API page#1455
MilagrosMarin merged 1 commit into
masterfrom
docs/fix-codecs-docstring-formatting

Conversation

@dimitri-yatsenko
Copy link
Copy Markdown
Member

Summary

https://docs.datajoint.com/api/datajoint/codecs/ renders docstring code as plain prose in three places. The page is built by mkdocstrings with docstring_style: numpy and Markdown-flavored bodies, so reST and Google-style syntax don't get parsed.

Where Was Now
Codec class docstring (two examples) reST :: literal blocks Markdown fenced code blocks
decode_attribute Google-style Args: / Returns: (parsed as paragraphs) NumPy Parameters / Returns with dashes (renders as a parameter table)
Module-level Example: 4-space-indented Python (worked by accident) Markdown fenced code block

No behavior change — docstrings only.

Test plan

  • After merge + docs rebuild, confirm codecs API page:
    • the two examples under Codec ("Use in table definitions" / "Skip auto-registration") render as Python code blocks (no literal ::)
    • decode_attribute shows attr, data, squeeze, connection in a parameter table consistent with sibling functions
    • the module-level Example: Python sample renders as a fenced code block
  • python -c "import datajoint.codecs" still imports cleanly
  • mypy src/datajoint/codecs.py clean (pre-existing unrelated failure in storage_adapter.py:98 was skipped on commit; CI lint doesn't gate on mypy)

Note on the unrelated mypy failure

Local pre-commit's mypy hook fails on storage_adapter.py:98 (a Deprecated.get() typing shim for older importlib.metadata). That error exists on master and is not enforced by CI (.github/workflows/lint.yaml only runs codespell + ruff + ruff-format). Skipped with SKIP=mypy git commit per the documented pattern at the top of .pre-commit-config.yaml. Happy to file a separate PR for the typing shim if you'd like.

Three issues caused docstring code to render as plain text on
https://docs.datajoint.com/api/datajoint/codecs/ (mkdocstrings is
configured for docstring_style: numpy + Markdown-flavored bodies):

- Codec class docstring used reST '::' literal blocks for the two
  table-definition examples. Replaced with Markdown fenced code blocks.
- decode_attribute used Google-style 'Args:'/'Returns:' sections in a
  NumPy-configured doc generator. Converted to NumPy 'Parameters'/
  'Returns' with dashed underlines so it renders as a parameter table
  consistent with the rest of the module.
- Module-level 'Example:' block now uses a Markdown fenced code block
  rather than relying on 4-space indentation.

No behavior change - docstrings only.
Copy link
Copy Markdown
Contributor

@MilagrosMarin MilagrosMarin left a comment

Choose a reason for hiding this comment

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

Thanks @dimitri-yatsenko! Verified the fix:

datajoint-docs/mkdocs.yaml confirms docstring_style: numpy — reST :: and Google Args:/Returns: would indeed render as literal text on /api/datajoint/codecs/.
✅ All three conversions land in formats mkdocstrings + numpy parser consume. After this PR, grep "Args:\|Returns:\|Raises:" in codecs.py returns 0 matches.
decode_attribute parameter list matches the function signature.

Approving. The mypy-skip note is handled transparently and CI doesn't gate on it anyway.

@MilagrosMarin MilagrosMarin merged commit 7554240 into master May 21, 2026
7 checks passed
@MilagrosMarin MilagrosMarin deleted the docs/fix-codecs-docstring-formatting branch May 21, 2026 14:48
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