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
In the default sphinx code-block directive, when the caption option is passed in, the default literal_block node is wrapped inside a container node. When this is replicated in this extension (for compatibility with the caption option), all the children of the parsed_code_block node get deleted/removed by sphinx somewhere between the return from the directive run method and the doctree-read event being emitted by sphinx.
This has been successfully circumvented by creating a deepcopy and keeping a reference to it inside the parsed_code_block node. The reference to the deepcopy is not used anywhere, but its mere existence prevents the children from being removed. Setting the children to the deepcopy:
custom_node.extend(deepcopy(text_nodes))
does not help and neither does setting the children after the wrapping in container:
I am mystified why the children keep getting deleted/removed and completely baffled why the hack used works, but it does work and the sphinx/docutils engine is too complex to spend time trying to untagle the causes of this issue at this thime. Nevertheless, it would be good to do so and create a proper solution, or at least understand why the solution works.
The text was updated successfully, but these errors were encountered:
In the default sphinx code-block directive, when the
caption
option is passed in, the defaultliteral_block
node is wrapped inside acontainer
node. When this is replicated in this extension (for compatibility with thecaption
option), all the children of theparsed_code_block
node get deleted/removed by sphinx somewhere between the return from the directiverun
method and thedoctree-read
event being emitted by sphinx.This has been successfully circumvented by creating a deepcopy and keeping a reference to it inside the
parsed_code_block
node. The reference to the deepcopy is not used anywhere, but its mere existence prevents the children from being removed. Setting the children to the deepcopy:does not help and neither does setting the children after the wrapping in container:
I am mystified why the children keep getting deleted/removed and completely baffled why the hack used works, but it does work and the sphinx/docutils engine is too complex to spend time trying to untagle the causes of this issue at this thime. Nevertheless, it would be good to do so and create a proper solution, or at least understand why the solution works.
The text was updated successfully, but these errors were encountered: