If you repeat Sphinx directives they are separated by an empty line. For example:
Renders with a newline:
Could be changed to, which is more readable:
.. data:: ParamSpecArgs
ParamSpecKwargs
And renders without a newline:
Regexes:
\.\. attribute::.*\n \.\. attribute::
: 35 matches
\.\. data::.*\n \.\. data::
: 2 matches
\.\. decorator::.*\n \.\. decorator::
: 1 match
\.\. index::.*\n \.\. index::
: 3 matches
\.\. method::.*\n \.\. method::
: 3 matches
\.\. versionadded::.*\n \.\. versionadded::
: 1 match
\.\. versionchanged::.*\n \.\. versionchanged::
: 1 match
\.\. attribute::.*\n\.\. attribute::
: 4 matches
\.\. data::.*\n\.\. data::
: 6 matches
\.\. describe::.*\n\.\. describe::
: 1 match
\.\. exception::.*\n\.\. exception::
: 1 match
\.\. function::.*\n\.\. function::
: 11 matches
\.\. index::.*\n\.\. index::
: 2 matches
\.\. method::.*\n\.\. method::
: 2 matches
\.\. module::.*\n\.\. module::
: 1 match
\.\. moduleauthor::.*\n\.\. moduleauthor::
: 13 matches
\.\. opcode::.*\n\.\. opcode::
: 1 match
\.\. option::.*\n\.\. option::
: 17 matches
\.\. sectionauthor::.*\n\.\. sectionauthor::
: 26 matches
\.\. versionadded::.*\n\.\. versionadded::
: 4 matches
What’s your opinion?
AA-Turner
(Adam Turner)
May 6, 2024, 3:16pm
2
I think I understand your point, but the argument is fairly unclear here — especially regarding the tradeoffs w.r.t. churn.
Is there a middle ground, rather than simply arguing to change everything?
A
I would like to discuss which cases we want to change (maybe with abstract examples).
If a decision is made, I’ll update the files accordingly.
My main issue is that the description for the first definitions seems to be missing because of the empty line.
Yeah, churn counts against this, but it’s something I didn’t know about and I much prefer the tighter grouping visually.
Do we have a coding/style guide for the docs? This is probably in the category of “do it when we touch nearby docs, but don’t do it just for the sake of it”.
3 Likes
hugovk
(Hugo van Kemenade)
May 6, 2024, 4:52pm
5
There’s some earlier discussion at:
opened 08:16AM - 18 Apr 24 UTC
docs
# Documentation
If you repeat Sphinx directives they are separated by an empt… y line. For example:
https://github.com/python/cpython/blob/f70395786f6da2412d7406606feb64347fc71262/Doc/library/typing.rst?plain=1#L1974-L1975
Renders with a newline:
![image](https://github.com/python/cpython/assets/65588599/b8cababc-af5e-4f26-bd45-5c3dffa3b8b4)
Could be changed to:
```rst
.. data:: ParamSpecArgs
ParamSpecKwargs
```
Which renders without a newline:
![image](https://github.com/python/cpython/assets/65588599/bb38f6ea-a6f4-403e-b404-4bcb18623fa9)
Regexes:
- ` \.\. attribute::.*\n \.\. attribute::`: 35 matches
- ` \.\. data::.*\n \.\. data::`: 2 matches
- ` \.\. decorator::.*\n \.\. decorator::`: 1 match
- ` \.\. index::.*\n \.\. index::`: 3 matches
- ` \.\. method::.*\n \.\. method::`: 3 matches
- ~` \.\. versionadded::.*\n \.\. versionadded::`: 1 match~
- ~` \.\. versionchanged::.*\n \.\. versionchanged::`: 1 match~
- `\.\. attribute::.*\n\.\. attribute::`: 4 matches
- `\.\. data::.*\n\.\. data::`: 6 matches
- `\.\. describe::.*\n\.\. describe::`: 1 match
- `\.\. exception::.*\n\.\. exception::`: 1 match
- `\.\. function::.*\n\.\. function::`: 11 matches
- `\.\. index::.*\n\.\. index::`: 2 matches
- `\.\. method::.*\n\.\. method::`: 2 matches
- `\.\. module::.*\n\.\. module::`: 1 match
- `\.\. moduleauthor::.*\n\.\. moduleauthor::`: 13 matches
- `\.\. opcode::.*\n\.\. opcode::`: 1 match
- `\.\. option::.*\n\.\. option::`: 17 matches
- `\.\. sectionauthor::.*\n\.\. sectionauthor::`: 26 matches
- ~`\.\. versionadded::.*\n\.\. versionadded::`: 4 matches~
### Linked PRs
* gh-118154
* gh-118155
Where I concluded:
But I also couldn’t find any specific accessibility advice either way for this, and I’m not sure how much of a problem this is solving, and there’s probably more important things we can work on, so we might not want to do a full docs sweep?
nedbat
(Ned Batchelder)
May 6, 2024, 5:07pm
6
There is a style guide, both for Sphinx details (devguide: reStructuredText markup ) and English usage (the devguide section before that one).
2 Likes
It does give an example of this, but doesn’t mention the grouping explicitly:
.. function:: spam(eggs)
ham(eggs)
:noindex:
Spam or ham the foo.
It also uses the other style (reStructuredText markup ):
:mod:`parrot` -- Dead parrot access
===================================
.. module:: parrot
:platform: Unix, Windows
:synopsis: Analyze and reanimate dead parrots.
.. moduleauthor:: Eric Cleese <eric@python.invalid>
.. moduleauthor:: John Idle <john@python.invalid>
@hugovk where do we best add accessibility advice?
encukou
(Petr Viktorin)
June 20, 2024, 9:37am
9
For ReST tooling (e.g. showing ParamSpecArgs
docs for an IDE tooltip), grouped is better: the following paragraphs are attached to all of the definitions. Ungrouped means there’s, semantically, an extra entry with just a signature.
This shows up in the HTML structure too. I don’t know what the effect on screen readers is, but proper structure can’t hurt :‍)