Georg Brandl  committed 8af4bb3

Warn if doctest blocks don't contain code.

  • Participants
  • Parent commits c62c9b8
  • Branches default

Comments (0)

Files changed (2)

 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).

File sphinx/ext/

                 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: