summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-10-27 19:42:44 +0100
committerGeorg Brandl <georg@python.org>2009-10-27 19:42:44 +0100
commit213eba02250d003ebd25d2e883ffcc69b37fbd5d (patch)
treecc1c949b1320839c2c6c85f373a731ee481319f4 /tests
parent414816bb373379cf1ca8f4b6ef21a329fff1270f (diff)
downloadsphinx-git-213eba02250d003ebd25d2e883ffcc69b37fbd5d.tar.gz
Automatically convert directive functions, and add a test for that.
Diffstat (limited to 'tests')
-rw-r--r--tests/root/conf.py16
-rw-r--r--tests/root/contents.txt1
-rw-r--r--tests/root/extapi.txt10
-rw-r--r--tests/test_build_html.py4
4 files changed, 31 insertions, 0 deletions
diff --git a/tests/root/conf.py b/tests/root/conf.py
index d268ae3a5..dbb2bca7e 100644
--- a/tests/root/conf.py
+++ b/tests/root/conf.py
@@ -58,7 +58,12 @@ autosummary_generate = ['autosummary']
# modify tags from conf.py
tags.add('confpytag')
+
+# -- extension API
+
+from docutils import nodes
from sphinx import addnodes
+from sphinx.util.compat import Directive
def userdesc_parse(env, sig, signode):
x, y = sig.split(':')
@@ -67,7 +72,18 @@ def userdesc_parse(env, sig, signode):
signode[-1] += addnodes.desc_parameter(y, y)
return x
+def functional_directive(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ return [nodes.strong(text='from function: %s' % options['opt'])]
+
+class ClassDirective(Directive):
+ option_spec = {'opt': lambda x: x}
+ def run(self):
+ return [nodes.strong(text='from class: %s' % self.options['opt'])]
+
def setup(app):
app.add_config_value('value_from_conf_py', 42, False)
+ app.add_directive('funcdir', functional_directive, opt=lambda x: x)
+ app.add_directive('clsdir', ClassDirective)
app.add_description_unit('userdesc', 'userdescrole', '%s (userdesc)',
userdesc_parse)
diff --git a/tests/root/contents.txt b/tests/root/contents.txt
index e1468ad04..2d7ba8fb0 100644
--- a/tests/root/contents.txt
+++ b/tests/root/contents.txt
@@ -11,6 +11,7 @@ Contents:
:maxdepth: 2
:numbered:
+ extapi
images
subdir/images
subdir/includes
diff --git a/tests/root/extapi.txt b/tests/root/extapi.txt
new file mode 100644
index 000000000..4728e3de1
--- /dev/null
+++ b/tests/root/extapi.txt
@@ -0,0 +1,10 @@
+Extension API tests
+===================
+
+Testing directives:
+
+.. funcdir::
+ :opt: Foo
+
+.. clsdir::
+ :opt: Bar
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index 7dfbef5b6..dd89ff2e0 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -66,6 +66,10 @@ HTML_XPATH = {
".//dt[@id='test_autodoc.function']/em": r'\*\*kwds',
".//dd": r'Return spam\.',
},
+ 'extapi.html': {
+ ".//strong": 'from function: Foo',
+ ".//strong": 'from class: Bar',
+ },
'markup.html': {
".//title": 'set by title directive',
".//p/em": 'Section author: Georg Brandl',