You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The entries added by toc_object_entries for Python (and other domains?) seems to use the scoping of the language to nest the toc entries, instead of how they were declared in the document. E.g., if a nested class is declared after the class, then its entry is nested inside the class instead of appended.
To get the nested class I'd rely only on reST scoping rules so it seems the most robust and language agnostic solution would be to put f() and MyNestedClass on the same level:
Being a directive shouldn't currentmodule also have an empty line and one level of nesting? Like this:
The currentmodule has no content, but simply sets the module. However, if you use module with content, then it's equivalent to the original example, and produces the wrong TOC as well.
To get the nested class I'd rely only on reST scoping rules so it seems the most robust and language agnostic solution would be to put f() and MyNestedClass on the same level:
Generally I agree that showing them nested is a good default. However, in the original use-case there are multiple nested classes and all involved classes are relatively large, making it desirable to separate them.
Describe the bug
The entries added by
toc_object_entries
for Python (and other domains?) seems to use the scoping of the language to nest the toc entries, instead of how they were declared in the document. E.g., if a nested class is declared after the class, then its entry is nested inside the class instead of appended.How to Reproduce
E.g., with
I get the toc
instead of
Environment Information
Sphinx extensions
No response
Additional context
Could the check at
sphinx/sphinx/environment/collectors/toctree.py
Line 146 in 88a54d8
The text was updated successfully, but these errors were encountered: