Commit 0235780
committed
docs(refactor[package-reference]): drop docutils role monkey-patch
why: The `collect_extension_surface()` and `_seed_python_objects_map()`
helpers each monkey-patched
`docutils.parsers.rst.roles.register_local_role` /
`register_canonical_role` so that `sphinx-autodoc-argparse`'s
`register_roles()` — which registered its five `cli-*` roles via the
docutils global — would be discoverable by the RecorderApp. Now that
argparse registers via `Sphinx.add_role`, the RecorderApp captures
those calls through its own `__getattr__`, and the monkey-patch has
nothing left to catch. Removing it drops three `t.cast("t.Any", …)`
casts, two try/finally blocks that mutated process-global docutils
state, and an entire `"docutils role"` post-processing branch.
what:
- Delete the `registered_roles` / `_record_local` / role-patch
try-finally in `collect_extension_surface()` (lines 317–336) and
the trailing "docutils role" emission loop (lines 443–451)
- Delete the `docutils_roles` / `_capture` / role-patch try-finally
in `_seed_python_objects_map()` and the trailing
`docutils_roles`-based `raw_objs` append (lines 781–823)
- Drop the `from docutils.parsers.rst import roles` import (no other
references remain in this file)
- Update the module-level architecture docstring to describe the
`RecorderApp.__getattr__` approach instead of the removed
monkey-patch
- Verified via `just build-docs`: the argparse package reference
page still lists all five `cli-*` roles (27 occurrences in the
rendered HTML, captured through the "add_role" branch)1 parent 1cbc355 commit 0235780
1 file changed
Lines changed: 6 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
| |||
314 | 313 | | |
315 | 314 | | |
316 | 315 | | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
| 316 | + | |
| 317 | + | |
337 | 318 | | |
338 | 319 | | |
339 | 320 | | |
| |||
440 | 421 | | |
441 | 422 | | |
442 | 423 | | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | 424 | | |
454 | 425 | | |
455 | 426 | | |
| |||
806 | 777 | | |
807 | 778 | | |
808 | 779 | | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | 780 | | |
821 | | - | |
822 | | - | |
823 | 781 | | |
824 | 782 | | |
825 | 783 | | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | 784 | | |
830 | 785 | | |
831 | 786 | | |
| |||
845 | 800 | | |
846 | 801 | | |
847 | 802 | | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | 803 | | |
853 | 804 | | |
854 | 805 | | |
| |||
0 commit comments