Sphinx role ``:rc:`` to highlight and link ``rcParams`` entries. Usage: Give the desired ``rcParams`` key as parameter. :code:`:rc:`figure.dpi`` will render as: :rc:`figure.dpi`
(name, rawtext, text, lineno, inliner, options=None, content=None)
| 95 | |
| 96 | |
| 97 | def _rcparam_role(name, rawtext, text, lineno, inliner, options=None, content=None): |
| 98 | """ |
| 99 | Sphinx role ``:rc:`` to highlight and link ``rcParams`` entries. |
| 100 | |
| 101 | Usage: Give the desired ``rcParams`` key as parameter. |
| 102 | |
| 103 | :code:`:rc:`figure.dpi`` will render as: :rc:`figure.dpi` |
| 104 | """ |
| 105 | # Generate a pending cross-reference so that Sphinx will ensure this link |
| 106 | # isn't broken at some point in the future. |
| 107 | title = f'rcParams["{text}"]' |
| 108 | rc_param_name = _RC_WILDCARD_LINK_MAPPING.get(text, text) |
| 109 | target = f'rcparam_{rc_param_name.replace(".", "_")}' |
| 110 | ref_nodes, messages = inliner.interpreted(title, f'{title} <{target}>', |
| 111 | 'ref', lineno) |
| 112 | |
| 113 | qr = _QueryReference(rawtext, highlight=text) |
| 114 | qr += ref_nodes |
| 115 | node_list = [qr] |
| 116 | |
| 117 | # The default backend would be printed as "agg", but that's not correct (as |
| 118 | # the default is actually determined by fallback). |
| 119 | if text in rcParamsDefault and text != "backend": |
| 120 | node_list.extend([ |
| 121 | nodes.Text(' (default: '), |
| 122 | nodes.literal('', repr(rcParamsDefault[text])), |
| 123 | nodes.Text(')'), |
| 124 | ]) |
| 125 | |
| 126 | return node_list, messages |
| 127 | |
| 128 | |
| 129 | def _mpltype_role(name, rawtext, text, lineno, inliner, options=None, content=None): |
nothing calls this directly
no test coverage detected
searching dependent graphs…