Buttons that link to source files#
There are a collection of buttons that you can use to link back to your source repository. This lets users browse the repository, or take actions like suggest an edit or open an issue.
Set your source repository#
You need to define a source repository for this functionality to work. This is the online space where your code / documentation is hosted. In each case, they require the following configuration to exist:
html_theme_options = {
...
"repository_url": "https://{your-provider}/{org}/{repo}",
...
}
Three providers are supported:
GitHub: For example,
https://github.com/executablebooks/sphinx-book-theme
. This includes custom URLs for self-hosted GitHub.GitLab: For example,
https://gitlab.com/gitlab-org/gitlab
. This includes custom URLs for self-hosted GitLab.BitBucket: For example,
https://opensource.ncsa.illinois.edu/bitbucket/scm/u3d/3dutilities
.
In each case, we assume the final two URL items are the org/repo
pair.
Manually specify the provider#
If your provider URL is more complex (e.g., if you’re self-hosting your provider), you can manually specify the provider with the following configuration:
html_theme_options = {
...
"repository_provider": "gitlab" # or "github", "bitbucket",
"repository_url": "selfhostedgh.mycompany.org/user/repo",
...
}
Once this is provided, you may add source buttons by following the following sections.
Add a link to your repository#
To add a link to your repository, add the following configuration:
html_theme_options = {
...
"use_repository_button": True,
...
}