Georg Brandl avatar Georg Brandl committed cf3159d

Don't output system messages while resolving, because they would stay in the doctrees even if keep_warnings is false.

Comments (0)

Files changed (2)

 Release 0.5.2 (in development)
 ==============================
 
+* Don't output system messages while resolving, because they
+  would stay in the doctrees even if keep_warnings is false.
+
 * #82: Determine the correct path for dependencies noted by
   docutils.  This fixes behavior where a source with dependent
   files was always reported as changed.

sphinx/environment.py

                         docname, labelid = self.anonlabels.get(target, ('',''))
                         sectname = node.astext()
                         if not docname:
-                            newnode = doctree.reporter.system_message(
-                                2, 'undefined label: %s' % target)
+                            self.warn(fromdocname, 'undefined label: %s' % target,
+                                      node.line)
                     else:
                         # reference to the named label; the final node will contain the
                         # section name after the label
                         docname, labelid, sectname = self.labels.get(target, ('','',''))
                         if not docname:
-                            newnode = doctree.reporter.system_message(
-                                2, 'undefined label: %s -- if you don\'t ' % target +
+                            self.warn(
+                                fromdocname,
+                                'undefined label: %s -- if you don\'t ' % target +
                                 'give a link caption the label must precede a section '
-                                'header.')
+                                'header.', node.line)
                     if docname:
                         newnode = nodes.reference('', '')
                         innernode = nodes.emphasis(sectname, sectname)
                             if labelid:
                                 newnode['refuri'] += '#' + labelid
                         newnode.append(innernode)
+                    else:
+                        newnode = contnode
                 elif typ == 'keyword':
                     # keywords are referenced by named labels
                     docname, labelid, _ = self.labels.get(target, ('','',''))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.