Allow to build docs in readthedocs.org

At present, readthedocs_ext expects that DirectoryHTMLBuilder and
SingleFileHTMLBuilder are placed at sphinx.builders.html module.
But they were deprecated since Sphinx-2.0 and will be removed at
Sphinx-4.0.

This revives them temporarily to build our document successfully on
RTD until readthedocs_ext supports the new structure of Sphinx
components.

refs: https://github.com/readthedocs/readthedocs-sphinx-ext/pull/86
This commit is contained in:
Takeshi KOMIYA
2020-05-03 23:23:25 +09:00
parent 257550a547
commit 08f25d39af
3 changed files with 19 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ from typing import Any, Dict
from sphinx.application import Sphinx
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.util import logging
from sphinx.util.osutil import SEP, os_path
@@ -45,6 +46,14 @@ class DirectoryHTMLBuilder(StandaloneHTMLBuilder):
return outfilename
# for compatibility
deprecated_alias('sphinx.builders.html',
{
'DirectoryHTMLBuilder': DirectoryHTMLBuilder,
},
RemovedInSphinx40Warning)
def setup(app: Sphinx) -> Dict[str, Any]:
app.setup_extension('sphinx.builders.html')

View File

@@ -1162,7 +1162,7 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
config.html_favicon = None # type: ignore
# for compatibility
# for compatibility; RemovedInSphinx40Warning
import sphinx.builders.dirhtml # NOQA
import sphinx.builders.singlehtml # NOQA
import sphinxcontrib.serializinghtml # NOQA

View File

@@ -16,6 +16,7 @@ from docutils.nodes import Node
from sphinx.application import Sphinx
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias
from sphinx.environment.adapters.toctree import TocTree
from sphinx.locale import __
from sphinx.util import logging
@@ -187,6 +188,14 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
self.handle_page('opensearch', {}, 'opensearch.xml', outfilename=fn)
# for compatibility
deprecated_alias('sphinx.builders.html',
{
'SingleFileHTMLBuilder': SingleFileHTMLBuilder,
},
RemovedInSphinx40Warning)
def setup(app: Sphinx) -> Dict[str, Any]:
app.setup_extension('sphinx.builders.html')