Skip to content

Auto-scrape Examples in Docs #16654

Open
Open
@crepererum

Description

@crepererum

What

It's hard to put in words, but have a look at this example from bevy: https://docs.rs/bevy/0.16.1/bevy/prelude/struct.Events.html#method.send

Image

Also see this explanation.

Why

I think the "manual style" of adding some code to the doc string is very good, e.g.:

/// Get value for given key.\
///
/// # Example
/// ```
/// ...
/// ```
pub fn get(&self, k: &str) -> Option<...> {
...

However sometimes it helps to see certain methods used in a wider context or more complex examples. While one can manually link examples, I think the rendering of rustdoc is great and avoiding manual maintenance burden is always a plus.

I think this greatly helps people to understand what certain methods do.

How

IIRC docs.rs uses a nightly compiler. So all we would need to do is to follow bevy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions