doxysphinx icon indicating copy to clipboard operation
doxysphinx copied to clipboard

Support "Edit on Github" with doxysphinx

Open mb-emag opened this issue 3 years ago • 1 comments

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 + "/",
}

mb-emag avatar May 20 '22 07:05 mb-emag

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.

twodrops avatar Sep 12 '22 10:09 twodrops