Skip to content

DOC: Add role for custom informal types like color #27200

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

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/sphinxext/custom_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,23 @@ def rcparam_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
return node_list, messages


def mpltype_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
mpltype = text
type_to_link_target = {
'color': 'colors_def',
}
if mpltype not in type_to_link_target:
raise ValueError(f"Unknown mpltype: {mpltype!r}")

ref_nodes, messages = inliner.interpreted(
mpltype, f'{mpltype} <{type_to_link_target[mpltype]}>', 'ref', lineno)
node_list = [ref_nodes]
return node_list, messages


def setup(app):
app.add_role("rc", rcparam_role)
app.add_role("mpltype", mpltype_role)
app.add_node(
QueryReference,
html=(visit_query_reference_node, depart_query_reference_node),
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def __init__(self, ax, label, image=None,
image : array-like or PIL Image
The image to place in the button, if not *None*. The parameter is
directly forwarded to `~.axes.Axes.imshow`.
color : color
color : :mpltype:`color`
The color of the button when not activated.
hovercolor : color
The color of the button when the mouse is over it.
Expand Down