Skip to content

Commit

Permalink
Fix #7195: todo: emit doctree-resolved event with non-document node i…
Browse files Browse the repository at this point in the history
…ncorrectly
  • Loading branch information
tk0miya committed Feb 22, 2020
1 parent 723c449 commit 29db44a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Bugs fixed
* #7189: autodoc: classmethod coroutines are not detected
* #7183: intersphinx: ``:attr:`` reference to property is broken
* #6244, #6387: html search: Search breaks/hangs when built with dirhtml builder
* #7195: todo: emit doctree-resolved event with non-document node incorrectly


Testing
Expand Down
9 changes: 7 additions & 2 deletions sphinx/ext/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from sphinx.errors import NoUri
from sphinx.locale import _, __
from sphinx.util import logging, texescape
from sphinx.util.docutils import SphinxDirective
from sphinx.util.docutils import SphinxDirective, new_document
from sphinx.util.nodes import make_refnode
from sphinx.writers.html import HTMLTranslator
from sphinx.writers.latex import LaTeXTranslator
Expand Down Expand Up @@ -159,6 +159,7 @@ def __init__(self, app: Sphinx, doctree: nodes.document, docname: str) -> None:

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)
Expand All @@ -175,7 +176,11 @@ def process(self, doctree: nodes.document, docname: str) -> None:
new_todo['ids'].clear()

# (Recursively) resolve references in the todo content
self.env.resolve_references(new_todo, todo['docname'], self.builder) # type: ignore # NOQA
#
# 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)
content.append(new_todo)

todo_ref = self.create_todo_reference(todo, docname)
Expand Down

0 comments on commit 29db44a

Please sign in to comment.