#463 - Add github, gitlab, bitbucket page arguments option (#464)

This currently defaults to current behavior but can be changed with `vcs_pageview_mode`
This commit is contained in:
jpsenior 2018-01-31 19:46:14 -07:00 committed by Aaron Carlisle
parent 7b57c074a8
commit 04520a0476
3 changed files with 19 additions and 5 deletions

View File

@ -8,6 +8,9 @@ You can configure different parts of the theme.
Project-wide Configuration Project-wide Configuration
========================== ==========================
HTML Theme Options
------------------
The theme's project-wide options are defined in the ``sphinx_rtd_theme/theme.conf`` The theme's project-wide options are defined in the ``sphinx_rtd_theme/theme.conf``
file of this repository, and can be defined in your project's ``conf.py`` via file of this repository, and can be defined in your project's ``conf.py`` via
``html_theme_options``. For example: ``html_theme_options``. For example:
@ -21,6 +24,7 @@ file of this repository, and can be defined in your project's ``conf.py`` via
'display_version': True, 'display_version': True,
'prev_next_buttons_location': bottom, 'prev_next_buttons_location': bottom,
'style_external_links': False, 'style_external_links': False,
'vcs_pageview_mode': '',
# Toc options # Toc options
'collapse_navigation': False, 'collapse_navigation': False,
'sticky_navigation': True, 'sticky_navigation': True,
@ -32,7 +36,7 @@ file of this repository, and can be defined in your project's ``conf.py`` via
The following options are available: The following options are available:
Base options Base options
------------ ~~~~~~~~~~~~
* ``canonical_url`` String. This will specify a `canonical url <https://en.wikipedia.org/wiki/Canonical_link_element>`__ * ``canonical_url`` String. This will specify a `canonical url <https://en.wikipedia.org/wiki/Canonical_link_element>`__
to let search engines know they should give higher ranking to latest version of the docs. to let search engines know they should give higher ranking to latest version of the docs.
@ -42,9 +46,12 @@ Base options
* ``prev_next_buttons_location`` String. can take the value ``bottom``, ``top``, ``both`` , or ``None`` * ``prev_next_buttons_location`` String. can take the value ``bottom``, ``top``, ``both`` , or ``None``
and will display the "Next" and "Previous" buttons accordingly. and will display the "Next" and "Previous" buttons accordingly.
* ``style_external_links`` Bool. Add an icon next to external links. Defaults to ``False``. * ``style_external_links`` Bool. Add an icon next to external links. Defaults to ``False``.
* ``vcs_pageview_mode`` String. Changes how to view files when using `display_github`, `display_gitlab`, etc.
When using Github or Gitlab this can be: `blob` (default), `edit`, or `raw`,
on Bitbucket, this can be either: `view` (default) or `edit`.
TOC Options TOC Options
----------- ~~~~~~~~~~~
These effect how we display the Table of Contents in the side bar. You can read more about them here: http://www.sphinx-doc.org/en/stable/templating.html#toctree These effect how we display the Table of Contents in the side bar. You can read more about them here: http://www.sphinx-doc.org/en/stable/templating.html#toctree
@ -55,6 +62,12 @@ These effect how we display the Table of Contents in the side bar. You can read
* ``includehidden`` Bool. Specifies if the sidebar includes toctrees marked with the ``:hidden:`` option * ``includehidden`` Bool. Specifies if the sidebar includes toctrees marked with the ``:hidden:`` option
* ``titles_only`` Bool. If True, removes headers within a page from the sidebar. * ``titles_only`` Bool. If True, removes headers within a page from the sidebar.
HTML Context Options
--------------------
TODO.
Page-level Configuration Page-level Configuration
======================== ========================

View File

@ -42,21 +42,21 @@
<!-- User defined GitHub URL --> <!-- User defined GitHub URL -->
<a href="{{ meta['github_url'] }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a> <a href="{{ meta['github_url'] }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
{% else %} {% else %}
<a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a> <a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/{{ theme_vcs_pageview_mode|default("blob") }}/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
{% endif %} {% endif %}
{% elif display_bitbucket %} {% elif display_bitbucket %}
{% if check_meta and 'bitbucket_url' in meta %} {% if check_meta and 'bitbucket_url' in meta %}
<!-- User defined Bitbucket URL --> <!-- User defined Bitbucket URL -->
<a href="{{ meta['bitbucket_url'] }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a> <a href="{{ meta['bitbucket_url'] }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a>
{% else %} {% else %}
<a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }}/src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a> <a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }}/src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}{{ suffix }}?mode={{ theme_vcs_pageview_mode|default("view") }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a>
{% endif %} {% endif %}
{% elif display_gitlab %} {% elif display_gitlab %}
{% if check_meta and 'gitlab_url' in meta %} {% if check_meta and 'gitlab_url' in meta %}
<!-- User defined GitLab URL --> <!-- User defined GitLab URL -->
<a href="{{ meta['gitlab_url'] }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a> <a href="{{ meta['gitlab_url'] }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a>
{% else %} {% else %}
<a href="https://{{ gitlab_host|default("gitlab.com") }}/{{ gitlab_user }}/{{ gitlab_repo }}/blob/{{ gitlab_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a> <a href="https://{{ gitlab_host|default("gitlab.com") }}/{{ gitlab_user }}/{{ gitlab_repo }}/{{ theme_vcs_pageview_mode|default("blob") }}/{{ gitlab_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a>
{% endif %} {% endif %}
{% elif show_source and source_url_prefix %} {% elif show_source and source_url_prefix %}
<a href="{{ source_url_prefix }}{{ pagename }}{{ suffix }}">{{ _('View page source') }}</a> <a href="{{ source_url_prefix }}{{ pagename }}{{ suffix }}">{{ _('View page source') }}</a>

View File

@ -15,3 +15,4 @@ logo_only =
display_version = True display_version = True
prev_next_buttons_location = bottom prev_next_buttons_location = bottom
style_external_links = False style_external_links = False
vcs_pageview_mode =