Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "Edit on Github" with doxysphinx #5

Open
mb-emag opened this issue May 20, 2022 · 1 comment
Open

Support "Edit on Github" with doxysphinx #5

mb-emag opened this issue May 20, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@mb-emag
Copy link
Contributor

mb-emag commented May 20, 2022

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 mb-emag added the enhancement New feature or request label May 20, 2022
@twodrops
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants