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

Skip to content

Commit 7827326

Browse files
committed
Minor fixes to plot_directive.
1. The `plot_directive` function was reusing the module's docstring, but the latter is not valid numpydoc. Replace by a short stub pointing to the module docstring. 2. jinja2 is a requirement of sphinx since 2008 (sphinx-doc/sphinx@eeb494c), so we can reasonably drop the code to support jinja1.
1 parent 1b5223a commit 7827326

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,7 @@
159159
sphinx_version = tuple([int(re.split('[^0-9]', x)[0])
160160
for x in sphinx_version[:2]])
161161

162-
try:
163-
# Sphinx depends on either Jinja or Jinja2
164-
import jinja2
165-
def format_template(template, **kw):
166-
return jinja2.Template(template).render(**kw)
167-
except ImportError:
168-
import jinja
169-
def format_template(template, **kw):
170-
return jinja.from_string(template, **kw)
162+
import jinja2 # Sphinx dependency.
171163

172164
import matplotlib
173165
import matplotlib.cbook as cbook
@@ -190,8 +182,11 @@ def format_template(template, **kw):
190182

191183
def plot_directive(name, arguments, options, content, lineno,
192184
content_offset, block_text, state, state_machine):
185+
"""Implementation of the ``.. plot::`` directive.
186+
187+
See the module docstring for details.
188+
"""
193189
return run(arguments, content, options, state_machine, state, lineno)
194-
plot_directive.__doc__ = __doc__
195190

196191

197192
def _option_boolean(arg):
@@ -827,8 +822,7 @@ def run(arguments, content, options, state_machine, state, lineno):
827822
else:
828823
src_link = None
829824

830-
result = format_template(
831-
config.plot_template or TEMPLATE,
825+
result = jinja2.Template(config.plot_template or TEMPLATE).render(
832826
default_fmt=default_fmt,
833827
dest_dir=dest_dir_link,
834828
build_dir=build_dir_link,

0 commit comments

Comments
 (0)