Documentation of examples

Is there a way to include examples in documentation generated by rustdoc?

I mean the executables that are stored in ./examples folder rather than just example snippets includes in regular documentation of the source. I'd like to see something in line of an annotated list of examples, as the one produced by Doxygen:

EDIT: It would be also great to be able to include such an example or it's parts within a documentation of a class or struct, e.g. like with Sphinx:

Sounds like Scraped examples - The rustdoc book


The other way is to use #[doc] with include_str! to have all contents of a script:

/// ### Example
#[doc = concat!("\n", "```", "\n", include_str!("../examples/"), "\n", "```")]
pub fn g() {}

If you follow the link I gave above,

pub fn f() {}

you'll get this automatically

Note: only a few lines related will be shown and the documented item will be highlighted.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.