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

Rustdoc should allow copying use statements into clipboard with 1 click #50239

Closed
Boscop opened this issue Apr 26, 2018 · 4 comments · Fixed by #83721
Closed

Rustdoc should allow copying use statements into clipboard with 1 click #50239

Boscop opened this issue Apr 26, 2018 · 4 comments · Fixed by #83721
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Boscop
Copy link

Boscop commented Apr 26, 2018

The intention of many (if not most) visits to any crate doc (e.g. on docs.rs but also std) is to find out the import paths, so that one can write the right use statement for the symbol.

So Rustdoc should allow copying use statements into the clipboard with 1 click.
There should be a copy icon next to the name of each type/trait/module, which will cause a use statement for this symbol to be copied to the user's clipboard ("use {};\n").
For easy pasting into the editor after lookup up the path of the symbol.
I always find myself manually selecting the path (carefully avoiding clicking its link but also not selecting any chars before and after, which is annoying*), then copying, pasting and writing use before and ;\n after it, for many symbols, which wouldn't be necessary with this feature.

The icon could be something from FontAwesome or similar (that's instantly recognizable as a "copy-to-clipboard" icon.)

*Also, why is the symbol even a link, always to its page which is the same page, when the user is already on that page? (We could just change (re-purpose) this link to copy the use-statement to the clipboard, but it won't be as obvious as with a copy icon.)

@hellow554
Copy link
Contributor

While I think this could be a very useful feature, I tried three different pages in the std doc (time::instant, mpsc::Sender and process::Command)
They all have an examples section and they all have an use declaration in it. I guess if there is something missing in the std crate, just file an PR and fix that.
For other crates, I do not have a strong opinion on that. Imho the crate should be documented well, so that people can use it and if I write documentation I try to look at the std and mimic it.
But let's see what other people think. As I said, I would find it very neat, but not very necessary.

@Boscop
Copy link
Author

Boscop commented Apr 26, 2018

Yes, std is better documented than probably any other crates, but even there, the use statements in the examples are not at a consistently placed location, requiring manual visual searching and manual selecting+copying. And most of the time when I'm looking stuff up in the docs it's just to find the import path, I don't want to have to read through the example code to find a possible use statement (which may not even be there)..
And many other crates don't have example code for each type (esp with use statements), and I also wouldn't expect them to, it shouldn't be required / necessary.

@pietroalbini pietroalbini added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-dev-tools-rustdoc labels Apr 26, 2018
@steveklabnik
Copy link
Member

Triage: no changes here that I'm aware of.

@GuillaumeGomez GuillaumeGomez added the A-rustdoc-ui Area: Rustdoc UI (generated HTML) label Mar 18, 2021
@GuillaumeGomez
Copy link
Member

A few extra info on copying things in clipboard on IE:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants