docs.rs icon indicating copy to clipboard operation
docs.rs copied to clipboard

Add links to examples folder

Open tafia opened this issue 8 years ago • 5 comments
trafficstars

Not sure if it is possible, but as examples are complimentary to documentation, it would be nice if docs.rs could provide links to examples in the repo examples directory (even perhaps render them?).

tafia avatar Jun 14 '17 01:06 tafia

This would be beneficial, as new users might not know that examples are located under the examples folder in the source code.

This should be relatively easy. Just detect if there is src/examples, and if it's present, add a dedicated Examples link to the top bar.

crumblingstatue avatar Sep 09 '17 09:09 crumblingstatue

Triage: This can be part of #740 as we pass the have_examples variable to templates, however I can see issues related to crates that don't use an examples folder for examples which might require expanding the parsing we do on each crate's Cargo.toml

Kixiron avatar May 27 '20 14:05 Kixiron

Could also be related to https://github.com/rust-lang/docs.rs/issues/238, in that if we start generating documentation for examples then they'll have [src] links in them.

Nemo157 avatar May 27 '20 15:05 Nemo157

This should be quite doable already. docs.rs includes the examples in the source tab, for example https://docs.rs/crate/chumsky/latest/source/examples/brainfuck.rs

And docs.rs is aware of how to get to the source tab. image

So now it should just be a matter of putting the right link in the side-bar, I suppose?

stefnotch avatar Aug 19 '23 12:08 stefnotch

Everything except the topbar of the documentation pages is generated by rustdoc, we don't really want to be trying to inject extra stuff into the side-bar after the page was generated.

Nemo157 avatar Aug 19 '23 13:08 Nemo157