doxysphinx
doxysphinx copied to clipboard
Support "Edit on Github" with doxysphinx
RTD Theme supports, "Edit on GitHub" which helps navigate to sources in GitHub. It would be nice if doxysphinx generated HTMLs could navigate to its corresponding hpp/cpp.
Example conf.py
# Get current branch for "Edit on GitHub"
git_cmd = ["git", "branch", "--show-current"]
try:
import subprocess
git_branch = subprocess.check_output(git_cmd).decode("utf-8")
display_github = True # Show "Edit on GitHub"
except FileNotFoundError:
display_github = False # Show "View page source"
git_branch = ""
warnings.warn("Cannot get current git branch. Not setting 'git_branch' for 'Edit on GitHub'.")
html_context = {
# Enable the "Edit in GitHub link within the header of each page.
"display_github": display_github,
# Variables to generate the resulting github URL for each page.
# Format Template:
# https://{{ github_host|default("github.com") }}/
# {{ github_user }}/{{ github_repo }}/blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}
"github_user": "USER",
"github_repo": "REPO",
"github_version": git_branch + "/",
}
The first step would be to avoid providing an edit button on such generated pages. Immaterial Theme, for example, supports adding this directly to generated pages. https://jbms.github.io/sphinx-immaterial/customization.html#themeconf-hide-edit-link
This could be different for different themes, so might be tough to handle from Doysphinx in a generic way.