Belle II Software  release-08-01-10
__init__.py
1 """
2 Sphinx Read the Docs theme.
3 
4 From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
5 """
6 
7 from os import path
8 from sys import version_info as python_version
9 
10 from sphinx import version_info as sphinx_version
11 from sphinx.locale import _
12 from sphinx.util.logging import getLogger
13 
14 
15 __version__ = '1.0.0alpha1'
16 __version_full__ = __version__
17 
18 logger = getLogger(__name__)
19 
20 
22  """Return list of HTML theme paths."""
23  cur_dir = path.abspath(path.dirname(path.dirname(__file__)))
24  return cur_dir
25 
26 
27 def config_initiated(app, config):
28  theme_options = config.html_theme_options or {}
29  if theme_options.get('canonical_url'):
30  logger.warning(
31  _('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.')
32  )
33 
34 # See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
35 
36 
37 def setup(app):
38  if python_version[0] < 3:
39  logger.warning("Python 2 is deprecated with sphinx_rtd_theme, update to Python 3")
40  app.require_sphinx('1.6')
41  if sphinx_version <= (2, 0, 0):
42  logger.warning("Sphinx 1.x is deprecated with sphinx_rtd_theme, update to Sphinx 2.x or greater")
43  if not app.config.html_experimental_html5_writer:
44  logger.warning("'html4_writer' is deprecated with sphinx_rtd_theme")
45  else:
46  if app.config.html4_writer:
47  logger.warning("'html4_writer' is deprecated with sphinx_rtd_theme")
48 
49  # Register the theme that can be referenced without adding a theme path
50  app.add_html_theme('sphinx_rtd_theme', path.abspath(path.dirname(__file__)))
51 
52  if sphinx_version >= (1, 8, 0):
53  # Add Sphinx message catalog for newer versions of Sphinx
54  # See http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_message_catalog
55  rtd_locale_path = path.join(path.abspath(path.dirname(__file__)), 'locale')
56  app.add_message_catalog('sphinx', rtd_locale_path)
57  app.connect('config-inited', config_initiated)
58 
59  # sphinx emits the permalink icon for headers, so choose one more in keeping with our theme
60  if sphinx_version >= (3, 5, 0):
61  app.config.html_permalinks_icon = "\uf0c1"
62  else:
63  app.config.html_add_permalinks = "\uf0c1"
64 
65  return {'parallel_read_safe': True, 'parallel_write_safe': True}
def get_html_theme_path()
Definition: __init__.py:21