From 1af7495e8d2b9e053a84cad79b9c84dde454f73b Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 16 Jun 2018 19:13:21 +0200 Subject: [PATCH] Link rcParams role to docs --- doc/_static/mpl.css | 8 ++++---- doc/sphinxext/custom_roles.py | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/_static/mpl.css b/doc/_static/mpl.css index 9ffe1335fce5..93a7f84518f9 100644 --- a/doc/_static/mpl.css +++ b/doc/_static/mpl.css @@ -23,6 +23,10 @@ a { text-decoration: none; } +a:hover { + color: #2491CF; +} + div.highlight-python a { color: #CA7900; } @@ -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; diff --git a/doc/sphinxext/custom_roles.py b/doc/sphinxext/custom_roles.py index 67492c0d5ac7..8e9ddea9fa46 100644 --- a/doc/sphinxext/custom_roles.py +++ b/doc/sphinxext/custom_roles.py @@ -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') + + ref = nodes.reference(rawtext, rendered, refuri=refuri) + return [nodes.literal('', '', ref)], [] def setup(app):