ink-playground icon indicating copy to clipboard operation
ink-playground copied to clipboard

Support running code from crate docs

Open cmichi opened this issue 3 years ago • 0 comments

Rustdoc supports a feature for defining a playground URL:

#![doc(html_playground_url = "https://playground.example.com/")]

https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#html_playground_url

We can use this feature to have a "Run" button show up in our ink! crate docs for example code:

YTbMYaa

Once the button is clicked the playground URL is opened with a GET parameter code and edition. The information that's missing for us is the version of ink! that the request originates from.

We can work around this by implementing https://github.com/paritytech/ink-playground/issues/427 and then setting something like

#![doc(html_playground_url = "https://ink-playground.substrate.io/v3.3.1/")]

cmichi avatar Oct 05 '22 08:10 cmichi