Skip to content

Commit

Permalink
Harmonise Builder.write_doc()
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 31, 2024
1 parent e3882b9 commit 6a10e65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sphinx/builders/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sphinx.locale import __

if TYPE_CHECKING:
from docutils.nodes import Node
from docutils import nodes

from sphinx.application import Sphinx
from sphinx.util.typing import ExtensionMetadata
Expand All @@ -32,7 +32,7 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str:
def prepare_writing(self, docnames: set[str]) -> None:
pass

def write_doc(self, docname: str, doctree: Node) -> None:
def write_doc(self, docname: str, doctree: nodes.document) -> None:
pass

def finish(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions sphinx/builders/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if TYPE_CHECKING:
from collections.abc import Iterator

from docutils.nodes import Node
from docutils import nodes

from sphinx.application import Sphinx
from sphinx.util.typing import ExtensionMetadata
Expand Down Expand Up @@ -67,7 +67,7 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str:
def prepare_writing(self, docnames: set[str]) -> None:
self.writer = TextWriter(self)

def write_doc(self, docname: str, doctree: Node) -> None:
def write_doc(self, docname: str, doctree: nodes.document) -> None:
self.current_docname = docname
self.secnumbers = self.env.toc_secnumbers.get(docname, {})
destination = StringOutput(encoding='utf-8')
Expand Down
6 changes: 2 additions & 4 deletions sphinx/builders/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
if TYPE_CHECKING:
from collections.abc import Iterator

from docutils.nodes import Node

from sphinx.application import Sphinx
from sphinx.util.typing import ExtensionMetadata

Expand Down Expand Up @@ -73,13 +71,13 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str:
def prepare_writing(self, docnames: set[str]) -> None:
self.writer = self._writer_class(self)

def write_doc(self, docname: str, doctree: Node) -> None:
def write_doc(self, docname: str, doctree: nodes.document) -> None:
# work around multiple string % tuple issues in docutils;
# replace tuples in attribute values with lists
doctree = doctree.deepcopy()
for domain in self.env.domains.values():
xmlns = "xmlns:" + domain.name
doctree[xmlns] = "https://www.sphinx-doc.org/" # type: ignore[index]
doctree[xmlns] = "https://www.sphinx-doc.org/"
for node in doctree.findall(nodes.Element):
for att, value in node.attributes.items():
if isinstance(value, tuple):
Expand Down

0 comments on commit 6a10e65

Please sign in to comment.