summaryrefslogtreecommitdiff
path: root/sphinx/ext/todo.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-09-23 09:46:24 +0200
committerGeorg Brandl <georg@python.org>2011-09-23 09:46:24 +0200
commitdb87ed440c39f08800feb11a5e851674ab949c6b (patch)
treef139be5f44c251ed99b0d2a43afbd047d8d8f279 /sphinx/ext/todo.py
parentfef4faf50d51009160a7947eebd877fb44f6f862 (diff)
downloadsphinx-git-db87ed440c39f08800feb11a5e851674ab949c6b.tar.gz
Fix #648: Fix line numbers reported in warnings about undefined references.
Diffstat (limited to 'sphinx/ext/todo.py')
-rw-r--r--sphinx/ext/todo.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py
index 2ba9d5e1a..c18d70c8d 100644
--- a/sphinx/ext/todo.py
+++ b/sphinx/ext/todo.py
@@ -16,6 +16,7 @@ from docutils import nodes
from sphinx.locale import _
from sphinx.environment import NoUri
+from sphinx.util.nodes import set_source_info
from sphinx.util.compat import Directive, make_admonition
class todo_node(nodes.Admonition, nodes.Element): pass
@@ -41,7 +42,7 @@ class Todo(Directive):
ad = make_admonition(todo_node, self.name, [_('Todo')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
- ad[0].line = self.lineno
+ set_source_info(self, ad[0])
return [targetnode] + ad
@@ -61,6 +62,7 @@ def process_todos(app, doctree):
targetnode = None
env.todo_all_todos.append({
'docname': env.docname,
+ 'source': node.source or env.doc2path(env.docname),
'lineno': node.line,
'todo': node.deepcopy(),
'target': targetnode,
@@ -105,9 +107,9 @@ def process_todo_nodes(app, doctree, fromdocname):
for todo_info in env.todo_all_todos:
para = nodes.paragraph(classes=['todo-source'])
- filename = env.doc2path(todo_info['docname'], base=None)
description = _('(The <<original entry>> is located in '
- ' %s, line %d.)') % (filename, todo_info['lineno'])
+ ' %s, line %d.)') % \
+ (todo_info['source'], todo_info['lineno'])
desc1 = description[:description.find('<<')]
desc2 = description[description.find('>>')+2:]
para += nodes.Text(desc1, desc1)