summaryrefslogtreecommitdiff
path: root/doc/sphinxext/plot_directive.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-06-27 15:02:14 +0000
committerPauli Virtanen <pav@iki.fi>2009-06-27 15:02:14 +0000
commit692f3f65acd441995f893908d694b3891a67070c (patch)
treeeaf7c6fe5d1b3ab13525eb7f85fd598db67cce6a /doc/sphinxext/plot_directive.py
parentcefd431502c6b9915611ca46cd8194b7007db0ef (diff)
downloadnumpy-692f3f65acd441995f893908d694b3891a67070c.tar.gz
docs: generate Attributes and Methods sections in class documentation
Diffstat (limited to 'doc/sphinxext/plot_directive.py')
-rw-r--r--doc/sphinxext/plot_directive.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/doc/sphinxext/plot_directive.py b/doc/sphinxext/plot_directive.py
index f564cd670..8de8c7399 100644
--- a/doc/sphinxext/plot_directive.py
+++ b/doc/sphinxext/plot_directive.py
@@ -73,6 +73,7 @@ TODO
"""
import sys, os, glob, shutil, imp, warnings, cStringIO, re, textwrap, traceback
+import sphinx
import warnings
warnings.warn("A plot_directive module is also available under "
@@ -157,7 +158,7 @@ except ImportError:
TEMPLATE = """
{{ source_code }}
-.. htmlonly::
+{{ only_html }}
{% if source_code %}
(`Source code <{{ source_link }}>`__)
@@ -188,7 +189,7 @@ TEMPLATE = """
)
{% endfor %}
-.. latexonly::
+{{ only_latex }}
{% for img in images %}
.. image:: {{ build_dir }}/{{ img.basename }}.pdf
@@ -304,11 +305,20 @@ def run(arguments, content, options, state_machine, state, lineno):
opts = [':%s: %s' % (key, val) for key, val in options.items()
if key in ('alt', 'height', 'width', 'scale', 'align', 'class')]
+ if sphinx.__version__ >= "0.6":
+ only_html = ".. only:: html"
+ only_latex = ".. only:: latex"
+ else:
+ only_html = ".. htmlonly::"
+ only_latex = ".. latexonly::"
+
result = format_template(
TEMPLATE,
dest_dir=dest_dir_link,
build_dir=build_dir_link,
source_link=source_link,
+ only_html=only_html,
+ only_latex=only_latex,
options=opts,
images=images,
source_code=source_code)