Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-101100: Fix sphinx warnings inenum
module#101122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
CAM-Gerlach left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In general, unfortunately none of these changes are actually the correct fix, and many are in fact regressions. Some common themes:
- Method/attribute names should use be
literal
, notitalic (reserved for parameters), and genericobject
methods/attributes can be either linked with:meth:`~object.__dunder__`
, or unlinked with:meth:`!__dunder__`
(see thereST markup quick reference in the devguide) - If the ref target actually exists,
!
should not be used unless it would be repeating the same link within the same information unit (paragraph, description block, etc—seeStyle guide suggestion: Avoid duplicate links docs-community#52 ) - If the ref target does not and should not exist, and the original usage did not prefix a method, attribute, etc. name with the class or module it belongs to, and it is unambiguous in context, then it shouldn't be added when making it an unresolved reference (seeStyle guide suggestion: Avoid duplicate links docs-community#52 again)
- If the ref target does not exist, but potentially should be documented, then it is a valid warning that should either be documented or left as-is a rather than silenced (see what we did in
sqlite3
).
Etc., see individual comments on each change for more details and the suggested fixes to each.
Doc/library/enum.rst Outdated
- The class``Color`` is an *enumeration* (or *enum*) | ||
- The attributes``Color.RED``, ``Color.GREEN``, etc., are |
CAM-GerlachJan 18, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If@ethanfurman prefers these to be verbatim code literals, as you've changed them to, instead of marked-up classes and attributes as they were before, then that's fine—it is a bit of a gray area.
However, in general when you're changing existing text, it seems to make more sense to at least initially propose the more minimal change that retains the previous markup, formatting and rendering, and just disables resolution (silencing the warnings):
- The class``Color`` is an *enumeration* (or *enum*) | |
- The attributes``Color.RED``, ``Color.GREEN``, etc., are | |
- The class:class:`!Color` is an *enumeration* (or *enum*) | |
- The attributes:attr:`!Color.RED`,:attr:`!Color.GREEN`, etc., are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't quite agree that these references should be:class:
and:attr:
, becauseColor
is only defined in the docs. But, visual separation is a good enough argument to keep it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, I think there's a good conceptual argument to be made for either way, and I don't have a particular preference myself—in fact, if anything generally I tend to prefer the style you used, for the reason you mentioned (plus its a little simpler).
However, I ended up mentioning it here because it preserved the existing syntax and styling as much as practical, and in particular because this particular usage is explicitly to highlight the semantic differences between the enum, members, and their names and values, which the markup helps accentuate (in fact, before I saw the next line, I hesitated to make this comment at all).
To note, though, due to a theme CSS bug, references in admonitions (like this note) are rendered with the background anyway—but will start working again as soon as that's fixed.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Doc/library/enum.rst Outdated
@@ -424,9 +424,9 @@ Data Types | |||
Using :class:`auto` with :class:`IntEnum` results in integers of increasing | |||
value, starting with ``1``. | |||
.. versionchanged:: 3.11:meth:`__str__` is now:func:`int.__str__` to | |||
.. versionchanged:: 3.11*__str__* is now``int.__str__`` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Same here; why not:
..versionchanged::3.11*__str__* is now``int.__str__`` to | |
..versionchanged::3.11:meth:`~object.__str__` is now:meth:`!int.__str__` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I have slightly modified your proposed change, because reading
:meth:`~object.__str__` is now :meth:`!int.__str__`
does not make much sense to me. Now it is:
:meth:`!__str__` is now :meth:`!int.__str__`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
But the latteris essentially what readers will actually see, of course; the~
removes theobject
prefix, so the original suggestion already displays as your second example, just with__str__
usefully cross-referenced to a description of the__str__
dunder and what it's used for, which seems to me to be potentially helpful to readers (and surely does no harm, at least).
Uh oh!
There was an error while loading.Please reload this page.
Doc/library/enum.rst Outdated
@@ -761,11 +761,11 @@ Data Types | |||
Supported ``__dunder__`` names | |||
"""""""""""""""""""""""""""""" | |||
:attr:`__members__` is a read-only ordered mapping of ``member_name``:``member`` | |||
:attr:`!EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't really get this either. This is a list of supported dunder and sunder names, and none of the other names have the class name explicitly prefixed, so I'm not sure why it makes sense to treat this differently.
Either__members__
should be explicitly documented underEnumType
, like a number of other dunders and sunders are (including some listed here), and the link fixed here in the meantime (which displays the same as now until it is added):
:attr:`!EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member`` | |
:attr:`~EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member`` |
or, if for whatever reason it doesn't make sense to explicitly document__members__
in the usual way, silence the warning without the prefix:
:attr:`!EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member`` | |
:attr:`!__members__` is a read-only ordered mapping of ``member_name``:``member`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Let's document__member__
separately and keep the focus of this PRfocused 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sure, but if__members__
should be documented (or the decision left until later), then deresolving it not only silences avalid warning, but also means that it will stay broken even if and when__members__
is documented, rather than start working automatically.
Therefore, unless@ethanfurman has some reason to not explicitly document__members__
but still list it here (which is possible), then the default approach should be the former, i.e. to fix it but leave it resolving, unless and until it is decided to explicitly leave it undocumented.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Also, since this fixes a docs defect and would otherwise increase the change of merge conflicts when backporting other docs fixes, this should be backported as well, at least to 3.11 if not 3.10. To note, the 3.10 backport will likely hit a conflict on one of the lines that's 3.11-specific, but that can be backported manually or with Cherry-Picker. |
@CAM-Gerlach thanks a lot for teaching me this! It makes so much more sense now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A few followup suggestions.
(Standard reminder: You can apply the suggestions you want in one go withFiles changed
->Add to batch ->Commit, or modify them/add your own and do the same)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I'm so glad it was helpful to you! I was pretty worried that I was too harsh and critical with the tone of my comment, but I'm glad you learned a lot—that's as if not more important than fixing these issues, as it benefits everyone going forward! |
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good, thank you both!
The enum docs were completely redone in 3.11, so there's no backporting to 3.10. |
Thanks@sobolevn for the PR, and@ethanfurman for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
*pythongh-101100: [Enum] Fix sphinx warnings in(cherry picked from commit9e025d3)Co-authored-by: Nikita Sobolev <mail@sobolevn.me>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
bedevere-bot commentedJan 20, 2023
GH-101173 is a backport of this pull request to the3.11 branch. |
Uh oh!
There was an error while loading.Please reload this page.
There were several warnings before:
Here's how these places were rendered:
After the fix, there are no warnings: