Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5fee0fa

Browse filesBrowse files
committed
Promote mpltype Sphinx role to a public extension
When projects derive from our types, but don't override all the docstrings, they may want to use these extensions so that their docs build.
1 parent 31a2e1e commit 5fee0fa
Copy full SHA for 5fee0fa

File tree

4 files changed

+16
-15
lines changed
Filter options

4 files changed

+16
-15
lines changed

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ def _parse_skip_subdirs_file():
116116
'sphinx_gallery.gen_gallery',
117117
'matplotlib.sphinxext.mathmpl',
118118
'matplotlib.sphinxext.plot_directive',
119+
'matplotlib.sphinxext.roles',
119120
'matplotlib.sphinxext.figmpl_directive',
120121
'sphinxcontrib.inkscapeconverter',
121-
'sphinxext.custom_roles',
122122
'sphinxext.github',
123123
'sphinxext.math_symbol_table',
124124
'sphinxext.missing_references',

‎lib/matplotlib/sphinxext/meson.build

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/meson.build
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python_sources = [
33
'figmpl_directive.py',
44
'mathmpl.py',
55
'plot_directive.py',
6+
'roles.py',
67
]
78

89
typing_sources = [

‎doc/sphinxext/custom_roles.py renamed to ‎lib/matplotlib/sphinxext/roles.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/roles.py
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from matplotlib import rcParamsDefault
66

77

8-
class QueryReference(nodes.Inline, nodes.TextElement):
8+
class _QueryReference(nodes.Inline, nodes.TextElement):
99
"""
1010
Wraps a reference or pending reference to add a query string.
1111
@@ -19,7 +19,7 @@ def to_query_string(self):
1919
return '&'.join(f'{name}={value}' for name, value in self.attlist())
2020

2121

22-
def visit_query_reference_node(self, node):
22+
def _visit_query_reference_node(self, node):
2323
"""
2424
Resolve *node* into query strings on its ``reference`` children.
2525
@@ -33,22 +33,22 @@ def visit_query_reference_node(self, node):
3333
self.visit_literal(node)
3434

3535

36-
def depart_query_reference_node(self, node):
36+
def _depart_query_reference_node(self, node):
3737
"""
3838
Act as if this is a `~docutils.nodes.literal`.
3939
"""
4040
self.depart_literal(node)
4141

4242

43-
def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
43+
def _rcparam_role(name, rawtext, text, lineno, inliner, options=None, content=None):
4444
# Generate a pending cross-reference so that Sphinx will ensure this link
4545
# isn't broken at some point in the future.
4646
title = f'rcParams["{text}"]'
4747
target = 'matplotlibrc-sample'
4848
ref_nodes, messages = inliner.interpreted(title, f'{title} <{target}>',
4949
'ref', lineno)
5050

51-
qr = QueryReference(rawtext, highlight=text)
51+
qr = _QueryReference(rawtext, highlight=text)
5252
qr += ref_nodes
5353
node_list = [qr]
5454

@@ -64,7 +64,7 @@ def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
6464
return node_list, messages
6565

6666

67-
def mpltype_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
67+
def _mpltype_role(name, rawtext, text, lineno, inliner, options=None, content=None):
6868
mpltype = text
6969
type_to_link_target = {
7070
'color': 'colors_def',
@@ -78,12 +78,12 @@ def mpltype_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
7878

7979

8080
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)
8383
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),
8888
)
8989
return {"parallel_read_safe": True, "parallel_write_safe": True}

‎pyproject.toml

Copy file name to clipboardExpand all lines: pyproject.toml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ ignore_directives = [
283283
"include"
284284
]
285285
ignore_roles = [
286-
# sphinxext.custom_roles
287-
"rc",
288286
# matplotlib.sphinxext.mathmpl
289287
"mathmpl",
290288
"math-stix",
289+
# matplotlib.sphinxext.roles
290+
"rc",
291291
# sphinxext.github
292292
"ghissue",
293293
"ghpull",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.