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

'Edit on Github' should link to the page, not the project #269

Closed
weitzman opened this issue Dec 3, 2014 · 24 comments
Closed

'Edit on Github' should link to the page, not the project #269

weitzman opened this issue Dec 3, 2014 · 24 comments
Milestone

Comments

@weitzman
Copy link

weitzman commented Dec 3, 2014

IMO, the Github link should be smartened so that its text is 'Edit on Github' and the hyperlink points to the current page. For example, see the link in upper right of http://read-the-docs.readthedocs.org/en/latest/builds.html

PIP docs do this well

@weitzman weitzman changed the title Readthedocs theme does not show Github link when repo_url is provided 'Edit on Github' should link to the page, not the project Dec 8, 2014
@tomchristie
Copy link
Member

Yup that'd be much better.

@jimporter
Copy link
Contributor

Is this just for the Readthedocs theme? At least for me (using one of the Bootstrap themes), I'd find it strange for "Edit on GitHub" to get higher billing than a link to the project's main page on GitHub. As a user, I think I'd be a lot more likely to want to go to GitHub to download a tarball than I would be to edit the docs.

@d0ugal
Copy link
Member

d0ugal commented Jan 12, 2015

@jimporter Yup, that's correct, it is only in the read the docs theme at the moment.

@jails
Copy link

jails commented Feb 2, 2015

👍, yeah otherwise people click on the edit button and just bail out because there's nothing to edit. Finding the correct .md in a repository is just a pain in the ass when you are a newcomer. It will greatly help people to get involved into documentation maintenance.

@laserb
Copy link

laserb commented Feb 19, 2015

I got this working by changing the following line in the breadcrumbs.html from
<a href="{{ repo_url }}" class="icon icon-github"> Edit on GitHub</a>
to

<a href="{{ repo_url }}{{ current_page.abs_url.rstrip('index.html').rstrip('/') }}.md" class="icon icon-github"> Edit on GitHub</a>

@d0ugal
Copy link
Member

d0ugal commented Feb 19, 2015

Neat, I didn't expect it to be this easy - we should mabe come up with a nicer method tho and add a property to the current_page and remove the stripping.

@jails
Copy link

jails commented Feb 22, 2015

👍 would be great to have this in !

@d0ugal d0ugal added this to the 1.0.0 milestone Mar 7, 2015
@d0ugal d0ugal added the Easy label Apr 3, 2015
@d0ugal d0ugal modified the milestones: 0.12.0, 1.0.0 Apr 3, 2015
@d0ugal
Copy link
Member

d0ugal commented Apr 4, 2015

@laserb Did you change your repo_url to point to the docs directory? That's the only way I can get this to work and that seems a little odd. Otherwise I have to do something like:

<a href="{{ repo_url }}blob/master/docs/{{ current_page.input_path }}" class="icon icon-github"> Edit on GitHub</a>

@d0ugal
Copy link
Member

d0ugal commented Apr 4, 2015

Incidently, @laserb you can replace {{ current_page.abs_url.rstrip('index.html').rstrip('/') }}.md with {{ current_page.input_path }} :)

@d0ugal d0ugal removed this from the 0.12.0 milestone Apr 4, 2015
@Mopster
Copy link

Mopster commented Apr 6, 2015

