diff --git a/CHANGES b/CHANGES index 73a3dce7b..e63b673a7 100644 --- a/CHANGES +++ b/CHANGES @@ -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). diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index badd50ffd..c09de94fa 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -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: