summaryrefslogtreecommitdiff
path: root/sphinx/io.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/io.py')
-rw-r--r--sphinx/io.py67
1 files changed, 11 insertions, 56 deletions
diff --git a/sphinx/io.py b/sphinx/io.py
index 3508dd58d..382d31c89 100644
--- a/sphinx/io.py
+++ b/sphinx/io.py
@@ -8,8 +8,7 @@
:license: BSD, see LICENSE for details.
"""
import codecs
-import warnings
-from typing import Any, List
+from typing import TYPE_CHECKING, Any, List, Type
from docutils import nodes
from docutils.core import Publisher
@@ -23,9 +22,7 @@ from docutils.transforms.references import DanglingReferences
from docutils.writers import UnfilteredWriter
from sphinx import addnodes
-from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.environment import BuildEnvironment
-from sphinx.errors import FiletypeNotFoundError
from sphinx.transforms import (AutoIndexUpgrader, DoctreeReadEvent, FigureAligner,
SphinxTransformer)
from sphinx.transforms.i18n import (Locale, PreserveTranslatableMessages,
@@ -35,10 +32,7 @@ from sphinx.util import UnicodeDecodeErrorHandler, get_filetype, logging
from sphinx.util.docutils import LoggingReporter
from sphinx.versioning import UIDTransform
-if False:
- # For type annotation
- from typing import Type # for python3.5.1
-
+if TYPE_CHECKING:
from sphinx.application import Sphinx
@@ -52,7 +46,7 @@ class SphinxBaseReader(standalone.Reader):
This replaces reporter by Sphinx's on generating document.
"""
- transforms = [] # type: List[Type[Transform]]
+ transforms: List[Type[Transform]] = []
def __init__(self, *args: Any, **kwargs: Any) -> None:
from sphinx.application import Sphinx
@@ -63,23 +57,11 @@ class SphinxBaseReader(standalone.Reader):
super().__init__(*args, **kwargs)
- @property
- def app(self) -> "Sphinx":
- warnings.warn('SphinxBaseReader.app is deprecated.',
- RemovedInSphinx40Warning, stacklevel=2)
- return self._app
-
- @property
- def env(self) -> BuildEnvironment:
- warnings.warn('SphinxBaseReader.env is deprecated.',
- RemovedInSphinx40Warning, stacklevel=2)
- return self._env
-
def setup(self, app: "Sphinx") -> None:
self._app = app # hold application object only for compatibility
self._env = app.env
- def get_transforms(self) -> List["Type[Transform]"]:
+ def get_transforms(self) -> List[Type[Transform]]:
transforms = super().get_transforms() + self.transforms
# remove transforms which is not needed for Sphinx
@@ -196,39 +178,12 @@ def read_doc(app: "Sphinx", env: BuildEnvironment, filename: str) -> nodes.docum
# CommonMarkParser.
parser.settings_spec = RSTParser.settings_spec
- input_class = app.registry.get_source_input(filetype)
- if input_class:
- # Sphinx-1.8 style
- source = input_class(app, env, source=None, source_path=filename, # type: ignore
- encoding=env.config.source_encoding)
- pub = Publisher(reader=reader,
- parser=parser,
- writer=SphinxDummyWriter(),
- source_class=SphinxDummySourceClass, # type: ignore
- destination=NullOutput())
- pub.process_programmatic_settings(None, env.settings, None)
- pub.set_source(source, filename)
- else:
- # Sphinx-2.0 style
- pub = Publisher(reader=reader,
- parser=parser,
- writer=SphinxDummyWriter(),
- source_class=SphinxFileInput,
- destination=NullOutput())
- pub.process_programmatic_settings(None, env.settings, None)
- pub.set_source(source_path=filename)
-
+ pub = Publisher(reader=reader,
+ parser=parser,
+ writer=SphinxDummyWriter(),
+ source_class=SphinxFileInput,
+ destination=NullOutput())
+ pub.process_programmatic_settings(None, env.settings, None)
+ pub.set_source(source_path=filename)
pub.publish()
return pub.document
-
-
-deprecated_alias('sphinx.io',
- {
- 'FiletypeNotFoundError': FiletypeNotFoundError,
- 'get_filetype': get_filetype,
- },
- RemovedInSphinx40Warning,
- {
- 'FiletypeNotFoundError': 'sphinx.errors.FiletypeNotFoundError',
- 'get_filetype': 'sphinx.util.get_filetype',
- })