Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2da812c

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR #31020: DOC: Fix doc builds with Sphinx 9
1 parent 6e203dc commit 2da812c

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
@@ -891,3 +891,4 @@ def setup(app):
891891
if sphinx.version_info[:2] < (7, 1):
892892
app.connect('html-page-context', add_html_cache_busting, priority=1000)
893893
generate_ScalarMappable_docs()
894+
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
@@ -937,6 +937,7 @@ def trigger(self, *args, **kwargs):
937937
self.toolmanager.message_event(message, self)
938938

939939

940+
#: The default tools to add to a tool manager.
940941
default_tools = {'home': ToolHome, 'back': ToolBack, 'forward': ToolForward,
941942
'zoom': ToolZoom, 'pan': ToolPan,
942943
'subplots': ConfigureSubplotsBase,
@@ -956,12 +957,13 @@ def trigger(self, *args, **kwargs):
956957
'copy': ToolCopyToClipboardBase,
957958
}
958959

960+
#: The default tools to add to a container.
959961
default_toolbar_tools = [['navigation', ['home', 'back', 'forward']],
960962
['zoompan', ['pan', 'zoom', 'subplots']],
961963
['io', ['save', 'help']]]
962964

963965

964-
def add_tools_to_manager(toolmanager, tools=default_tools):
966+
def add_tools_to_manager(toolmanager, tools=None):
965967
"""
966968
Add multiple tools to a `.ToolManager`.
967969
@@ -971,14 +973,16 @@ def add_tools_to_manager(toolmanager, tools=default_tools):
971973
Manager to which the tools are added.
972974
tools : {str: class_like}, optional
973975
The tools to add in a {name: tool} dict, see
974-
`.backend_managers.ToolManager.add_tool` for more info.
976+
`.backend_managers.ToolManager.add_tool` for more info. If not specified, then
977+
defaults to `.default_tools`.
975978
"""
976-
979+
if tools is None:
980+
tools = default_tools
977981
for name, tool in tools.items():
978982
toolmanager.add_tool(name, tool)
979983

980984

981-
def add_tools_to_container(container, tools=default_toolbar_tools):
985+
def add_tools_to_container(container, tools=None):
982986
"""
983987
Add multiple tools to the container.
984988
@@ -990,9 +994,11 @@ def add_tools_to_container(container, tools=default_toolbar_tools):
990994
tools : list, optional
991995
List in the form ``[[group1, [tool1, tool2 ...]], [group2, [...]]]``
992996
where the tools ``[tool1, tool2, ...]`` will display in group1.
993-
See `.backend_bases.ToolContainerBase.add_tool` for details.
997+
See `.backend_bases.ToolContainerBase.add_tool` for details. If not specified,
998+
then defaults to `.default_toolbar_tools`.
994999
"""
995-
1000+
if tools is None:
1001+
tools = default_toolbar_tools
9961002
for group, grouptools in tools:
9971003
for position, tool in enumerate(grouptools):
9981004
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
@@ -980,7 +980,7 @@ class CheckButtons(AxesWidget):
980980
For the check buttons to remain responsive you must keep a
981981
reference to this object.
982982
983-
Connect to the CheckButtons with the `.on_clicked` method.
983+
Connect to the CheckButtons with the `~._Buttons.on_clicked` method.
984984
985985
Attributes
986986
----------
@@ -1545,7 +1545,7 @@ class RadioButtons(AxesWidget):
15451545
For the buttons to remain responsive you must keep a reference to this
15461546
object.
15471547
1548-
Connect to the RadioButtons with the `.on_clicked` method.
1548+
Connect to the RadioButtons with the `~._Buttons.on_clicked` method.
15491549
15501550
Attributes
15511551
----------

0 commit comments

Comments
 (0)