-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Link rcParams role to docs #11448
Conversation
Would setting |
Minor point, possibly just an issue to open with sphinx/docutils (although we may get away with applying our own styling, but I'd rather get the issue fixed upstream): https://10444-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/api/_as_gen/matplotlib.axes.Axes.errorbar.html#matplotlib.axes.Axes.errorbar (see errorbar.capsize rc) uses curly quotes for the literal+link, whereas the previous version at https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.errorbar.html#matplotlib.axes.Axes.errorbar uses straight quotes; the latter seems better. |
Curly quotes:They are replaced by For now, the present solution is as good as I can get this (an alternative would only be a raw node). |
doc/_static/mpl.css
Outdated
@@ -23,6 +23,14 @@ a { | |||
text-decoration: none; | |||
} | |||
|
|||
a.rcparams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is is really worth it using a different styling (or even a different class)?
I think the normal orange would probably actually look better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to use styling, a class is the cleanest way.
To me, the original orange looked a bit too distracting. Can add a screenshot later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see what others think, then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 opinions welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why it should be distinct. Every other link in the docs, including normal url links, are the same orange.
doc/sphinxext/custom_roles.py
Outdated
'tutorials/introductory/customizing.html#matplotlib-rcparams') | ||
|
||
ref = nodes.reference(rawtext, rendered, refuri=refuri, | ||
classes=['rcparams']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would perhaps not bother with the separate class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't harm. And makes it easier to adapt the style of the link if desired now or later (e.g. it would also be possible not to have a literal node nested and instead style the font-family of the link).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(that comment basically just applies if we decide not to style rcs differently from normal links)
rel_source = inliner.document.attributes['source'].split('/doc/', 1)[1] | ||
levels = rel_source.count('/') | ||
refuri = ('../' * levels + | ||
'tutorials/introductory/customizing.html#matplotlib-rcparams') |
There was a problem hiding this comment.
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/...")
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
Removed the css class and special highlighting for the link. It now appears as a regular link. |
Concerning curly quotes: This is controlled via the smartquotes option. Maybe, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some possible further improvements, but that's clearly a step in the right direction and can be merged as is.
PR Summary
Follow up to #10226. This turns the text generated by the
:rc:
role into a link to the rc documentation.Note: I'm no expert in docutils and it's really difficult to find good documentation. There generation of the
refuri
feels a bit clumsy, because I have to build the final url. Naturally, one would like to have some functionlabel_to_uri('matplotlib-rcparams')
but I couldn't find something like that. The downside is that we rely on a hard coded file structure, but I can live with that (We're not likely to change that often).