Test add_description_unit in test suite.

This commit is contained in:
Georg Brandl
2009-02-18 22:12:03 +01:00
parent 54b0890095
commit a06813c4ae
3 changed files with 27 additions and 3 deletions

View File

@@ -48,5 +48,16 @@ coverage_c_path = ['special/*.h']
coverage_c_regexes = {'cfunction': r'^PyAPI_FUNC\(.*\)\s+([^_][\w_]+)'}
from sphinx import addnodes
def userdesc_parse(env, sig, signode):
x, y = sig.split(':')
signode += addnodes.desc_name(x, x)
signode += addnodes.desc_parameterlist()
signode[-1] += addnodes.desc_parameter(y, y)
return x
def setup(app):
app.add_config_value('value_from_conf_py', 42, False)
app.add_description_unit('userdesc', 'userdescrole', '%s (userdesc)',
userdesc_parse)

View File

@@ -58,3 +58,14 @@ Testing references
==================
Referencing :class:`mod.Cls` or :Class:`mod.Cls` should be the same.
User markup
===========
.. userdesc:: myobj:parameter
Description of userdesc.
Referencing :userdescrole:`myobj`.

View File

@@ -88,6 +88,9 @@ HTML_XPATH = {
".//dt[@id='mod.Cls.meth1']": '',
".//dt[@id='errmod.Error']": '',
".//a[@href='#mod.Cls']": '',
".//dl[@class='userdesc']": '',
".//dt[@id='userdescrole-myobj']": '',
".//a[@href='#userdescrole-myobj']": '',
},
'contents.html': {
".//meta[@name='hc'][@content='hcval']": '',
@@ -147,9 +150,8 @@ def test_html(app):
etree = ET.parse(os.path.join(app.outdir, fname), parser)
for path, check in paths.iteritems():
nodes = list(etree.findall(path))
if not nodes:
import pdb; pdb.set_trace()
assert nodes != []
assert nodes != [], ('did not find any node matching xpath '
'%r in file %s' % (path, fname))
if hasattr(check, '__call__'):
check(nodes)
elif not check: