Permit _AttrGetter to override absent docstrings from __slots__#14316
Open
clayote wants to merge 2 commits intosphinx-doc:masterfrom
Open
Permit _AttrGetter to override absent docstrings from __slots__#14316clayote wants to merge 2 commits intosphinx-doc:masterfrom
_AttrGetter to override absent docstrings from __slots__#14316clayote wants to merge 2 commits intosphinx-doc:masterfrom
Conversation
ab4a25e to
c5271d9
Compare
c5271d9 to
d9da662
Compare
Closed
13 tasks
866f9ba to
d9da662
Compare
Author
|
Here is the extension to make |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Last year, attrs changed its implementation of
@cached_propertyon classes with slots in a way that made those properties invisible to Sphinx's autodoc. It now writes a custom__getattr__that accesses the slot by the same name as the property.Sphinx has an easy solution: the
add_autodoc_attrgetterhook lets us swap in the originalcached_propertyfor documentation purposes. This works fine for the.. autopropertydirective. However, I also wanted the:members:option of.. autoclassto pick up any@cached_propertydecorated in the class definition. This did not work, because the member-finder code didn't anticipate the necessity. Once it finds the slots member, it considers the member found, even if there's no docstring for it.This PR lets the general member-finding code for classes override an earlier result, in the case that the prior
ObjectMemberhas nodocstring. The specialattrgettercode gets a chance to run, and delivers the object we really want to document.References