|
6 | 6 |
|
7 | 7 | from os import path |
8 | 8 |
|
9 | | -import sphinx |
| 9 | +from sphinx import version_info |
| 10 | +from sphinx.locale import _ |
| 11 | + |
| 12 | +try: |
| 13 | + # Avaliable from Sphinx 1.6 |
| 14 | + from sphinx.util.logging import getLogger |
| 15 | +except ImportError: |
| 16 | + from logging import getLogger |
10 | 17 |
|
11 | 18 |
|
12 | 19 | __version__ = '0.5.0' |
13 | 20 | __version_full__ = __version__ |
14 | 21 |
|
| 22 | +logger = getLogger(__name__) |
| 23 | + |
15 | 24 |
|
16 | 25 | def get_html_theme_path(): |
17 | 26 | """Return list of HTML theme paths.""" |
18 | 27 | cur_dir = path.abspath(path.dirname(path.dirname(__file__))) |
19 | 28 | return cur_dir |
20 | 29 |
|
21 | 30 |
|
| 31 | +def config_initiated(app, config): |
| 32 | + theme_options = config.html_theme_options or {} |
| 33 | + if theme_options.get('canonical_url'): |
| 34 | + logger.warning( |
| 35 | + _('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.') |
| 36 | + ) |
| 37 | + |
| 38 | + |
22 | 39 | # See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package |
23 | 40 | def setup(app): |
24 | | - if sphinx.version_info >= (1, 6, 0): |
| 41 | + if version_info >= (1, 6, 0): |
25 | 42 | # Register the theme that can be referenced without adding a theme path |
26 | 43 | app.add_html_theme('sphinx_rtd_theme', path.abspath(path.dirname(__file__))) |
27 | 44 |
|
28 | | - if sphinx.version_info >= (1, 8, 0): |
| 45 | + if version_info >= (1, 8, 0): |
29 | 46 | # Add Sphinx message catalog for newer versions of Sphinx |
30 | 47 | # See http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_message_catalog |
31 | 48 | rtd_locale_path = path.join(path.abspath(path.dirname(__file__)), 'locale') |
32 | 49 | app.add_message_catalog('sphinx', rtd_locale_path) |
| 50 | + app.connect('config-inited', config_initiated) |
33 | 51 |
|
34 | 52 | return {'parallel_read_safe': True, 'parallel_write_safe': True} |
0 commit comments