docs.rs
docs.rs copied to clipboard
Add links to examples folder
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?).
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.
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
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.
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.
So now it should just be a matter of putting the right link in the side-bar, I suppose?
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.