|
| 1 | +Version Control System Integration |
| 2 | +================================== |
| 3 | + |
| 4 | +If you want to integrate editing into your own theme, you will have to declare |
| 5 | +few variables inside your configuration file ``conf.py`` in the ``'html_context'`` |
| 6 | +setting, for the template to use them. |
| 7 | + |
| 8 | +More information can be found on `Sphinx documentation`_. |
| 9 | + |
| 10 | +.. _`Sphinx documentation`: http://www.sphinx-doc.org/en/1.5.2/config.html#confval-html_context |
| 11 | + |
| 12 | +GitHub |
| 13 | +------ |
| 14 | + |
| 15 | +If you want to integrate GitHub, you can put the following snippet into |
| 16 | +your ``conf.py``:: |
| 17 | + |
| 18 | + html_context = { |
| 19 | + "display_github": True, # Integrate GitHub |
| 20 | + "github_user": "MyUserName", # Username |
| 21 | + "github_repo": "MyDoc", # Repo name |
| 22 | + "github_version": "master", # Version |
| 23 | + "conf_py_path": "/source/", # Path in the checkout to the docs root |
| 24 | + } |
| 25 | + |
| 26 | +It can be used like this:: |
| 27 | + |
| 28 | + {% if display_github %} |
| 29 | + <li><a href="https://github.com/{{ github_user }}/{{ github_repo }} |
| 30 | + /blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}.rst"> |
| 31 | + Show on GitHub</a></li> |
| 32 | + {% endif %} |
| 33 | + |
| 34 | +Bitbucket |
| 35 | +--------- |
| 36 | + |
| 37 | +If you want to integrate Bitbucket, you can put the following snippet into |
| 38 | +your ``conf.py``:: |
| 39 | + |
| 40 | + html_context = { |
| 41 | + "display_bitbucket": True, # Integrate Bitbucket |
| 42 | + "bitbucket_user": "MyUserName", # Username |
| 43 | + "bitbucket_repo": "MyDoc", # Repo name |
| 44 | + "bitbucket_version": "master", # Version |
| 45 | + "conf_py_path": "/source/", # Path in the checkout to the docs root |
| 46 | + } |
| 47 | + |
| 48 | +It can be used like this:: |
| 49 | + |
| 50 | + {% if display_bitbucket %} |
| 51 | + <a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }} |
| 52 | + /src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}.rst'" |
| 53 | + class="icon icon-bitbucket"> Edit on Bitbucket</a> |
| 54 | + {% endif %} |
| 55 | + |
| 56 | +Gitlab |
| 57 | +------ |
| 58 | + |
| 59 | +If you want to integrate Gitlab, you can put the following snippet into |
| 60 | +your ``conf.py``:: |
| 61 | + |
| 62 | + html_context = { |
| 63 | + "display_gitlab": True, # Integrate Gitlab |
| 64 | + "gitlab_user": "MyUserName", # Username |
| 65 | + "gitlab_repo": "MyDoc", # Repo name |
| 66 | + "gitlab_version": "master", # Version |
| 67 | + "conf_py_path": "/source/", # Path in the checkout to the docs root |
| 68 | + } |
| 69 | + |
| 70 | +It can be used like this:: |
| 71 | + |
| 72 | + {% if display_gitlab %} |
| 73 | + <a href="https://{{ gitlab_host|default("gitlab.com") }}/ |
| 74 | + {{ gitlab_user }}/{{ gitlab_repo }}/blob/{{ gitlab_version }} |
| 75 | + {{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-gitlab"> |
| 76 | + Edit on GitLab</a> |
| 77 | + {% endif %} |
| 78 | + |
| 79 | +Additional variables |
| 80 | +-------------------- |
| 81 | + |
| 82 | +* ``'pagename'`` - Sphinx variable representing the name of the page you're on. |
0 commit comments