Skip to content

Commit

Permalink
Update :rc: role extension
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Sep 16, 2019
1 parent 9a11f2e commit 402433f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ lxml>=4.0.0
numpy>=1.14
ipython>=7.0.0
matplotlib>=3.0
git+https://github.com/lukelbd/sphinx-automodapi@v0.4.proplot-mods
git+https://github.com/lukelbd/sphinx-automodapi@v0.5.proplot-mods
9 changes: 6 additions & 3 deletions docs/sphinxext/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
# Adapted from matplotlib
# TODO: Understand what the hell is going on here
def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
rendered = nodes.Text(f"rc['{text}']")
rctext = (f"rc['{text}']" if '.' in text else f'rc.{text}')
rendered = nodes.Text(rctext)
source = inliner.document.attributes['source'].replace(sep, '/')
relsource = source.split('/docs/', 1)[1]
levels = relsource.count('/') # distance to 'docs' folder
relsource = source.split('/docs/', 1)
if len(relsource) == 1:
return [], []
levels = relsource[1].count('/') # distance to 'docs' folder
refuri = ('../' * levels) + 'en/latest/rctools.html?highlight=' + text

ref = nodes.reference(rawtext, rendered, refuri=refuri)
Expand Down
6 changes: 3 additions & 3 deletions proplot/rctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,9 +874,9 @@ def reset(self):
@_timer
def nb_setup():
"""
Sets up your iPython workspace, called on import if :rc:`nbsetup` is
``True`` (the default). For all iPython sessions, passes :rc:`autoreload`
to the useful `autoreload <https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html>`__
Sets up your iPython workspace, called on import if :rc:`nbsetup`. For all
iPython sessions, passes :rc:`autoreload` to the useful
`autoreload <https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html>`__
extension. For iPython *notebook* sessions, results in higher-quality inline figures
and passes :rc:`autosave` to the `autosave <https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-matplotlib>`__
extension.
Expand Down

0 comments on commit 402433f

Please sign in to comment.