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

Possible to set "Edit on GitHub" link targets manually? #314

Closed
KarlTDebiec opened this issue Aug 13, 2016 · 5 comments
Closed

Possible to set "Edit on GitHub" link targets manually? #314

KarlTDebiec opened this issue Aug 13, 2016 · 5 comments

Comments

@KarlTDebiec
Copy link

Hi all,

I'm using this theme to generate documentation for my project, and have run into a small issue with the "Edit on GitHub" links. I've been able to get the "Edit on GitHub" links to appear in the documentation, and link to the corresponding rst source for each page. However, I am using autodoc extensively, and the rst files themselves aren't particularly useful. It would be preferable for the "Edit on GitHub" links on each page to simply target the root of my repository. It looks like this is intended to be possible by setting github_url in the metadata for each page, by adding:

.. meta::
    :github_url: github.com/KarlTDebiec/MolDynPlot

To the header of each rst source file. I see that this metadata does make it into the header of the html file, but the "Edit on Github" links still point to the rst files. Is there some other setting that is necessary in order to set the link targets manually?

Thanks,
Karl Debiec

@vpoughon
Copy link

I'm seeing the same issue with my project which isn't hosted on github. The top link says "View page source" and doesn't link to the specified url (which points to our github mirror). The metadata also makes it to the html header in my case.

@anarcat
Copy link

anarcat commented Sep 5, 2016

i have the same problem here. i have looked and looked, and it seems possible to set arbitrary locations for that "View page source" link, according to pull request #182 anyways. however, i can't for the life of me figure out where source_url_prefix is set.

According to #205, display_github, a similar parameter in breadcrumbs.html, is set in html_context. unfortunately, setting source_url_prefix there has no effect whatsoever. Even worse: there's no parameter for the version like there is in github...

it seems it would be possible to abuse the display_github settings to point to completely arbitrary hosts. it would still say "on github", but at least the link would be correct. unfortunately, this doesn't work either. this is what I have tried:

html_context = {
    'source_url_prefix': "https://gitlab.com/anarcat/foo/blob/HEAD/doc/",
    "display_github": True,
    "github_host": "gitlab.com",
    "github_user": "anarcat",
    "github_repo": 'foo',
    "github_version": "HEAD",
    "conf_py_path": "/doc/",
    "source_suffix": '.rst',
}

it would be nice to not be treated like a second-class citizen here, just because our stuff isn't hosted on Github... :)

@anarcat
Copy link

anarcat commented Sep 5, 2016

ugh... so the problem was that i was running an old version of sphinx-rtd.. the fix was of course to upgrade. I was running version 1.6, and 1.9 fixed the problem for me. the only config that was required was, in the end:

html_context = {
    'source_url_prefix': "https://gitlab.com/anarcat/foo/blob/HEAD/doc/",
}
# this is the default....
# html_show_sourcelink = True

@thiyagaraj
Copy link

@anarcat thank you!! I was trying to accomplish this by overriding the template/block and then injecting custom variables... but this was such an easy fix!

@Blendify
Copy link
Member

Blendify commented Mar 3, 2017

Someone please close.

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

No branches or pull requests

6 participants