Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use sphinx readthedocs theme locally #20

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"coveralls": "no",
"codecov": "yes",
"landscape": "no",
"scrutinizer": "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 .