1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
# -*- coding: utf-8 -*-
import sys
import os
import re
# If we are building locally, or the build on Read the Docs looks like a PR
# build, prefer to use the version of the theme in this repo, not the installed
# version of the theme.
def is_development_build():
# PR builds have an interger version
re_version = re.compile(r'^[\d]+$')
if 'READTHEDOCS' in os.environ:
version = os.environ.get('READTHEDOCS_VERSION', '')
if re_version.match(version):
return True
return False
return True
if is_development_build():
sys.path.insert(0, os.path.abspath('..'))
sys.path.append(os.path.abspath('./demo/'))
import sphinx_rtd_theme
from sphinx.locale import _
project = u'Read the Docs Sphinx Theme'
slug = re.sub(r'\W+', '-', project.lower())
version = '0.5.1'
release = '0.5.1'
author = u'Dave Snider, Read the Docs, Inc. & contributors'
copyright = author
language = 'en'
extensions = [
'sphinx.ext.intersphinx',
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinxcontrib.httpdomain',
'sphinx_rtd_theme',
]
templates_path = ['_templates']
source_suffix = '.rst'
exclude_patterns = []
locale_dirs = ['locale/']
gettext_compact = False
master_doc = 'index'
suppress_warnings = ['image.nonlocal_uri']
pygments_style = 'default'
intersphinx_mapping = {
'rtd': ('https://docs.readthedocs.io/en/latest/', None),
'sphinx': ('http://www.sphinx-doc.org/en/stable/', None),
}
html_theme = 'sphinx_rtd_theme'
html_theme_options = {
'logo_only': True,
'navigation_depth': 5,
}
html_context = {}
if not 'READTHEDOCS' in os.environ:
html_static_path = ['_static/']
html_js_files = ['debug.js']
# Add fake versions for local QA of the menu
html_context['test_versions'] = list(map(
lambda x: str(x / 10),
range(1, 100)
))
html_logo = "demo/static/logo-wordmark-light.svg"
html_show_sourcelink = True
htmlhelp_basename = slug
latex_documents = [
('index', '{0}.tex'.format(slug), project, author, 'manual'),
]
man_pages = [
('index', slug, project, [author], 1)
]
texinfo_documents = [
('index', slug, project, author, slug, project, 'Miscellaneous'),
]
# Extensions to theme docs
def setup(app):
from sphinx.domains.python import PyField
from sphinx.util.docfields import Field
app.add_object_type(
'confval',
'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value',
doc_field_types=[
PyField(
'type',
label=_('Type'),
has_arg=False,
names=('type',),
bodyrolename='class'
),
Field(
'default',
label=_('Default'),
has_arg=False,
names=('default',),
),
]
)
|