Skip to content

Commit 3275b8a

Browse files
committed
Print a warning when building docs with a pre-release version of the theme
1 parent feb0beb commit 3275b8a

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

babel.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
encoding = utf-8
99
ignore_tags = script,style
1010
include_attrs = alt title summary placeholder
11+
12+
# Extraction from Python files
13+
[python: **.py]

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Other Changes
2020
* Added Spanish translation
2121
* Added i18n support using Babel
2222
* Moved build system from Grunt and friends to Webpack
23+
* Warn when using a pre-release version of the theme
2324

2425
0.4.3
2526
======

sphinx_rtd_theme/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
"""
66

77
from os import path
8+
import pkg_resources
9+
from sphinx.util import logging
10+
from sphinx.locale import get_translation
811

912
import sphinx
1013

1114

1215
__version__ = '0.4.3.dev0'
1316
__version_full__ = __version__
1417

18+
logger = logging.getLogger('sphinx-rtd-theme')
19+
MESSAGE_CATALOG_NAME = 'sphinx'
20+
_ = get_translation(MESSAGE_CATALOG_NAME)
21+
1522

1623
def get_html_theme_path():
1724
"""Return list of HTML theme paths."""
@@ -23,8 +30,15 @@ def get_html_theme_path():
2330
def setup(app):
2431
app.add_html_theme('sphinx_rtd_theme', path.abspath(path.dirname(__file__)))
2532

33+
# Warn if a prerelease version of the theme is used
34+
parsed_version = pkg_resources.parse_version(__version__)
35+
if parsed_version.is_prerelease:
36+
logger.warning(_('You are using a pre-release version (%s) of sphinx-rtd-theme.'), __version__)
37+
logger.warning(_('Use a stable release if you encounter problems.'))
38+
logger.warning(_('See <https://sphinx-rtd-theme.readthedocs.io/en/stable/installing.html>.'))
39+
2640
if sphinx.version_info >= (1, 8, 0):
2741
# Add Sphinx message catalog for newer versions of Sphinx
2842
# See http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_message_catalog
2943
rtd_locale_path = path.join(path.abspath(path.dirname(__file__)), 'locale')
30-
app.add_message_catalog('sphinx', rtd_locale_path)
44+
app.add_message_catalog(MESSAGE_CATALOG_NAME, rtd_locale_path)

0 commit comments

Comments
 (0)