summaryrefslogtreecommitdiff
path: root/sphinx/io.py
diff options
context:
space:
mode:
authorAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-05-07 13:03:43 +0100
committerAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-05-07 13:11:39 +0100
commit919eb1db912ae80c98b3edfbb303dcd04e2b3e9c (patch)
treed96c1a2e5877e087bb86a065d86cfa3b4c59cbef /sphinx/io.py
parentf346e0a11f358f0496524b1e3f5d0984722f7d85 (diff)
downloadsphinx-git-919eb1db912ae80c98b3edfbb303dcd04e2b3e9c.tar.gz
Inline `io.read_doc` and explain why settings are copied
Diffstat (limited to 'sphinx/io.py')
-rw-r--r--sphinx/io.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/sphinx/io.py b/sphinx/io.py
index 4ffa8e54d..b4cec7d3e 100644
--- a/sphinx/io.py
+++ b/sphinx/io.py
@@ -1,5 +1,5 @@
"""Input/Output files"""
-import codecs
+
from typing import TYPE_CHECKING, Any, List, Type
from docutils import nodes
@@ -19,7 +19,7 @@ from sphinx.transforms import (AutoIndexUpgrader, DoctreeReadEvent, FigureAligne
from sphinx.transforms.i18n import (Locale, PreserveTranslatableMessages,
RemoveTranslatableInline)
from sphinx.transforms.references import SphinxDomains
-from sphinx.util import UnicodeDecodeErrorHandler, logging
+from sphinx.util import logging
from sphinx.util.docutils import LoggingReporter
from sphinx.versioning import UIDTransform
@@ -152,21 +152,6 @@ class SphinxFileInput(FileInput):
super().__init__(*args, **kwargs)
-def read_doc(publisher: Publisher, docname: str, filename: str) -> nodes.document:
- """Parse a document and convert to doctree."""
- # set up error_handler for the target document
- error_handler = UnicodeDecodeErrorHandler(docname)
- codecs.register_error('sphinx', error_handler) # type: ignore
-
- publisher.set_source(source_path=filename)
- publisher.publish()
-
- doctree = publisher.document
- # settings get modified in ``write_doctree``; get a local copy
- doctree.settings = doctree.settings.copy()
- return doctree
-
-
def create_publisher(app: "Sphinx", filetype: str) -> Publisher:
reader = SphinxStandaloneReader()
reader.setup(app)