5
5
from matplotlib import rcParamsDefault
6
6
7
7
8
- class QueryReference (nodes .Inline , nodes .TextElement ):
8
+ class _QueryReference (nodes .Inline , nodes .TextElement ):
9
9
"""
10
10
Wraps a reference or pending reference to add a query string.
11
11
@@ -19,7 +19,7 @@ def to_query_string(self):
19
19
return '&' .join (f'{ name } ={ value } ' for name , value in self .attlist ())
20
20
21
21
22
- def visit_query_reference_node (self , node ):
22
+ def _visit_query_reference_node (self , node ):
23
23
"""
24
24
Resolve *node* into query strings on its ``reference`` children.
25
25
@@ -33,22 +33,22 @@ def visit_query_reference_node(self, node):
33
33
self .visit_literal (node )
34
34
35
35
36
- def depart_query_reference_node (self , node ):
36
+ def _depart_query_reference_node (self , node ):
37
37
"""
38
38
Act as if this is a `~docutils.nodes.literal`.
39
39
"""
40
40
self .depart_literal (node )
41
41
42
42
43
- def rcparam_role (name , rawtext , text , lineno , inliner , options = {} , content = [] ):
43
+ def _rcparam_role (name , rawtext , text , lineno , inliner , options = None , content = None ):
44
44
# Generate a pending cross-reference so that Sphinx will ensure this link
45
45
# isn't broken at some point in the future.
46
46
title = f'rcParams["{ text } "]'
47
47
target = 'matplotlibrc-sample'
48
48
ref_nodes , messages = inliner .interpreted (title , f'{ title } <{ target } >' ,
49
49
'ref' , lineno )
50
50
51
- qr = QueryReference (rawtext , highlight = text )
51
+ qr = _QueryReference (rawtext , highlight = text )
52
52
qr += ref_nodes
53
53
node_list = [qr ]
54
54
@@ -64,7 +64,7 @@ def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
64
64
return node_list , messages
65
65
66
66
67
- def mpltype_role (name , rawtext , text , lineno , inliner , options = {} , content = [] ):
67
+ def _mpltype_role (name , rawtext , text , lineno , inliner , options = None , content = None ):
68
68
mpltype = text
69
69
type_to_link_target = {
70
70
'color' : 'colors_def' ,
@@ -78,12 +78,12 @@ def mpltype_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
78
78
79
79
80
80
def setup (app ):
81
- app .add_role ("rc" , rcparam_role )
82
- app .add_role ("mpltype" , mpltype_role )
81
+ app .add_role ("rc" , _rcparam_role )
82
+ app .add_role ("mpltype" , _mpltype_role )
83
83
app .add_node (
84
- QueryReference ,
85
- html = (visit_query_reference_node , depart_query_reference_node ),
86
- latex = (visit_query_reference_node , depart_query_reference_node ),
87
- text = (visit_query_reference_node , depart_query_reference_node ),
84
+ _QueryReference ,
85
+ html = (_visit_query_reference_node , _depart_query_reference_node ),
86
+ latex = (_visit_query_reference_node , _depart_query_reference_node ),
87
+ text = (_visit_query_reference_node , _depart_query_reference_node ),
88
88
)
89
89
return {"parallel_read_safe" : True , "parallel_write_safe" : True }
0 commit comments