Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-01 19:17:56 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-01 19:27:11 +0300
commita65b333c87fa5fdd993cd3f4a66e69da35eab261 (patch)
tree84d3dd1787872ed2b74984d314b43a85a2423458 /sphinx/ext/todo.py
parent2956f19674071c51c7f84bb4428ce12aff8b8033 (diff)
Fix #8782: todo: Cross references in todolist get broken
On resolving cross reference nodes in todolist, some of them get broken because todo extension does not rewrite the "refdoc" attribute of them.
Diffstat (limited to 'sphinx/ext/todo.py')
-rw-r--r--sphinx/ext/todo.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py
index 640c93935..a73dea84d 100644
--- a/sphinx/ext/todo.py
+++ b/sphinx/ext/todo.py
@@ -20,6 +20,7 @@ from docutils.parsers.rst import directives
from docutils.parsers.rst.directives.admonitions import BaseAdmonition
import sphinx
+from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.deprecation import RemovedInSphinx40Warning
from sphinx.domains import Domain
@@ -153,12 +154,12 @@ class TodoListProcessor:
self.config = app.config
self.env = app.env
self.domain = cast(TodoDomain, app.env.get_domain('todo'))
+ self.document = new_document('')
self.process(doctree, docname)
def process(self, doctree: nodes.document, docname: str) -> None:
todos = sum(self.domain.todos.values(), []) # type: List[todo_node]
- document = new_document('')
for node in doctree.traverse(todolist):
if not self.config.todo_include_todos:
node.parent.remove(node)
@@ -174,12 +175,7 @@ class TodoListProcessor:
new_todo = todo.deepcopy()
new_todo['ids'].clear()
- # (Recursively) resolve references in the todo content
- #
- # Note: To resolve references, it is needed to wrap it with document node
- document += new_todo
- self.env.resolve_references(document, todo['docname'], self.builder)
- document.remove(new_todo)
+ self.resolve_reference(new_todo, docname)
content.append(new_todo)
todo_ref = self.create_todo_reference(todo, docname)
@@ -215,6 +211,17 @@ class TodoListProcessor:
return para
+ def resolve_reference(self, todo: todo_node, docname: str) -> None:
+ """Resolve references in the todo content."""
+ for node in todo.traverse(addnodes.pending_xref):
+ if 'refdoc' in node:
+ node['refdoc'] = docname
+
+ # Note: To resolve references, it is needed to wrap it with document node
+ self.document += todo
+ self.env.resolve_references(self.document, docname, self.builder)
+ self.document.remove(todo)
+
def process_todo_nodes(app: Sphinx, doctree: nodes.document, fromdocname: str) -> None:
"""Replace all todolist nodes with a list of the collected todos.