From c48dfada7c3227ee4b470db7d58f460c2824be3a Mon Sep 17 00:00:00 2001 From: Bruno Beltran Date: Thu, 6 May 2021 11:22:22 -0700 Subject: [PATCH] DOCS: fully qualify docstring _enum refs Avoid using explicit references to private module in docs, instead let intersphinx handle it. --- lib/matplotlib/_enums.py | 8 ++++++-- lib/matplotlib/backend_bases.py | 10 ++++++---- lib/matplotlib/collections.py | 12 ++++++------ lib/matplotlib/lines.py | 16 ++++++++-------- lib/matplotlib/patches.py | 8 ++++---- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/lib/matplotlib/_enums.py b/lib/matplotlib/_enums.py index 35fe82482869..d0eb14d4369c 100644 --- a/lib/matplotlib/_enums.py +++ b/lib/matplotlib/_enums.py @@ -204,5 +204,9 @@ def demo(): + ", ".join([f"'{cs.name}'" for cs in CapStyle]) \ + "}" -docstring.interpd.update({'JoinStyle': JoinStyle.input_description, - 'CapStyle': CapStyle.input_description}) +docstring.interpd.update({ + 'JoinStyleLink': '`~matplotlib._enums.JoinStyle`', + 'JoinStyle': JoinStyle.input_description, + 'CapStyleLink': '`~matplotlib._enums.CapStyle`', + 'CapStyle': CapStyle.input_description +}) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 8615967fd981..f5975f35e7b2 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -805,8 +805,9 @@ def get_antialiased(self): """Return whether the object should try to do antialiased rendering.""" return self._antialiased + @docstring.interpd def get_capstyle(self): - """Return the `.CapStyle`.""" + """Return the %(CapStyleLink)s.""" return self._capstyle.name def get_clip_rectangle(self): @@ -850,8 +851,9 @@ def get_forced_alpha(self): """ return self._forced_alpha + @docstring.interpd def get_joinstyle(self): - """Return the `.JoinStyle`.""" + """Return the %(JoinStyleLink)s.""" return self._joinstyle.name def get_linewidth(self): @@ -910,7 +912,7 @@ def set_capstyle(self, cs): Parameters ---------- - cs : `.CapStyle` or %(CapStyle)s + cs : %(CapStyleLink)s or %(CapStyle)s """ self._capstyle = CapStyle(cs) @@ -976,7 +978,7 @@ def set_joinstyle(self, js): Parameters ---------- - js : `.JoinStyle` or %(JoinStyle)s + js : %(JoinStyleLink)s or %(JoinStyle)s """ self._joinstyle = JoinStyle(js) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index d02607cc5052..faa4ee0ceb1d 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -114,10 +114,10 @@ def __init__(self, where *onoffseq* is an even length tuple of on and off ink lengths in points. For examples, see :doc:`/gallery/lines_bars_and_markers/linestyles`. - capstyle : `.CapStyle`-like, default: :rc:`patch.capstyle` + capstyle : %(CapStyleLink)s-like, default: :rc:`patch.capstyle` Style to use for capping lines for all paths in the collection. Allowed values are %(CapStyle)s. - joinstyle : `.JoinStyle`-like, default: :rc:`patch.joinstyle` + joinstyle : %(JoinStyleLink)s-like, default: :rc:`patch.joinstyle` Style to use for joining lines for all paths in the collection. Allowed values are %(JoinStyle)s. antialiaseds : bool or list of bool, default: :rc:`patch.antialiased` @@ -664,11 +664,11 @@ def set_linestyle(self, ls): @docstring.interpd def set_capstyle(self, cs): """ - Set the `.CapStyle` for the collection (for all its elements). + Set the %(CapStyleLink)s for the collection (for all its elements). Parameters ---------- - cs : `.CapStyle` or %(CapStyle)s + cs : %(CapStyleLink)s or %(CapStyle)s """ self._capstyle = CapStyle(cs) @@ -678,11 +678,11 @@ def get_capstyle(self): @docstring.interpd def set_joinstyle(self, js): """ - Set the `.JoinStyle` for the collection (for all its elements). + Set the %(JoinStyleLink)s for the collection (for all its elements). Parameters ---------- - js : `.JoinStyle` or %(JoinStyle)s + js : %(JoinStyleLink)s or %(JoinStyle)s """ self._joinstyle = JoinStyle(js) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index a94a7aa4868e..d7d116ff4796 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1295,7 +1295,7 @@ def set_dash_joinstyle(self, s): Parameters ---------- - s : `.JoinStyle` or %(JoinStyle)s + s : %(JoinStyleLink)s or %(JoinStyle)s """ js = JoinStyle(s) if self._dashjoinstyle != js: @@ -1309,7 +1309,7 @@ def set_solid_joinstyle(self, s): Parameters ---------- - s : `.JoinStyle` or %(JoinStyle)s + s : %(JoinStyleLink)s or %(JoinStyle)s """ js = JoinStyle(s) if self._solidjoinstyle != js: @@ -1318,7 +1318,7 @@ def set_solid_joinstyle(self, s): def get_dash_joinstyle(self): """ - Return the `.JoinStyle` for dashed lines. + Return the %(JoinStyleLink)s for dashed lines. See also `~.Line2D.set_dash_joinstyle`. """ @@ -1326,7 +1326,7 @@ def get_dash_joinstyle(self): def get_solid_joinstyle(self): """ - Return the `.JoinStyle` for solid lines. + Return the %(JoinStyleLink)s for solid lines. See also `~.Line2D.set_solid_joinstyle`. """ @@ -1339,7 +1339,7 @@ def set_dash_capstyle(self, s): Parameters ---------- - s : `.CapStyle` or %(CapStyle)s + s : %(CapStyleLink)s or %(CapStyle)s """ cs = CapStyle(s) if self._dashcapstyle != cs: @@ -1353,7 +1353,7 @@ def set_solid_capstyle(self, s): Parameters ---------- - s : `.CapStyle` or %(CapStyle)s + s : %(CapStyleLink)s or %(CapStyle)s """ cs = CapStyle(s) if self._solidcapstyle != cs: @@ -1362,7 +1362,7 @@ def set_solid_capstyle(self, s): def get_dash_capstyle(self): """ - Return the `.CapStyle` for dashed lines. + Return the %(CapStyleLink)s for dashed lines. See also `~.Line2D.set_dash_capstyle`. """ @@ -1370,7 +1370,7 @@ def get_dash_capstyle(self): def get_solid_capstyle(self): """ - Return the `.CapStyle` for solid lines. + Return the %(CapStyleLink)s for solid lines. See also `~.Line2D.set_solid_capstyle`. """ diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 3b4e1f5c3818..dc30ccee95e5 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -479,11 +479,11 @@ def get_fill(self): @docstring.interpd def set_capstyle(self, s): """ - Set the `.CapStyle`. + Set the %(CapStyleLink)s. Parameters ---------- - s : `.CapStyle` or %(CapStyle)s + s : %(CapStyleLink)s or %(CapStyle)s """ cs = CapStyle(s) self._capstyle = cs @@ -496,11 +496,11 @@ def get_capstyle(self): @docstring.interpd def set_joinstyle(self, s): """ - Set the `.JoinStyle`. + Set the %(JoinStyleLink)s. Parameters ---------- - s : `.JoinStyle` or %(JoinStyle)s + s : %(JoinStyleLink)s or %(JoinStyle)s """ js = JoinStyle(s) self._joinstyle = js