numpydoc: add a recommandation on doc-styles for section entries that have a description
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- documentation
Research direction
Start with docs/format.rst, which the issue names as the style guide to update, and review its section spacing rules and examples. The issue also suggests updating docs/example.py; confirm whether its examples cover the affected definition list sections. Done means the guide recommends a blank line after described entries while leaving undescribed listings compact, with relevant examples updated.
Written by the indexing model from the issue text.
Description
Style guide: recommend a blank line between section entries that have a description
This issue aims to improve the readability and maintainability of docstrings with long descriptions and/or many entries.
Background
The style guide states that "Line spacing and indentation are significant and should be carefully followed", but it is silent on the whitespace between the entries of a section. Its examples all use the compact ("tight") layout:
Parameters
----------
x : type
Description of parameter `x`.
y : type
Description of parameter `y`.
For projects that have classes or functions with many parameters, or that need very precise field descriptions, the "tight" layout reduces docstring readability in the source code.
Proposal
Add an explicit recommendation to format.rst (and update the examples to match):
When an entry of a section (
Parameters,Attributes,Returns,Yields,Receives,Other Parameters,Raises, …) has a multi-line description, i.e., an indented definition block, insert a blank line after the description, before the next entry.
Entries consisting of a single line with no description are exempt, so compact listings stay compact when there is no need for over-spaced docstrings.
With that rule, the recommended form of the example above becomes:
Parameters
----------
x : type
Description of parameter `x`.
y : type
Description of parameter `y`.
While undescribed listings remain unchanged:
Parameters
----------
*args
**kwargs
Attributes
----------
real
imag
Motivation
-
Readability in text terminals and IDEs, which the guide explicitly prioritizes ("human readers of the text are given precedence"). With multi-line descriptions, the compact layout blurs where one parameter ends and the next begins; the blank line makes the entry boundary unambiguous, and its indentation (the description is indented, the next term is not) makes the required whitespace mechanically detectable.
-
Rendered output: in the loose layout each description is a paragraph, so the HTML/PDF output visibly separates entries, matching how readers parse them in the source.
-
Tooling: a single documented convention lets pydocstyle/ruff add an autofixable check; today every project encodes the opposite house rule in editorconfig/lint configs and the ecosystem cannot converge.
-
Consistency with existing whitespace guidance: the guide already mandates precise whitespace around headers and between Examples; the entry boundary is the last unspecified spacing rule.
Open questions
SHOULD(recommend, allow legacy compact code) orMUST(validate)? I suggest recommending it for new docstrings without a mass-reformat of the existing stack. The idea is to build consensus and a written rule, not to force a massive reformat on all users.- Should the rule apply to
See Alsotwo-line entries as well, or only to definition-list sections? In my opinion, it should be limited to definition-list sections only. It wouldn't make sense to over-space sections that just convey free-text information.
Happy to discuss this with you and to send a PR against docs/format.rst (and docs/example.py) once there is consensus.
- Dominant language
- Python
- Stars
- 355
- Forks
- 184
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from numpy/numpydoc
-
Don't require ``RT01`` for propertiesMay be free again @Nani-2007-code claimed this 38 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
-
DOC: Version link overflowing on navbarMay be free again @swoyer2 claimed this 60 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
-
needs-decision
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choicePossibly taken @beartester34 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelscope/evalscope#2330 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Distribution plot crashes when a numeric feature is constant in the train or test setPossibly taken @adembilge claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
MAIF/shapash#847 · 1 comment ·
Maintainers usually reply within 10 days
-
enhancement
Difficulty 1/5 1-3 hours Newbie friendliness 76/100
AgriciDaniel/claude-obsidian#223 ·