8000 Backport PR #15115 on branch v3.1.1-doc (Doc: highlight rcparams) by meeseeksmachine · Pull Request #15129 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #15115 on branch v3.1.1-doc (Doc: highlight rcparams) #15129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Thumbs.db
###################################
lib/matplotlib/mpl-data/matplotlib.conf
lib/matplotlib/mpl-data/matplotlibrc
tutorials/intermediate/CL01.png
tutorials/intermediate/CL02.png

# Documentation generated files #
#################################
Expand Down
4 changes: 4 additions & 0 deletions doc/_static/mpl.css
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ span.linkdescr {
font-size: 90%;
}

.highlight span.c1 span.highlighted {
background-color: #fce5a6;
}

ul.search {
margin: 10px 0 0 20px;
padding: 0;
Expand Down
7 changes: 5 additions & 2 deletions doc/sphinxext/custom_roles.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from docutils import nodes
from os.path import sep
from matplotlib import rcParamsDefault


def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
rendered = nodes.Text('rcParams["{}"]'.format(text))
param = rcParamsDefault.get(text)
rendered = nodes.Text(f'rcParams["{text}"] = {param!r}')

source = inliner.document.attributes['source'].replace(sep, '/')
rel_source = source.split('/doc/', 1)[1]

levels = rel_source.count('/')
refuri = ('../' * levels +
'tutorials/introductory/customizing.html#matplotlib-rcparams')
'tutorials/introductory/customizing.html' +
f"?highlight={text}#a-sample-matplotlibrc-file")

ref = nodes.reference(rawtext, rendered, refuri=refuri)
return [nodes.literal('', '', ref)], []
Expand Down
0