Add deprecation warning for dropping Sphinx 2 and Python 2 support (#1099)

* Add deprecation warning for dropping Sphinx 2 and Python 2 support

Fixes #1092

* Cleanup version imports

* Update __init__.py

* Update sphinx_rtd_theme/__init__.py

Co-authored-by: Santos Gallegos <santos_g@outlook.com>

Co-authored-by: Santos Gallegos <santos_g@outlook.com>
This commit is contained in:
Aaron Carlisle 2021-03-29 15:57:14 -04:00 committed by GitHub
parent 6f684828ed
commit 3693d4c325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,9 @@ From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""
from os import path
from sys import version_info as python_version
from sphinx import version_info
from sphinx import version_info as sphinx_version
from sphinx.locale import _
from sphinx.util.logging import getLogger
@ -33,8 +34,11 @@ def config_initiated(app, config):
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
def setup(app):
if python_version[0] < 3:
logger.warning("Python 2 is deprecated with sphinx_rtd_theme, update to Python 3")
app.require_sphinx('1.6')
if version_info <= (2, 0, 0):
if sphinx_version <= (2, 0, 0):
logger.warning("Sphinx 1.x is deprecated with sphinx_rtd_theme, update to Sphinx 2.x or greater")
if not app.config.html_experimental_html5_writer:
logger.warning("'html4_writer' is deprecated with sphinx_rtd_theme")
else:
@ -44,7 +48,7 @@ def setup(app):
# Register the theme that can be referenced without adding a theme path
app.add_html_theme('sphinx_rtd_theme', path.abspath(path.dirname(__file__)))
if version_info >= (1, 8, 0):
if sphinx_version >= (1, 8, 0):
# Add Sphinx message catalog for newer versions of Sphinx
# See http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_message_catalog
rtd_locale_path = path.join(path.abspath(path.dirname(__file__)), 'locale')