Skip to content

Commit c6c6cf7

Browse files
committed
changed paths in kwdocs
1 parent 0a7c0d2 commit c6c6cf7

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

lib/matplotlib/artist.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ def mouseover(self, val):
10351035

10361036
class ArtistInspector(object):
10371037
"""
1038-
A helper class to inspect an :class:`~matplotlib.artist.Artist` and return
1038+
A helper class to inspect an `~matplotlib.artist.Artist` and return
10391039
information about its settable properties and their current values.
10401040
"""
10411041

@@ -1146,9 +1146,23 @@ def _get_setters_and_targets(self):
11461146
if name in cls.__dict__:
11471147
source_class = cls.__module__ + "." + cls.__name__
11481148
break
1149+
source_class = self._replace_path(source_class)
11491150
setters.append((name[4:], source_class + "." + name))
11501151
return setters
11511152

1153+
def _replace_path(self, source_class):
1154+
"""
1155+
Changes the full path to the public API path that is used
1156+
in sphinx. This is needed for links to work.
1157+
"""
1158+
1159+
replace_dict = {'_base._AxesBase': 'Axes',
1160+
'_axes.Axes': 'Axes'}
1161+
1162+
for key, value in replace_dict.items():
1163+
source_class = source_class.replace(key, value)
1164+
return source_class
1165+
11521166
def get_setters(self):
11531167
"""
11541168
Get the attribute strings with setters for object. e.g., for a line,
@@ -1443,12 +1457,32 @@ def setp(obj, *args, **kwargs):
14431457
return list(cbook.flatten(ret))
14441458

14451459

1446-
def kwdoc(a):
1460+
def kwdoc(artist):
1461+
"""
1462+
Inspect an `~matplotlib.artist.Artist` class and return
1463+
information about its settable properties and their current values.
1464+
1465+
It use the class `.ArtistInspector`.
1466+
1467+
Parameters
1468+
----------
1469+
artist : `~matplotlib.artist.Artist` or an iterable of `Artist`\s
1470+
1471+
Returns
1472+
-------
1473+
string
1474+
Returns a string with a list or rst table with the settable properties
1475+
of the *artist*. The formating depends on the value of
1476+
:rc:`docstring.hardcopy`. False result in a list that is intended for
1477+
easy reading as a docstring and True result in a rst table intended
1478+
for rendering the documentation with sphinx.
1479+
"""
14471480
hardcopy = matplotlib.rcParams['docstring.hardcopy']
14481481
if hardcopy:
1449-
return '\n'.join(ArtistInspector(a).pprint_setters_rest(
1482+
return '\n'.join(ArtistInspector(artist).pprint_setters_rest(
14501483
leadingspace=4))
14511484
else:
1452-
return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=2))
1485+
return '\n'.join(ArtistInspector(artist).pprint_setters(
1486+
leadingspace=2))
14531487

14541488
docstring.interpd.update(Artist=kwdoc(Artist))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy