Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
ethanfurman merged 4 commits intopython:mainfromsobolevn:fix-enum-docs
Jan 20, 2023

Conversation

sobolevn
Copy link
Member

@sobolevnsobolevn commentedJan 18, 2023
edited by bedevere-bot
Loading

There were several warnings before:

/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:428: WARNING: py:meth reference target not found: __str__/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:428: WARNING: py:func reference target not found: int.__str__/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:428: WARNING: py:meth reference target not found: __format__/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:428: WARNING: py:func reference target not found: int.__format__/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:764: WARNING: py:attr reference target not found: __members__/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:767: WARNING: py:meth reference target not found: __new__/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:767: WARNING: py:attr reference target not found: _value_/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:806: WARNING: py:meth reference target not found: _generate_next_value_/Users/sobolev/Desktop/cpython/Doc/library/enum.rst:849: WARNING: py:attr reference target not found: __members__

Here's how these places were rendered:

Снимок экрана 2023-01-18 в 11 18 28

Снимок экрана 2023-01-18 в 11 18 38

Снимок экрана 2023-01-18 в 11 19 57

Снимок экрана 2023-01-18 в 11 21 18

After the fix, there are no warnings:

Снимок экрана 2023-01-18 в 11 27 00

Copy link
Member

@CAM-GerlachCAM-Gerlach left a comment
edited
Loading

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 beliteral, 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 insqlite3).

Etc., see individual comments on each change for more details and the suggested fixes to each.

Comment on lines 55 to 56
- The class``Color`` is an *enumeration* (or *enum*)
- The attributes``Color.RED``, ``Color.GREEN``, etc., are
Copy link
Member

@CAM-GerlachCAM-GerlachJan 18, 2023
edited
Loading

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):

Suggested change
- 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

Copy link
MemberAuthor

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.

Copy link
Member

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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

Same here; why not:

Suggested change
..versionchanged::3.11*__str__* is now``int.__str__`` to
..versionchanged::3.11:meth:`~object.__str__` is now:meth:`!int.__str__` to

Copy link
MemberAuthor

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__`

Copy link
Member

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).

@@ -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``
Copy link
Member

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):

Suggested change
: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:

Suggested change
: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``

Copy link
MemberAuthor

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 😉

Copy link
Member

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.

@CAM-Gerlach
Copy link
Member

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.

@sobolevn
Copy link
MemberAuthor

@CAM-Gerlach thanks a lot for teaching me this! It makes so much more sense now.
It is like 10x times better than just going through thehttps://devguide.python.org/documentation/style-guide/ :)

CAM-Gerlach reacted with heart emoji

Copy link
Member

@CAM-GerlachCAM-Gerlach left a 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)

@CAM-Gerlach
Copy link
Member

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!

ethanfurmanand others added2 commitsJanuary 19, 2023 18:07
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Copy link
Member

@ethanfurmanethanfurman left a 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!

CAM-Gerlach reacted with rocket emoji
@ethanfurman
Copy link
Member

The enum docs were completely redone in 3.11, so there's no backporting to 3.10.

CAM-Gerlach reacted with thumbs up emoji

@ethanfurmanethanfurman merged commit9e025d3 intopython:mainJan 20, 2023
@miss-islington
Copy link
Contributor

Thanks@sobolevn for the PR, and@ethanfurman for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJan 20, 2023
*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
Copy link

GH-101173 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelJan 20, 2023
ambv pushed a commit that referenced this pull requestJan 20, 2023
…1173)(cherry picked from commit9e025d3)Co-authored-by: Nikita Sobolev <mail@sobolevn.me>Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@CAM-GerlachCAM-GerlachCAM-Gerlach requested changes

@ethanfurmanethanfurmanethanfurman approved these changes

Assignees
No one assigned
Labels
docsDocumentation in the Doc dirskip news
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@sobolevn@CAM-Gerlach@ethanfurman@miss-islington@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp