From 6901e1cb7899822d89b5968a927a829a47c44c34 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 9 Sep 2019 01:34:51 +0200 Subject: [PATCH] Doc: Do not write default for non-existing rcParams --- doc/sphinxext/custom_roles.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/sphinxext/custom_roles.py b/doc/sphinxext/custom_roles.py index 88dddb6a2e4b..18f9144d9000 100644 --- a/doc/sphinxext/custom_roles.py +++ b/doc/sphinxext/custom_roles.py @@ -4,8 +4,12 @@ def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]): - param = rcParamsDefault.get(text) - rendered = nodes.Text(f'rcParams["{text}"] = {param!r}') + try: + default_str = f' = {rcParamsDefault[text]!r}' + except KeyError: + # handling of generic references such as rcParams["figure.subplot.*"] + default_str = '' + rendered = nodes.Text(f'rcParams["{text}"]' + default_str) source = inliner.document.attributes['source'].replace(sep, '/') rel_source = source.split('/doc/', 1)[1]