In my opinion the 'Github' link on the bottom left (in the readthedocs template) should link to the repository and the 'Edit on Github' should link to the page itself to edit. But that might be just in my case, since we committed the docs inside a '/docs/content' folder in the repository (so it's available together with the software).

Maybe a second variable in the configuration to specify the path of the docs inside the repository might be a good addition, empty by default, but gets added to the repo path when configured.

Something like :

<a href="{{ repo_url }}{{ repo_doc_path }}/{{ current_page.input_path }}" class="icon icon-github"> Edit on GitHub</a>

@laserb
Copy link

laserb commented Apr 7, 2015

@d0ugal Thank you for the simplification. I was looking for something like that, but couldn't find it.
Yes, I did changed the repo_url, to point to the correct repo and to the edit page directly.

As the button text is "Edit on Github" I would expect it pointing to the edit page. Otherwise the button should be called "View on Github"

@Mopster I agree, an additional variable would help.

@paulproteus
Copy link

@d0ugal is this something where you want a patch to make this move forward? Or is this something you're planning on handling soon?

Much gratitude,

Asheesh.

@d0ugal
Copy link
Member

d0ugal commented Jul 17, 2015

@paulproteus Yeah, essentially, if somebody can come up with a patch to make this work well generally that would be ideal. It is something I had planned to do soonish, but no promises. I have been super busy, I hope to find time for MkDocs again very shortly after a deadline is out of the way.

@dmehra
Copy link

dmehra commented Nov 17, 2015

I discovered the same need to have true-editing "Edit on GitHub" links, and have a patch in the works, but not sure how to handle the BitBucket case. I'm unable to figure out how to generate a direct link to a given file for BitBucket, as they appear to stick a guid in the middle (for viewing as well as for editing). Looks like BitBucket would have to stay with a link that takes you to the repository root.

Given that, would it be better to have unequal treatment (github's link is a direct edit, while bitbucket's is a top-of-repo view), or provide "view" options for both, and additionally "edit" just for github? It would mean an extra config parameter, something like "repo_link: view|edit".

Another option is to keep the "Edit on ..." link name, and just have github take you to the file, but not in edit mode (the user can then click the edit pen); while bitbucket would continue going to the repo root. This is simplest / least change, and still useful to me.

@paulproteus
Copy link

paulproteus commented Nov 25, 2015 via email

@d0ugal
Copy link
Member

d0ugal commented Nov 26, 2015

I discovered the same need to have true-editing "Edit on GitHub" links, and have a patch in the works, but not sure how to handle the BitBucket case. I'm unable to figure out how to generate a direct link to a given file for BitBucket, as they appear to stick a guid in the middle (for viewing as well as for editing). Looks like BitBucket would have to stay with a link that takes you to the repository root.

It looks like the GUID is actually the latest sha, so just changing that to the branch name (or any other valid reference) will work. This is an hg repo for example:

https://bitbucket.org/regebro/pyroma/src/e05297042b1bdb15ca5938079da7c501185dee78/LICENSE.txt

https://bitbucket.org/regebro/pyroma/src/default/LICENSE.txt

So, it looks like the repo_branch setting you are proposing can be used to make this work. The only downside is that the master default is very git centric, but MkDocs already is somewhat git biased, so I am fine with that.

@dmehra
Copy link

dmehra commented Nov 30, 2015

Not having a BitBucket repo to play with, I can't validate that it will work in all cases, is the "default" branch guaranteed to be there (like "master" is for git)? Is there a bitbucket user around who could weigh in?

@d0ugal d0ugal removed the Easy label Jan 31, 2016
@d0ugal
Copy link
Member

d0ugal commented Feb 23, 2016

Okay, so to formalise this. This is the way forward for this issue described here and in the related comments: #752 (comment)

@JayHoltslander
Copy link

On Thursday, February 25, 2016 at 8:36:35 PM UTC-5, Jay wrote:

I'd like to have a link "Edit this page" on every page in my MkDocs project that takes users to the Git repo and brings up the editor on the specific file they were wanting to edit.
Once finished they could click "Commit" to save the changes to that page. (Which obviously would necessitate a redeployment of the site.)

Ideally this would work with GitLab and not just GitHub.

Any ideas on how I can make this happen?

@waylan replied:

This is currently being worked on as per issue #269 (#269). However, as you may note, no one has made any mention of GitLab there (we have GitHub and BitBucket in the works so far). If you add the relevant info in a comment for creating links to GitLab, perhaps support will be added in when the feature is finalized.

However, I should note that the "edit this page" links don't go to the "editor," they simply go to the page and the user still needs to click the "edit" button. Personally, I can see the case for either behavior. I would suggest bringing up the issue in the discussion on GitHub so it is not lost/forgotten.

I would like to see support for this edit function that works with GitLab as well as GitHub and BitBucket.

@viktorbenei
Copy link

Hi,

Is there any progress on this feature? I read through the whole discussion, with the related PR (#752) and links, and it seems the feature was planned for a 0.15.x release, but then was left out from all the existing releases (so far).

Just wanted to ask if this feature is still considered to be in an upcoming 0.15.x release, and if we can help with anything as we would love to use this feature in our docs.

Thanks!

@waylan waylan added this to the 0.16 milestone Jun 11, 2016
@waylan
Copy link
Member

waylan commented Jun 11, 2016

@viktorbenei the PR was rejected in favor of the approach described in this comment. However, no one has actually done the work to implement that. Until someone does, its not going to be added. Truth be told, I forgot about it, so I just added it to the 0.16 milestone which should ensure its not forgotten again.

@viktorbenei
Copy link

all right, thank you @waylan , I'll try to make some time to send a PR :)

lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
lorengordon added a commit to lorengordon/mkdocs that referenced this issue Jun 27, 2016
This patch adds support for a configuration option `edit_uri` that
is used to generate a link directly to an individual page in the
source repository.

Fixes mkdocs#269
@d0ugal
Copy link
Member

d0ugal commented Jun 28, 2016

Hrm, one oddity I just noticed with this. The default MkDocs theme now links to the edit page with the "GitHub" link on the top right. I find that really unexpected - I think we should just update the theme to link to the repo address.

It would be nice to add an "edit on github" link to this theme, but I can't think of a good place to put it.

re-opening this issue so I don't forget.

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

No branches or pull requests