Commit 3c26d3d
committed
functions: Fix broken parent-child node relationships
The find_and_replace_node_content function breaks parent-child node
relationships since it does not go through the docutils tools for
assigning node children. Utilize one of the built-in docutils methods [1]
for this since it correctly assigns the parent-child relationship of
each node.
Notably, the sphinxcontrib-spelling [2] extension is broken by this
broken parent-child relationship since if something is misspelled it
tries to identify which source line was impacted. When a node is added
as a child, setup_child(...) [3] code fixes up the source/line location
with the parent's information if needed.
A test has been added at the top-level which covers every single test
run by adding a build hook into the "doctree-resolved" hook. This test
is fairly simple - check each node (outside of the top node) and
validate that it has a parent assigned.
[1] https://github.com/docutils/docutils/blob/4e912fe000b1b6dc1466c0ad1c3d1787d40fd96d/docutils/docutils/nodes.py#L788-L794
[2] https://pypi.org/project/sphinxcontrib-spelling/
[3] https://github.com/docutils/docutils/blob/4e912fe000b1b6dc1466c0ad1c3d1787d40fd96d/docutils/docutils/nodes.py#L150-L1571 parent fbcfbab commit 3c26d3d
2 files changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| |||
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
271 | | - | |
| 272 | + | |
| 273 | + | |
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
257 | 264 | | |
258 | 265 | | |
259 | 266 | | |
| |||
330 | 337 | | |
331 | 338 | | |
332 | 339 | | |
| 340 | + | |
| 341 | + | |
333 | 342 | | |
334 | 343 | | |
335 | 344 | | |
| |||
0 commit comments