-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improve edit_uri flexability #1378
Comments
What URL are you expecting to get? IIRC, Bitbucket doesn't have an "edit" URL for documents in your repo. We can only point to the document, then the user needs to click on the "edit" button which uses a script on Bitbucket's site to switch to edit mode (there is no change to the URL). In other words, this is a limit of Bitbucket which we have no control over. If, on the other hand, Bitbucket does offer an "edit" URL for documents, we would be happy to update MkDocs to support it. Please let us know what that URL scheme is and we'll add support. |
Closing this due to a lack of information to act on. |
@jkobti In my case I set @waylan If that helps, this is how an edit URL in Bitbucket would open directly the file from the source code editor: https://bitbucket.org/elvismdev/my-project/src/master/docs/index.md?mode=edit&spa=0 |
@elvismdev thank you for providing Bitbiucket's edit URL format. It would seem that MkDocs' current implementation is inadequate for general use. As it currently stands, an "edit URL" is composed by joining the following three parts:
However, Bitbucket would need:
And based on this recent report in #1437, a GitHub wiki would need:
Given the above, it seems that rather than having a setting for |
Note that since #1224 we have supported query string based formats used by some hosts. However, this works because, like GitHub, the page path comes after the What I'm proposing here would work in all cases with the various parts in any order. Users just need to be careful that to properly include or exclude slashes in the template. Under the hood it drastically simplifies things as we no longer need to worry about that. The problem is that the burden is now on the end user to do things correctly. There could also be an issue where a value included in a query string would need to be escaped differently that when part of the path. Not sure how to address that. Although we currently don't address it, so maybe its not necessary. |
See also some thoughts on a plugin for handling this. |
Hi, I spotted this with my documentation (http://spinicist.github.io/QUIT) because I had only the I have now specified So: Thanks for all the hard work, this is first problem I've had with |
For GitHub, the following seems to work: repo_url: https://github.com/<owner>/<repo>
edit_uri: https://github.com/<owner>/<repo>/edit/<branch>/<docs-root> e.g. repo_url: https://github.com/jacebrowning/datafiles
edit_uri: https://github.com/jacebrowning/datafiles/edit/develop/docs |
#2212 highlights that even '/' is not a given before filename |
For GitLab's Static Site Editor (from #2212), this would be something like:
Or optionally with a redirect back to the site in the query:
Both the path and This makes me think @waylan that at least your idea of I'd be interested in adding this, although for now I managed to get GitLab's SSE to work with a small jinja hack in the For reference gitlab's middleman example template https://gitlab.com/gitlab-org/project-templates/static-site-editor-middleman/-/blob/master/source/layouts/layout.erb#L16-18 and helper: https://gitlab.com/gitlab-org/project-templates/static-site-editor-middleman/-/blob/master/helpers/custom_helpers.rb#L3 |
If we go with an This should be easy for a plugin to address now. Each The one issue that a plugin may struggle with is providing an icon for the service. This was discussed here. We may need to provide a mechanism for the plugin to provide the icon and make it available for the theme. |
Thanks for the quick feedback @waylan. Based on your info I put together a quick thing here: https://gitlab.com/nejch1/mkdocs-gitlab-static-site-editor, which does the job for me (initial PR here if you have an account to comment). Does this makes sense? If so I might do some cleanup/polishing and publish this on pypi. Still unsure if it's overkill to have a plugin specifically for this, or if it should be a more generic plugin that can handle other use cases/platforms, but I can't think of any at the moment. Hmm I wasn't even thinking about icons (some don't use repo-specific ones for Edit, see https://github.com/squidfunk/mkdocs-material/blob/094819e1e41b7a54aa2b5ed2a413cdc22fd5afd9/material/base.html#L161). But I see now the plugin should probably at least set |
I have created a plugin now for GitHub Wiki that changes the link to the correct format... For those needing GitHub Wiki support, give it a try? |
For GitLab support too this would be useful. GitLab provides two ways to edit files:
GitLab defaults to 2) Web IDE but mkdocs doesn't provide a way to construct that kind of URL using the edit_uri field (only 1) works) |
I propose a new config These two are equivalent: edit_uri: blob/master/docs/
edit_uri_template: blob/master/docs/{path} Available expansions:
Let's collect some useful examples
Explanations
|
I like your proposal @oprypin, it does make sense to propose such a template variant What I don't quite get tho is your proposed expansions taxonomy:
|
Ah yes, |
Ok makes more sense now, that sounds great if correctly documented. Do you want to rebase #2927 ? I can try to add a commit to the PR branch to update the documentation if you like. |
btw, and the weird exclamation mark syntax is just because I reuse the implementation of Python's format strings. Other features of format strings are available, although also currently unnecessary |
Ah.. I have the branch rebased but I didn't push it. |
Saw that, elegant (should I say as always?) ;) |
Hi guys,
According to the documentation, I should be able to only add the link to my bitbucket repository to get edit links.
I added it like this: repo_url: https://bitbucket.org/josephkobti/testdocs/
but the links I'm getting are not working
i.e. https://bitbucket.org/josephkobti/testdocs/src/default/docs/index.md
I think maybe I should add the repo_url in another way, any suggestions?
The text was updated successfully, but these errors were encountered: