-
Notifications
You must be signed in to change notification settings - Fork 1.6k
rustdoc edit links #2985
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
base: master
Are you sure you want to change the base?
rustdoc edit links #2985
Conversation
Assuming this is intended for docs.rs to implement, how would it construct the URL? Is that something that would go in |
The
It would be great enhancement to be able to specify branch and package_path, but in general this is just a best-effort approach that usually works. There is nothing we can do about renamed files, and it would be costly to try to poll the git diff for actively updating line number offsets, however I suppose it won't hurt to add a link that mostly works and usually lands near the right line. |
I agree that UI design is important especially for mobile devices. I think it'd be better not to put an "edit" button beside the "src" button. First, I think editing the documentation itself is more developer-oriented and is not something for every library users. So it can afford to be placed deeper in UI. More importantly, I believe the editors must have at least looked at the source for the documentation, and probably at the source code itself, then they can make a rightful judgement on whether some documentation indeed needs modifications. |
Yeah, reserving the edit button for when you're already looking at the source itself is much better. |
What if the user is just trying to fix a typo or paraphrase the documentation to make it simpler? |
Rustdoc already generates very busy pages that are full of too much cruft. The common case is reading, so we should have the default view be oriented accordingly. |
@SOF3 if someone is willing to spend time on making a PR to fix a typo, I believe he/she won't mind making an additional click. |
I was thinking like a ✏️ icon that appears when the user hovers over the |
@SOF3 how do you hover on touch screen? |
Press down your finger on the element, then drag it a bit to any direction so that it doesn't register as a click. |
that won't work on ios |
Related to rust-lang/rust#74758 - could there be two different views of the page? One that's intended for viewing and one for editing? Then the editing one would show much less detail, but would also have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the idea, but this RFC proposes a goal, not a way how to get there. Consider posting this as a pre-rfc on https://internals.rust-lang.org/ to get more ideas on the design - as-is, this isn't really actionable for the rustdoc team.
``` | ||
--edit-link-format "https://github.com/rust-lang/rust/edit/master/libstd/{file}#L{start_line}-L{end_line}" | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing a reference-level explanation. Consider addressing what the UI would look like for this.
[drawbacks]: #drawbacks | ||
|
||
This increases complexity of the documentation page, especially with mobile devices. | ||
Good UX design is required to prevent bloating the content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should really be part of the RFC, not deferred until later. Certainly no one on the rustdoc team has the bandwidth to design it.
|
||
Pros: | ||
|
||
- *May* support previous crate builds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to expand on why this is 'May'. The difficulty I forsee is changes in HTML page structure, but since the links always say '[src]' that could be mitigated somewhat. It highly depends where the buttons end up going, which is one more reason I think the design should be part of the RFC.
# Alternatives | ||
[alternatives]: #alternatives | ||
|
||
It is also possible to perform this with JavaScript on behalf of docs.rs only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't have to be with JavaScript, docs.rs already rewrites pages on the backend: https://github.com/rust-lang/docs.rs/blob/master/src/utils/html.rs
I don't like this approach, it breaks for gitlab. What docs.rs could do instead is have a list of supported git hosts (that's fairly easy to add to) and choose the file path based on that and the |
Co-authored-by: Joshua Nelson <[email protected]>
|
||
This increases complexity of the documentation page, especially with mobile devices. | ||
Good UX design is required to prevent bloating the content. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This RFC will only show the links on new docs.rs pages, not existing builds. Can you add that as a drawback?
Co-authored-by: Joshua Nelson <[email protected]>
Adds an edit button to rustdoc-generated pages
Related: rust-lang/docs.rs#1007
Rendered