Warn if doctest blocks don't contain code.

This commit is contained in:
Georg Brandl 2008-12-15 11:29:07 +01:00
parent 44b0929669
commit 7debd67c23
2 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,8 @@
Release 0.5.1 (in development)
==============================
* Warn if a doctest extension block doesn't contain any code.
* Fix the handling of ``:param:`` and ``:type:`` doc fields when
they contain markup (especially cross-referencing roles).

View File

@ -229,8 +229,12 @@ Doctest summary
return isinstance(node, (nodes.literal_block, nodes.comment)) \
and node.has_key('testnodetype')
for node in doctree.traverse(condition):
code = TestCode(node.has_key('test') and node['test'] or node.astext(),
type=node.get('testnodetype', 'doctest'),
source = node.has_key('test') and node['test'] or node.astext()
if not source:
self.warn('no code/output in %s block at %s:%s' %
(node.get('testnodetype', 'doctest'),
self.env.doc2path(docname), node.line))
code = TestCode(source, type=node.get('testnodetype', 'doctest'),
lineno=node.line, options=node.get('options'))
node_groups = node.get('groups', ['default'])
if '*' in node_groups: