159159sphinx_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
172164import matplotlib
173165import matplotlib .cbook as cbook
@@ -190,8 +182,11 @@ def format_template(template, **kw):
190182
191183def 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
197192def _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