scribble icon indicating copy to clipboard operation
scribble copied to clipboard

Make examples easier to modify

Open bennn opened this issue 8 years ago • 4 comments

Feature request from RacketCon: make it easy to copy/paste examples from scribble/examples.

The problem is that the code snippets in "Examples:" often need some context in order to run, so you can't just copy/paste from the docs to start experimenting with the examples.

One solution: add a "copy to clipboard" button to every codeblock made from an @examples[....]

bennn avatar Oct 11 '17 05:10 bennn

Oh god yes please. Were you also thinking that the examples form could look at the bindings of all identifiers used and automatically include the needed (require ...) form?

There might be weirdness related to whether the user pastes the codeblock into a module or the repl, but that's still much better than how things are now.

jackfirth avatar Oct 11 '17 06:10 jackfirth

Were you also thinking that the examples form could look at the bindings of all identifiers used and automatically include the needed (require ...) form?

Yes. Also any definitions from prior examples.

The evaluator has to get all this code to work (requires, defines), so I'm thinking we just need a way to record & replay the source code.

bennn avatar Oct 11 '17 13:10 bennn

Please make this a backwards-compatible change. I don’t want the examples in HtDP/2e to reveal the source definitions because they are not (always) in *SL.

mfelleisen avatar Oct 11 '17 14:10 mfelleisen

Maybe we can use a parameter so that both cases can be handled, that defaults to copy/pastable?

I think too that would be very useful thing to have.

Metaxal avatar Jul 11 '21 13:07 Metaxal