Conversation
…on-nestable directive.
This branch has not been deployed
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
PyObject.before_contentsetspy:classfrom an explicit dotted prefix but only pushes onto thepy:classesstack when the directive is nestable.PyObject.after_contentrestorespy:classfrom that stack unconditionally, outside theallow_nestingguard. For.. py:attribute:: Widget.flagsthe stack is empty, so the first object nested in its body clearspy:classandthe rest of the body loses its class context.
With an empty
extensionslist, three.. py:data::directives in that body are registered asmymod.Widget.FLAG_A,mymod.FLAG_Bandmymod.FLAG_C, and the HTML ids differ the same way. Cross-references also stop resolvingafter the first nested object, with no warning unless
-nis used. Autodoc hits the same path, since.. automethod:: mymod.Widget.frobemits aWidget.-prefixed signature.The fix saves
py:classinbefore_contentand restores it inafter_content, instead of restoring the stack top. It applies to nestable directives too: in the body of.. py:method:: Other.meth()inside.. py:class:: Outer, an object after a nested.. py:class::is currently registered underOuterrather thanOther— the same defect with a wrong prefix instead of a missing one. Thepy:classesstack is otherwise unchanged.This restores the pre-1.6 semantics: before b0875d6,
after_contpy:classonlyif self.clsname_set`, so a nested directive never parent's context. That rewrite covered the nestable case only.Documents relying on the current behaviour will see object names a change for siblings after the first nested object. Adds a regressi a
CHANGES.rstentry.References
AI Disclosure
Claude Code (Claude Opus 5) was used to prepare this pull request. reproduced the behaviour on 8.2.3 and master, ran the test suites patched and unpatched checkout, found the pre-1.6 implementation, identified the nested-class case behind the nestable branch change this description, the
CHANGES.rstentry and the regression test.tosphinx/domains/python/_object.pyis mine.🤖 Generated with Claude Code