mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Test add_description_unit in test suite.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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`.
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user