diff options
Diffstat (limited to 'sphinx/io.py')
-rw-r--r-- | sphinx/io.py | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/sphinx/io.py b/sphinx/io.py index f3e72733e..624a04246 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -18,7 +18,8 @@ from docutils.readers import standalone from docutils.transforms.references import DanglingReferences from docutils.writers import UnfilteredWriter -from sphinx.deprecation import RemovedInSphinx40Warning +from sphinx.errors import FiletypeNotFoundError +from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias from sphinx.transforms import ( AutoIndexUpgrader, DoctreeReadEvent, FigureAligner, SphinxTransformer ) @@ -26,7 +27,7 @@ from sphinx.transforms.i18n import ( PreserveTranslatableMessages, Locale, RemoveTranslatableInline, ) from sphinx.transforms.references import SphinxDomains -from sphinx.util import logging +from sphinx.util import logging, get_filetype from sphinx.util import UnicodeDecodeErrorHandler from sphinx.util.docutils import LoggingReporter from sphinx.versioning import UIDTransform @@ -192,20 +193,6 @@ class SphinxFileInput(FileInput): super().__init__(*args, **kwargs) -class FiletypeNotFoundError(Exception): - pass - - -def get_filetype(source_suffix, filename): - # type: (Dict[str, str], str) -> str - for suffix, filetype in source_suffix.items(): - if filename.endswith(suffix): - # If default filetype (None), considered as restructuredtext. - return filetype or 'restructuredtext' - else: - raise FiletypeNotFoundError - - def read_doc(app, env, filename): # type: (Sphinx, BuildEnvironment, str) -> nodes.document """Parse a document and convert to doctree.""" @@ -249,3 +236,11 @@ def read_doc(app, env, filename): pub.publish() return pub.document + + +deprecated_alias('sphinx.io', + { + 'FiletypeNotFoundError': FiletypeNotFoundError, + 'get_filetype': get_filetype, + }, + RemovedInSphinx40Warning) |