Skip to content

Documentation: format docstrings for dev docs#3353

Open
C-Achard wants to merge 29 commits into
arash/dev_docsfrom
cy/dev-docs-formatting
Open

Documentation: format docstrings for dev docs#3353
C-Achard wants to merge 29 commits into
arash/dev_docsfrom
cy/dev-docs-formatting

Conversation

@C-Achard
Copy link
Copy Markdown
Collaborator

@C-Achard C-Achard commented Jun 1, 2026

  • Fixes docstring formatting via ruff
  • Enforces consistent style for all docstrings across tools
  • Added a currently inactive mdformat hook for dev docs
    • An issue with the mdformat-mkdocs plugin breaks all autoref links

Warning

This runs mdformat on all docs, which may conflict with the docs audit.
We may want to revert c99aa9d to prevent issues.

See #3336

C-Achard added 6 commits June 1, 2026 11:32
Add mdformat pre-commit hook (rev 1.0.0) with mdformat-myst to format Markdown files under docs/*.md. Update local pre-commit hook to exclude tools/docs_audits/ from the docs/notebooks checks. Also include tools/**/*.md in the docs_and_notebooks_report scan and add tools/docs_audits/** to its exclude list to avoid auditing generated/temporary audit files.
Align docstring and formatting settings to the NumPy convention: set docstring_style to 'numpy' and increase line_length to 120 in dev-docs/mkdocs.yml; update [tool.ruff.lint.pydocstyle] convention to 'numpy' and enable [tool.ruff.format].docstring-code-format in pyproject.toml. These changes ensure consistent docstring parsing/formatting across documentation tooling and linters.
Comment out the mdformat hook in .pre-commit-config.yaml because it currently breaks autorefs by replacing them with escaped links. Add explanatory comments and link to the related issue (KyleKing/mdformat-mkdocs#80). The commented block also shows a potential workaround pin (mdformat-mkdocs==5.2.0b2) for reference.
@C-Achard C-Achard self-assigned this Jun 1, 2026
@C-Achard C-Achard added enhancement New feature or request documentation documentation updates/comments labels Jun 1, 2026
This reverts commit c99aa9d.
@C-Achard C-Achard requested a review from deruyter92 June 1, 2026 09:58
Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 left a comment

Choose a reason for hiding this comment

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

I really like the idea in this PR, but would prefer to use google style instead of numpy.
By far most of our codebase currently uses google style (which is also our recommended style I believe?). If we want to align everything in google style, only a small fraction of the codebase would need to be readjusted (~36 files according to Claude).

What would you think about the following approach?

  • Settle on google style in pyproject.toml (as it was), mkdocs.yml, and sphinx (using sphinx.ext.napoleon)
  • Use a basic conversion tool (e.g. pyment for the trivial conversions numpy -> google in ~36 files)
  • Manual review for these files
  • Agent-supported review for the more difficult (e.g. mixed) cases
  • Linting to enforce

Comment thread .pre-commit-config.yaml

# - repo: https://github.com/hukkin/mdformat
# Broken currently, replaces all autorefs with broken escaped links.
# See https://github.com/KyleKing/mdformat-mkdocs/issues/80
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.

Let's keep an eye on this issue.

Comment thread pyproject.toml Outdated
"*.ipynb" = [ "E402" ]
[tool.ruff.lint.pydocstyle]
convention = "google"
convention = "numpy"
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.

I think we should stick with google style.

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.

We currently mix both, but google seems to be most prevalent:

Style marker Occurrences Files Where
Google Args: ~501 ~131
Google Returns: ~370 ~119 Newer API (e.g. all pose_estimation_pytorch/
NumPy Parameters ~66 ~36
NumPy Returns ~31 ~17 Mostly older API (e.g. create_project/)

(This requires us to update the mkdocs.yml accordingly)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, I'm also in favor of making a minimal amount of changes and on a personal level prefer google style, so I definitely agree.

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.

I'll give it a try right now

None.
copy_videos (bool, optional): If this is set to True, the videos are copied to
the ``videos`` directory. If it is False, symlink of the videos are copied
to the project/videos directory. Note: on Windows: True is often necessary!
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
to the project/videos directory. Note: on Windows: True is often necessary!
to the project/videos directory. Note: on Windows, True is necessary when not running in Administrator mode. The same applies whenever symlinks are disabled or unsupported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation documentation updates/comments enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants