File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838 'sphinx.ext.coverage' ,
3939 'sphinx.ext.doctest' ,
4040 'sphinx.ext.extlinks' ,
41+ 'doctree' ,
4142]
4243
4344# Skip if downstream redistributors haven't installed them
Original file line number Diff line number Diff line change 1+
2+ from __future__ import annotations
3+
4+ from typing import TYPE_CHECKING
5+
6+ from docutils import nodes
7+ from sphinx import addnodes
8+
9+ if TYPE_CHECKING :
10+ from sphinx .application import Sphinx
11+ from sphinx .util .typing import ExtensionMetadata
12+
13+ class Visitor :
14+ def __init__ (self ):
15+ self .indent = 0
16+
17+ def visit (self , node ):
18+ print (' ' * self .indent + node .__class__ )
19+ self .indent += 4
20+ for child in node .findall (include_self = False ):
21+ self .visit (child )
22+ self .indent -= 4
23+
24+
25+ def get_doctree_ast (app : Sphinx , doctree : nodes .document , doc_name : str ) -> None :
26+ visitor = Visitor ()
27+ if doc_name == "library/sys.monitoring" :
28+ '''
29+ Notes: prefix is desc_addname for the prefix (e.g. 'sys.monitoring.') then
30+ desc_name with the final part, e.g. 'use_tool_id'.
31+
32+ structure is:
33+ desc_addname
34+ <prefix>
35+ desc_name
36+ <name>
37+ paramlist
38+ desc_parameter
39+ desc_sig_name
40+ <name>
41+ desc_sig_punctuation
42+ ':'
43+ desc_sig_space
44+ ' '
45+ desc_sig_name
46+ reference
47+ <name>
48+ desc_returns
49+ reference
50+ <name>
51+ '''
52+ breakpoint ()
53+
54+ def setup (app : Sphinx ) -> ExtensionMetadata :
55+ app .connect ("doctree-resolved" , get_doctree_ast )
56+
57+ return {
58+ "version" : "1.0" ,
59+ "parallel_read_safe" : True ,
60+ "parallel_write_safe" : True ,
61+ }
You can’t perform that action at this time.
0 commit comments