Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-101100: Fix sphinx warnings in howto/* #127084

Merged
merged 4 commits into from
Nov 26, 2024
Merged

Conversation

koyuki7w
Copy link
Contributor

@koyuki7w koyuki7w commented Nov 21, 2024

Removed sphinx roles of some classes and methods, as the classes are defined in the sample codes, not in Python.

Fixed warnings:

howto/descriptor.rst:45: WARNING: py:class reference target not found: Ten [ref.class]
howto/descriptor.rst:218: WARNING: py:class reference target not found: Person [ref.class]
howto/descriptor.rst:218: WARNING: py:class reference target not found: Person [ref.class]
howto/descriptor.rst:256: WARNING: py:class reference target not found: Person [ref.class]
howto/descriptor.rst:340: WARNING: py:class reference target not found: Validator [ref.class]
howto/descriptor.rst:363: WARNING: py:class reference target not found: Validator [ref.class]
howto/descriptor.rst:363: WARNING: py:meth reference target not found: validate [ref.meth]
howto/descriptor.rst:372: WARNING: py:class reference target not found: OneOf [ref.class]
howto/descriptor.rst:374: WARNING: py:class reference target not found: Number [ref.class]
howto/descriptor.rst:378: WARNING: py:class reference target not found: String [ref.class]
howto/descriptor.rst:876: WARNING: py:class reference target not found: Field [ref.class]
howto/descriptor.rst:1143: WARNING: py:func reference target not found: Property [ref.func]
howto/enum.rst:78: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:90: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:113: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:131: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:576: WARNING: py:class reference target not found: Animal [ref.class]
howto/enum.rst:893: WARNING: py:class reference target not found: FloatEnum [ref.class]

📚 Documentation preview 📚: https://cpython-previews--127084.org.readthedocs.build/

Removed sphinx roles of some classes and methods,
as the classes are defined in the sample codes, not in Python.

Fixed warnings:
```
howto/descriptor.rst:45: WARNING: py:class reference target not found: Ten [ref.class]
howto/descriptor.rst:218: WARNING: py:class reference target not found: Person [ref.class]
howto/descriptor.rst:218: WARNING: py:class reference target not found: Person [ref.class]
howto/descriptor.rst:256: WARNING: py:class reference target not found: Person [ref.class]
howto/descriptor.rst:340: WARNING: py:class reference target not found: Validator [ref.class]
howto/descriptor.rst:363: WARNING: py:class reference target not found: Validator [ref.class]
howto/descriptor.rst:363: WARNING: py:meth reference target not found: validate [ref.meth]
howto/descriptor.rst:372: WARNING: py:class reference target not found: OneOf [ref.class]
howto/descriptor.rst:374: WARNING: py:class reference target not found: Number [ref.class]
howto/descriptor.rst:378: WARNING: py:class reference target not found: String [ref.class]
howto/descriptor.rst:876: WARNING: py:class reference target not found: Field [ref.class]
howto/descriptor.rst:1143: WARNING: py:func reference target not found: Property [ref.func]
howto/descriptor.rst:1725: WARNING: py:class reference target not found: Object [ref.class]
howto/enum.rst:78: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:90: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:113: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:131: WARNING: py:class reference target not found: Weekday [ref.class]
howto/enum.rst:576: WARNING: py:class reference target not found: Animal [ref.class]
howto/enum.rst:893: WARNING: py:class reference target not found: FloatEnum [ref.class]
```
@hugovk hugovk added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Nov 24, 2024
@@ -42,7 +42,7 @@ add new capabilities one by one.
Simple example: A descriptor that returns a constant
----------------------------------------------------

The :class:`Ten` class is a descriptor whose :meth:`__get__` method always
The ``Ten`` class is a descriptor whose :meth:`__get__` method always
Copy link
Member

Choose a reason for hiding this comment

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

If we keep the class role but add an exclamation mark then we keep the formatting of a class but don't try to resolve the reference, and get no warning:

Suggested change
The ``Ten`` class is a descriptor whose :meth:`__get__` method always
The :class:`!Ten` class is a descriptor whose :meth:`!__get__` method always

Re: https://devguide.python.org/documentation/markup/#roles

Same applies to the others in this PR.

And we can also do it for the example __get__ method here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hugovk Fixed class references by using ! prefix. __get__ is documented in https://docs.python.org/3/reference/datamodel.html#object.__get__ , so I think it is better to fix __get__ to ~object.__get__.

Copy link
Member

Choose a reason for hiding this comment

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

__get__ is documented in docs.python.org/3/reference/datamodel.html#object.get , so I think it is better to fix __get__ to ~object.__get__.

Yes, good idea.

@koyuki7w koyuki7w changed the title gh-101100: Remove roles of sample classes in howto/* gh-101100: Fix sphinx warnings in howto/* Nov 25, 2024
@koyuki7w koyuki7w requested a review from hugovk November 25, 2024 11:34
Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Thanks!

@hugovk hugovk merged commit 733fe59 into python:main Nov 26, 2024
29 checks passed
@miss-islington-app
Copy link

Thanks @koyuki7w for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 26, 2024
(cherry picked from commit 733fe59)

Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
@miss-islington-app
Copy link

Sorry, @koyuki7w and @hugovk, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 733fe59206e04141fd5cf65606ebd3d42a996226 3.12

@bedevere-app
Copy link

bedevere-app bot commented Nov 26, 2024

GH-127287 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Nov 26, 2024
@hugovk
Copy link
Member

hugovk commented Nov 26, 2024

@koyuki7w Please could you take care of the 3.12 backport? Thanks!

hugovk pushed a commit that referenced this pull request Nov 26, 2024
Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Nov 27, 2024

GH-127311 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Nov 27, 2024
@koyuki7w
Copy link
Contributor Author

@hugovk Thanks. Opened 3.12 backport PR.

@koyuki7w koyuki7w deleted the doc-fix-2 branch November 27, 2024 00:58
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants