ex_doc
ex_doc copied to clipboard
Add "Edit Documentation" link
Extracted from https://github.com/elixir-lang/ex_doc/pull/1818#issuecomment-1822395188.
I think we have all the ingredients:
-
GitHub code edit links may contain line numbers, notice the editor cursor is at line 3: https://github.com/elixir-lang/ex_doc/edit/main/lib/ex_doc/markdown.ex#L3
-
Remix has a suitable icon: https://remixicon.com/icon/edit-line
Here is a mockup:
WDYT?
Oh, the link is a bit problematic. It seems it has to point to a branch and not a tag. This link https://github.com/elixir-lang/ex_doc/edit/v0.30.9/lib/ex_doc/markdown.ex#L3 404s.
There are thus two problems:
- We need to add a configuration for a branch, we shouldn't just hardcode
"main". - The edit link will get out of sync as the branch moves forward.
Nice!
We have used main/master in https://erlang.org/doc for the target and so far I have not received any complaints. Whenever anyone edits the docs, they really should be editing the latest as things may already have been fixed.
You could also add a "View Documentation Source" in addition to "View Source" and get rid of that problem.
What would happen for non-GitHub hosted projects (I don't have any personally, but it would be worthwhile to consider how this might be configured both for enablement (some people may not want those links on their documentation) and target.
Any update on this? I often want to jump to the GitHub page of a project and currently I have to open a new tab and search for the project on Google and then get to the GitHub page. Having a direct edit link would be such a nice convenience and would do wonders in improving my workflow.
@yasoob the feature is already there for the source code. All you need to do is to click on the source icon and then the edit icon already on GitHub. It should take two clicks.
That said, I believe we can close this one. With Erlang moving to -doc attributes, docs and source are also collocated there, which reduces the need for a new link.
In Erlang the docs are however not always colocated with the code, but can be referred via -doc {file, …}. So from our perspective a view/edit doc button would be a nice addition.
This has not seen any activity and it seems the usage of -doc {file, ...} is quite rare. We can reopen it if someone really needs it.