Skip to content

Link rcParams role to docs #11448

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
merged 1 commit into from
Jun 21, 2018
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
8 changes: 4 additions & 4 deletions doc/_static/mpl.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ a {
text-decoration: none;
}

a:hover {
color: #2491CF;
}

div.highlight-python a {
color: #CA7900;
}
Expand All @@ -35,10 +39,6 @@ strong {
font-weight: strong;
}

a:hover {
color: #2491CF;
}

pre {
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
font-size: 0.90em;
Expand Down
9 changes: 8 additions & 1 deletion doc/sphinxext/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
rendered = nodes.Text('rcParams["{}"]'.format(text))
return [nodes.literal(rawtext, rendered)], []

rel_source = inliner.document.attributes['source'].split('/doc/', 1)[1]
levels = rel_source.count('/')
refuri = ('../' * levels +
'tutorials/introductory/customizing.html#matplotlib-rcparams')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an absolute link? ("/tutorials/...")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when trying this locally, sphinx links to file:///tutorials/introductory/customizing.html#matplotlib-rcparams

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps set refid instead of refuri? (just throwing some ideas around -- but somewhere docutils does have the ability to do this, so we just need to find the right way to trigger it...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. refid='matplotlib-rcparams' just links to the local anchor #matplotlib-rcparams.

I don't have the time to scan through the docutils docs and try out various stuff. I've posted the question to stackoverflow. If there is no hint from there, I'd leave it at that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I don't think this needs to be resolved to merge this PR -- it's quite unimportant. The only remaining point for me is about the styling.)


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


def setup(app):
Expand Down