Skip to content

Commit 04520a0

Browse files
jpseniorBlendify
authored andcommitted
#463 - Add github, gitlab, bitbucket page arguments option (#464)
This currently defaults to current behavior but can be changed with `vcs_pageview_mode`
1 parent 7b57c07 commit 04520a0

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

docs/configuring.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ You can configure different parts of the theme.
88
Project-wide Configuration
99
==========================
1010

11+
HTML Theme Options
12+
------------------
13+
1114
The theme's project-wide options are defined in the ``sphinx_rtd_theme/theme.conf``
1215
file of this repository, and can be defined in your project's ``conf.py`` via
1316
``html_theme_options``. For example:
@@ -21,6 +24,7 @@ file of this repository, and can be defined in your project's ``conf.py`` via
2124
'display_version': True,
2225
'prev_next_buttons_location': bottom,
2326
'style_external_links': False,
27+
'vcs_pageview_mode': '',
2428
# Toc options
2529
'collapse_navigation': False,
2630
'sticky_navigation': True,
@@ -32,7 +36,7 @@ file of this repository, and can be defined in your project's ``conf.py`` via
3236
The following options are available:
3337

3438
Base options
35-
------------
39+
~~~~~~~~~~~~
3640

3741
* ``canonical_url`` String. This will specify a `canonical url <https://en.wikipedia.org/wiki/Canonical_link_element>`__
3842
to let search engines know they should give higher ranking to latest version of the docs.
@@ -42,9 +46,12 @@ Base options
4246
* ``prev_next_buttons_location`` String. can take the value ``bottom``, ``top``, ``both`` , or ``None``
4347
and will display the "Next" and "Previous" buttons accordingly.
4448
* ``style_external_links`` Bool. Add an icon next to external links. Defaults to ``False``.
49+
* ``vcs_pageview_mode`` String. Changes how to view files when using `display_github`, `display_gitlab`, etc.
50+
When using Github or Gitlab this can be: `blob` (default), `edit`, or `raw`,
51+
on Bitbucket, this can be either: `view` (default) or `edit`.
4552

4653
TOC Options
47-
-----------
54+
~~~~~~~~~~~
4855

4956
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
5057

@@ -55,6 +62,12 @@ These effect how we display the Table of Contents in the side bar. You can read
5562
* ``includehidden`` Bool. Specifies if the sidebar includes toctrees marked with the ``:hidden:`` option
5663
* ``titles_only`` Bool. If True, removes headers within a page from the sidebar.
5764

65+
HTML Context Options
66+
--------------------
67+
68+
TODO.
69+
70+
5871
Page-level Configuration
5972
========================
6073

sphinx_rtd_theme/breadcrumbs.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@
4242
<!-- User defined GitHub URL -->
4343
<a href="{{ meta['github_url'] }}" class="fa fa-github"> {{ _('Edit on GitHub') }}</a>
4444
{% else %}
45-
<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>
45+
<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>
4646
{% endif %}
4747
{% elif display_bitbucket %}
4848
{% if check_meta and 'bitbucket_url' in meta %}
4949
<!-- User defined Bitbucket URL -->
5050
<a href="{{ meta['bitbucket_url'] }}" class="fa fa-bitbucket"> {{ _('Edit on Bitbucket') }}</a>
5151
{% else %}
52-
<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>
52+
<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>
5353
{% endif %}
5454
{% elif display_gitlab %}
5555
{% if check_meta and 'gitlab_url' in meta %}
5656
<!-- User defined GitLab URL -->
5757
<a href="{{ meta['gitlab_url'] }}" class="fa fa-gitlab"> {{ _('Edit on GitLab') }}</a>
5858
{% else %}
59-
<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>
59+
<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>
6060
{% endif %}
6161
{% elif show_source and source_url_prefix %}
6262
<a href="{{ source_url_prefix }}{{ pagename }}{{ suffix }}">{{ _('View page source') }}</a>

sphinx_rtd_theme/theme.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ logo_only =
1515
display_version = True
1616
prev_next_buttons_location = bottom
1717
style_external_links = False
18+
vcs_pageview_mode =

0 commit comments

Comments
 (0)