The Rust tool mdbook generates documentation from Markdown. It lets the reader edit and run Rust snippets directly in the browser by piping them to the Rust Playground. This lets you write readable documentation while letting your reader try out examples without cut-and-paste into a local editor. The Rust documentation uses this.
Is there anything like this for Scala? Scala has a playground (SCastie) so it seems the hard part has been dealt with. Perhaps there is a more general tool like gitbook that can do this by configuring SCastie as a backend?
Mdoc allows creating SCastie snippets out of your code.
From docs:
Before:
After: