Skip to content

Commit 8cb9bf3

Browse files
committed
Merge pull request hydralabs#15 from thijstriemstra/readthedocs-853
Add readthedocs checks.
2 parents d222c61 + d1bbc31 commit 8cb9bf3

File tree

1 file changed

+34
-19
lines changed

1 file changed

+34
-19
lines changed

doc/conf.py

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@
1717

1818
from docutils.core import publish_parts
1919

20+
2021
# If extensions (or modules to document with autodoc) are in another directory,
2122
# add these directories to sys.path here. If the directory is relative to the
2223
# documentation root, use os.path.abspath to make it absolute.
2324
sys.path.insert(0, os.path.abspath('..'))
2425
sys.path.append(os.path.abspath('.'))
2526
sys.path.append(os.path.abspath('html'))
2627

28+
29+
# When ReaTheDocs.org builds your project, it sets the READTHEDOCS environment
30+
# variable to the string True.
31+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
32+
33+
2734
def rst2html(input, output):
2835
"""
2936
Create html file from rst file.
@@ -57,8 +64,9 @@ def rst2html(input, output):
5764
extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.extlinks',
5865
'sphinxcontrib.epydoc']
5966

60-
# Paths that contain additional templates, relative to this directory.
61-
templates_path = ['html']
67+
if on_rtd == False:
68+
# Paths that contain additional templates, relative to this directory.
69+
templates_path = ['html']
6270

6371
# The suffix of source filenames.
6472
source_suffix = '.rst'
@@ -74,8 +82,12 @@ def rst2html(input, output):
7482
project = 'PyAMF'
7583
url = 'http://pyamf.org'
7684
description = 'AMF for Python'
77-
copyright = "Copyright &#169; 2007-%s The <a href='%s'>%s</a> Project. All rights reserved." % (
78-
time.strftime('%Y'), url, project)
85+
86+
if on_rtd == False:
87+
copyright = "Copyright &#169; 2007-%s The <a href='%s'>%s</a> Project. All rights reserved." % (
88+
time.strftime('%Y'), url, project)
89+
else:
90+
copyright = "2007-%s The %s Project" % (time.strftime('%Y'), project)
7991

8092
# We look for the __init__.py file in the current PyAMF source tree
8193
# and replace the values accordingly.
@@ -122,20 +134,30 @@ def rst2html(input, output):
122134

123135
# The theme to use for HTML and HTML Help pages. See the documentation for
124136
# a list of builtin themes.
125-
#
126-
# Note: you can download the 'beam' theme from:
127-
# http://github.com/collab-project/sphinx-themes
128-
# and place it in a 'themes' directory relative to this config file.
129-
html_theme = 'beam'
137+
if on_rtd:
138+
# default theme for readthedocs.org
139+
html_theme = 'default'
140+
else:
141+
# Note: you can download the 'beam' theme from:
142+
# http://github.com/collab-project/sphinx-themes
143+
# and place it in a 'themes' directory relative to this config file.
144+
html_theme = 'beam'
145+
146+
# Custom themes here, relative to this directory.
147+
html_theme_path = ['themes']
148+
149+
# Additional templates that should be rendered to pages, maps page names to
150+
# template names.
151+
html_additional_pages = {
152+
'index': 'defindex.html',
153+
'tutorials/index': 'tutorials.html',
154+
}
130155

131156
# Theme options are theme-specific and customize the look and feel of a theme
132157
# further. For a list of options available for each theme, see the
133158
# documentation.
134159
#html_theme_options = {}
135160

136-
# Add any paths that contain custom themes here, relative to this directory.
137-
html_theme_path = ['themes']
138-
139161
# The name for this set of Sphinx documents. If None, it defaults to
140162
# "<project> v<release> documentation".
141163
html_title = '%s - %s' % (project, description)
@@ -156,13 +178,6 @@ def rst2html(input, output):
156178
# typographically correct entities.
157179
#html_use_smartypants = True
158180

159-
# Additional templates that should be rendered to pages, maps page names to
160-
# template names.
161-
html_additional_pages = {
162-
'index': 'defindex.html',
163-
'tutorials/index': 'tutorials.html',
164-
}
165-
166181
# If false, no module index is generated.
167182
html_use_modindex = True
168183

0 commit comments

Comments
 (0)