Skip to content

Commit

Permalink
add option to use sphinx readthedocs theme locally
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeeren authored and ionelmc committed Jun 9, 2015
1 parent 8be9a32 commit 17ca2dc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ v1.5 (??????????)
* Made support and badges for landscape, scrutinizer, coveralls and codecov switchable at project creation time.
* Disabled all the pypip.in badges (server has way too much downtime).
* A fix for a whitespace issue in outputed ``tox.ini``.
* Add option to use Read The Docs theme when building docs locally.

v1.4 (2015-06-05)
-----------------
Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ You will be asked for these fields:
"no"
- Add a Scrutinizer_ badge in ``README.rst``.

* - ``rtd_theme``
- .. code:: python

"no"
- Whether to use the Read The Docs theme when building docs locally.

The testing (``tox.ini`` and ``.travis.yml``) configuration is generated from templates. For your convenience there's an
initial bootstrap ``tox.ini``, to get the initial generation going just run::
Expand Down
3 changes: 3 additions & 0 deletions ci/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ command_line_interface =
click &project_name[-] &full_name[-]
plain &project_name[-] &full_name[-]
no
rtd_theme =
yes
no
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
"codecov": "yes",
"landscape": "no",
"scrutinizer": "no"
"rtd_theme": "no"
}
16 changes: 13 additions & 3 deletions {{cookiecutter.repo_name}}/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,22 @@
copyright = '{0}, {1}'.format(year, author)
version = release = {{ '{0!r}'.format(cookiecutter.version) }}

{%- if cookiecutter.rtd_theme|lower == 'no' %}
import sphinx_py3doc_enhanced_theme
html_theme = "sphinx_py3doc_enhanced_theme"
html_theme_path = [sphinx_py3doc_enhanced_theme.get_html_theme_path()]
html_theme_options = {
'githuburl': 'https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/'
}
{%- else %}
# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
{%- endif %}

pygments_style = 'trac'
templates_path = ['.']
Expand All @@ -39,6 +52,3 @@
'**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
}
html_short_title = '%s-%s' % (project, version)
html_theme_options = {
'githuburl': 'https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}/'
}
4 changes: 4 additions & 0 deletions {{cookiecutter.repo_name}}/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
sphinx
sphinxcontrib-napoleon
{%- if cookiecutter.rtd_theme|lower == 'no' %}
sphinx-py3doc-enhanced-theme
{%- else %}
sphinx_rtd_theme
{%- endif %}
-e .

0 comments on commit 17ca2dc

Please sign in to comment.