Skip to content

Conversation

gmilde
Copy link

@gmilde gmilde commented Sep 9, 2025

The utility function sphinx.util.parsing.nested_parse_to_nodes() allows
nested parsing with support for sections.
This is a "power user" feature with known problems and usage restrictions.

Purpose

Inform the user about the risks and limitations when using nested_parse_to_nodes().

References

Set the "parent" attribute of RSTState instances to the `document`
instead of None.  The attribute holds the state machines "current node"
which is initialized to the `document` in `RSTStateMachine.run()` and
required since Docutils 0.22.1 in `RSTState.nested_parse()` to correctly
support sections in nested parsing.
"section" elements can only be children of "document" or "section"
elements, not "sidebar".
Cf. https://docutils.sourceforge.io/docs/ref/doctree.html#section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible data loss with sphinx.util.parsing.nested_parse_to_nodes() misleading docstring for sphinx.util.parsing.nested_parse_to_nodes()
1 participant