Skip to content

Commit 2fb2fd2

Browse files
authored
Merge pull request matplotlib#31020 from QuLogic/fix-sphinx9
DOC: Fix doc builds with Sphinx 9
2 parents 62834a2 + cde8c89 commit 2fb2fd2

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,3 +899,4 @@ def setup(app):
899899
if sphinx.version_info[:2] < (7, 1):
900900
app.connect('html-page-context', add_html_cache_busting, priority=1000)
901901
generate_ScalarMappable_docs()
902+
app.config.autodoc_use_legacy_class_based = True

lib/matplotlib/backend_tools.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ def trigger(self, *args, **kwargs):
934934
self.toolmanager.message_event(message, self)
935935

936936

937+
#: The default tools to add to a tool manager.
937938
default_tools = {'home': ToolHome, 'back': ToolBack, 'forward': ToolForward,
938939
'zoom': ToolZoom, 'pan': ToolPan,
939940
'subplots': ConfigureSubplotsBase,
@@ -953,12 +954,13 @@ def trigger(self, *args, **kwargs):
953954
'copy': ToolCopyToClipboardBase,
954955
}
955956

957+
#: The default tools to add to a container.
956958
default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
957959
['zoompan', ['pan', 'zoom', 'subplots']],
958960
['io', ['save', 'help']]]
959961

960962

961-
def add_tools_to_manager(toolmanager, tools=default_tools):
963+
def add_tools_to_manager(toolmanager, tools=None):
962964
"""
963965
Add multiple tools to a `.ToolManager`.
964966
@@ -968,14 +970,16 @@ def add_tools_to_manager(toolmanager, tools=default_tools):
968970
Manager to which the tools are added.
969971
tools : {str: class_like}, optional
970972
The tools to add in a {name: tool} dict, see
971-
`.backend_managers.ToolManager.add_tool` for more info.
973+
`.backend_managers.ToolManager.add_tool` for more info. If not specified, then
974+
defaults to `.default_tools`.
972975
"""
973-
976+
if tools is None:
977+
tools = default_tools
974978
for name, tool in tools.items():
975979
toolmanager.add_tool(name, tool)
976980

977981

978-
def add_tools_to_container(container, tools=default_toolbar_tools):
982+
def add_tools_to_container(container, tools=None):
979983
"""
980984
Add multiple tools to the container.
981985
@@ -987,9 +991,11 @@ def add_tools_to_container(container, tools=default_toolbar_tools):
987991
tools : list, optional
988992
List in the form ``[[group1, [tool1, tool2 ...]], [group2, [...]]]``
989993
where the tools ``[tool1, tool2, ...]`` will display in group1.
990-
See `.backend_bases.ToolContainerBase.add_tool` for details.
994+
See `.backend_bases.ToolContainerBase.add_tool` for details. If not specified,
995+
then defaults to `.default_toolbar_tools`.
991996
"""
992-
997+
if tools is None:
998+
tools = default_toolbar_tools
993999
for group, grouptools in tools:
9941000
for position, tool in enumerate(grouptools):
9951001
container.add_tool(tool, group, position)

lib/matplotlib/backend_tools.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ class ToolHelpBase(ToolBase):
112112

113113
class ToolCopyToClipboardBase(ToolBase): ...
114114

115-
default_tools: dict[str, ToolBase]
115+
default_tools: dict[str, type[ToolBase]]
116116
default_toolbar_tools: list[list[str | list[str]]]
117117

118118
def add_tools_to_manager(
119-
toolmanager: ToolManager, tools: dict[str, type[ToolBase]] = ...
119+
toolmanager: ToolManager, tools: dict[str, type[ToolBase]] | None = ...
120120
) -> None: ...
121-
def add_tools_to_container(container: ToolContainerBase, tools: list[Any] = ...) -> None: ...
121+
def add_tools_to_container(container: ToolContainerBase, tools: list[Any] | None = ...) -> None: ...

lib/matplotlib/widgets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ class CheckButtons(_Buttons):
11521152
For the check buttons to remain responsive you must keep a
11531153
reference to this object.
11541154
1155-
Connect to the CheckButtons with the `.on_clicked` method.
1155+
Connect to the CheckButtons with the `~._Buttons.on_clicked` method.
11561156
11571157
Attributes
11581158
----------
@@ -1652,7 +1652,7 @@ class RadioButtons(_Buttons):
16521652
For the buttons to remain responsive you must keep a reference to this
16531653
object.
16541654
1655-
Connect to the RadioButtons with the `.on_clicked` method.
1655+
Connect to the RadioButtons with the `~._Buttons.on_clicked` method.
16561656
16571657
Attributes
16581658
----------

0 commit comments

Comments
 (0)