Skip to content

docs: convert public-API docstrings to NumPy style + enforce convention#856

Merged
chaoming0625 merged 1 commit into
masterfrom
worktree-docstrings-numpy
Jun 19, 2026
Merged

docs: convert public-API docstrings to NumPy style + enforce convention#856
chaoming0625 merged 1 commit into
masterfrom
worktree-docstrings-numpy

Conversation

@chaoming0625

Copy link
Copy Markdown
Member

Summary

Standardize BrainPy's public-API docstrings on NumPy-doc style (per CLAUDE.md) and configure the toolchain to enforce it.

  • Convert all Google-style (Args: / Returns: / Raises:) and broken-RST (Parameters:: / Returns:: / :param:) docstrings of public APIs to NumPy style across 142 modules.
  • Reformat the shared parameter fragments in brainpy/dyn/_docs.py and align their %s / {} injection indentation (lif.py, base.py) so napoleon parses every injected Parameters section correctly.

Config

  • docs/conf.py: pin napoleon to NumPy style (napoleon_google_docstring=False, napoleon_numpy_docstring=True, plus use_param / use_rtype / preprocess_types).
  • pyproject.toml: record [tool.pydocstyle] convention = "numpy" as the single source of truth for the convention.

Safety / verification

  • Format-only: with docstrings stripped, the AST of every one of the 141 touched source modules is byte-identical to before (the only non-docstring diffs are the intended _docs.py string-constant values and docs/conf.py config).
  • import brainpy succeeds; public attribute access works.
  • napoleon parses all 1256 public Parameters sections — 0 parse errors, 0 empty sections.
  • No remaining Args: / ::-style / :param / single-colon section markers in non-test code.
  • Targeted tests in converted areas pass.

Convert all Google-style (`Args:`/`Returns:`) and broken-RST
(`Parameters::`/`Returns::`/`:param:`) docstrings of public APIs to
NumPy-doc style across 142 modules. Reformat the shared parameter
fragments in `brainpy/dyn/_docs.py` and align their `%s`/`{}` injection
indentation (lif.py, base.py) so napoleon parses every injected
`Parameters` section correctly.

Config:
- docs/conf.py: pin napoleon to NumPy style (google off, numpy on, plus
  use_param/use_rtype/preprocess_types).
- pyproject.toml: record `[tool.pydocstyle] convention = "numpy"` as the
  single source of truth for the docstring convention.

Format-only change: with docstrings stripped, the AST of every one of the
141 touched source modules is byte-identical to before. napoleon parses
all 1256 public `Parameters` sections with zero errors and zero empty
sections.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @chaoming0625, your pull request is larger than the review limit of 150000 diff characters

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file build labels Jun 19, 2026
@chaoming0625 chaoming0625 merged commit 01aa0c8 into master Jun 19, 2026
14 checks passed
@chaoming0625 chaoming0625 deleted the worktree-docstrings-numpy branch June 19, 2026 04:46
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

build dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant