Closed
Description
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
.. py:currentmodule:: myMod
.. py:class:: MyClass
.. py:method:: f()
.. py:class:: MyClass.MyNestedClass
I get the toc
- MyClass
- MyClass.f()
- MyClass.MyNestedClass
instead of
- MyClass
- MyClass.f()
- MyClass.MyNestedClass
Environment Information
Tested with current master.
Sphinx extensions
No response
Additional context
Could the check at
be changed to check if the parent in the language is also the parent in the current toctree generation?