Skip to content

Commit 7a199a2

Browse files
committed
Small API cleanups to plot_directive.
docutils' Image.align has existed since 2006.
1 parent 327cfcf commit 7a199a2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``sphinext.plot_directive.align``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated. Use ``docutils.parsers.rst.directives.images.Image.align``
4+
instead.

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@
159159
from matplotlib import _pylab_helpers, cbook
160160

161161
matplotlib.use("agg")
162-
align = Image.align
162+
align = cbook.deprecated(
163+
"3.4", alternative="docutils.parsers.rst.directives.images.Image.align")(
164+
Image.align)
163165

164166
__version__ = 2
165167

@@ -191,11 +193,6 @@ def _option_format(arg):
191193
return directives.choice(arg, ('python', 'doctest'))
192194

193195

194-
def _option_align(arg):
195-
return directives.choice(arg, ("top", "middle", "bottom", "left", "center",
196-
"right"))
197-
198-
199196
def mark_plot_labels(app, document):
200197
"""
201198
To make plots referenceable, we need to move the reference from the
@@ -238,7 +235,7 @@ class PlotDirective(Directive):
238235
'height': directives.length_or_unitless,
239236
'width': directives.length_or_percentage_or_unitless,
240237
'scale': directives.nonnegative_int,
241-
'align': _option_align,
238+
'align': Image.align,
242239
'class': directives.class_option,
243240
'include-source': _option_boolean,
244241
'format': _option_format,
@@ -258,7 +255,6 @@ def run(self):
258255

259256

260257
def setup(app):
261-
import matplotlib
262258
setup.app = app
263259
setup.config = app.config
264260
setup.confdir = app.confdir

0 commit comments

Comments
 (0)