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