summaryrefslogtreecommitdiff
path: root/sphinx/builders
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-03-05 09:21:35 +0100
committerGeorg Brandl <georg@python.org>2009-03-05 09:21:35 +0100
commit1ea50bf165f0456df9d2181c366aecca73e96118 (patch)
tree4008de659a759540024ae9df13df29acd6fc89ee /sphinx/builders
parentaaf084a590dd2abcb6486a4a703e799011d09f08 (diff)
downloadsphinx-1ea50bf165f0456df9d2181c366aecca73e96118.tar.gz
Use standard ``file:line: warning: message`` format for warning messages.
Diffstat (limited to 'sphinx/builders')
-rw-r--r--sphinx/builders/__init__.py16
-rw-r--r--sphinx/builders/html.py2
-rw-r--r--sphinx/builders/latex.py9
-rw-r--r--sphinx/builders/linkcheck.py6
-rw-r--r--sphinx/builders/text.py2
5 files changed, 18 insertions, 17 deletions
diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py
index 097be078..7b8a7095 100644
--- a/sphinx/builders/__init__.py
+++ b/sphinx/builders/__init__.py
@@ -136,9 +136,9 @@ class Builder(object):
if candidate:
break
else:
- self.warn('%s:%s: no matching candidate for image URI %r' %
- (node.source, getattr(node, 'lineno', ''),
- node['uri']))
+ self.warn(
+ 'no matching candidate for image URI %r' % node['uri'],
+ '%s:%s' % (node.source, getattr(node, 'line', '')))
continue
node['uri'] = candidate
else:
@@ -249,7 +249,7 @@ class Builder(object):
updated_docnames = set()
# while reading, collect all warnings from docutils
warnings = []
- self.env.set_warnfunc(warnings.append)
+ self.env.set_warnfunc(lambda *args: warnings.append(args))
self.info(bold('updating environment: '), nonl=1)
iterator = self.env.update(self.config, self.srcdir,
self.doctreedir, self.app)
@@ -261,8 +261,7 @@ class Builder(object):
# nothing further to do, the environment has already
# done the reading
for warning in warnings:
- if warning.strip():
- self.warn(warning)
+ self.warn(*warning)
self.env.set_warnfunc(self.warn)
doccount = len(updated_docnames)
@@ -327,14 +326,13 @@ class Builder(object):
# write target files
warnings = []
- self.env.set_warnfunc(warnings.append)
+ self.env.set_warnfunc(lambda *args: warnings.append(args))
for docname in self.status_iterator(sorted(docnames),
'writing output... ', darkgreen):
doctree = self.env.get_and_resolve_doctree(docname, self)
self.write_doc(docname, doctree)
for warning in warnings:
- if warning.strip():
- self.warn(warning)
+ self.warn(*warning)
self.env.set_warnfunc(self.warn)
def prepare_writing(self, docnames):
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index 6c2593ba..365cf5f9 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -657,7 +657,7 @@ class StandaloneHTMLBuilder(Builder):
finally:
f.close()
except (IOError, OSError), err:
- self.warn("Error writing file %s: %s" % (outfilename, err))
+ self.warn("error writing file %s: %s" % (outfilename, err))
if self.copysource and ctx.get('sourcename'):
# copy the source file for the "show source" link
source_name = path.join(self.outdir, '_sources',
diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py
index 9fe7b8a5..96d70e3e 100644
--- a/sphinx/builders/latex.py
+++ b/sphinx/builders/latex.py
@@ -60,8 +60,8 @@ class LaTeXBuilder(Builder):
def init_document_data(self):
preliminary_document_data = map(list, self.config.latex_documents)
if not preliminary_document_data:
- self.warn('No "latex_documents" config value found; no documents '
- 'will be written.')
+ self.warn('no "latex_documents" config value found; no documents '
+ 'will be written')
return
# assign subdirs to titles
self.titles = []
@@ -121,8 +121,9 @@ class LaTeXBuilder(Builder):
includefile, self.env.get_doctree(includefile))
self.docnames.add(includefile)
except Exception:
- self.warn('%s: toctree contains ref to nonexisting '
- 'file %r' % (docname, includefile))
+ self.warn('toctree contains ref to nonexisting '
+ 'file %r' % includefile,
+ self.builder.env.doc2path(docname))
else:
sof = addnodes.start_of_file(docname=includefile)
sof.children = subtree.children
diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py
index b0fa9ba6..f3962965 100644
--- a/sphinx/builders/linkcheck.py
+++ b/sphinx/builders/linkcheck.py
@@ -87,7 +87,8 @@ class CheckExternalLinksBuilder(Builder):
self.write_entry('broken', docname, lineno, uri + ': ' + s)
self.broken[uri] = (r, s)
if self.app.quiet:
- self.warn('%s:%s: broken link: %s' % (docname, lineno, uri))
+ self.warn('broken link: %s' % uri,
+ '%s:%s' % (self.env.doc2path(docname), lineno))
else:
self.info(' - ' + purple('redirected') + ' to ' + s)
self.write_entry('redirected', docname,
@@ -99,7 +100,8 @@ class CheckExternalLinksBuilder(Builder):
self.warn(uri + ' - ' + red('malformed!'))
self.write_entry('malformed', docname, lineno, uri)
if self.app.quiet:
- self.warn('%s:%s: malformed link: %s' % (docname, lineno, uri))
+ self.warn('malformed link: %s' % uri,
+ '%s:%s' % (self.env.doc2path(docname), lineno))
self.app.statuscode = 1
if self.broken:
diff --git a/sphinx/builders/text.py b/sphinx/builders/text.py
index 93737285..8651778c 100644
--- a/sphinx/builders/text.py
+++ b/sphinx/builders/text.py
@@ -64,7 +64,7 @@ class TextBuilder(Builder):
finally:
f.close()
except (IOError, OSError), err:
- self.warn("Error writing file %s: %s" % (outfilename, err))
+ self.warn("error writing file %s: %s" % (outfilename, err))
def finish(self):
pass