toctree, use document nesting instead of domain nesting when adding domain objects #12367
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.
Feature or Bugfix
Purpose
When
toc_object_entries = True
the nesting of the objects in the toctree seems to done based on the scoping rules of the domain, instead of how the objects are documented in the input document. This PR tries to use the doctree to define the nesting instead.Detail
The previous traversal of the doctree was done with
.findall()
which doesn't provide any path--from-root information when each element is yeilded. It therefore usedmemo_parents
to store parent information, but it was indexed by domain-specific information.I have kept the
.findall()
, butmemo_parents
is now indexed bydesc
nodes. As eachdesc
may have multiple signatures, it will be the last one which gets the nested elements.Example:
Before, the toctree became
With this PR, the toctree corresponds to the document structure:
Are there any tests for this? None seems to break with the change.
Relates
Fixes #12352.