Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration with online playground for code samples #76

Open
straight-shoota opened this issue Apr 12, 2019 · 4 comments
Open

Add integration with online playground for code samples #76

straight-shoota opened this issue Apr 12, 2019 · 4 comments
Assignees

Comments

@straight-shoota
Copy link
Member

It would be lovely if there was a "run" button on the code samples... I take it you care about adoption, since you bother providing a REPL - it's common for language sites to make code samples more useful by linking to the REPL so people can try and modify the code samples, and probably low-hanging fruit since you did the hard work of building a REPL already?)

Originally posted by @mindplay-dk in #75 (comment)

I think REPL means an online playogrund (i.e. https://play.crystal-lang.org) which is not really an REPL (but serves a similar use case).

This is an excellent idea. We should definitely do that. An MVP should be pretty simple, just C&P the examples to play and paste the link to the result page besides the original code.
Additionally, we should try to make the examples self-contained. The LibGMP example doesn't compile currently, but this can be fixed.
The HTTP server example won't work either, but that's to be expected. We should consider putting a different example on top which provides a meaningful play button.

The play links are fixed to the Crystal version used at creation. This would mean they need to be updated for every release. But I think that's fine for now. But this can certainly be improved.

Similar playground links would be nice for https://github.com/crystal-lang/crystal-book as well, and maybe the stdlib API docs. But the website has probably the most exposure to newcomers interested in seeing Crystal in action, so this should come first and then we can follow up with other parts.

/cc @jhass

@jhass
Copy link
Member

jhass commented Apr 12, 2019

There's kind of a chicken and egg problem here. I cannot put a new version in the playground until it's released and the docs can't be build until there's the new version in the playground, right?

What if we build a command like crystal docs serve which augments the examples with crystal playground like functionality?

@straight-shoota
Copy link
Member Author

It's not even necessary to run the samples with the new compiler during generation. So there are options if the compiler version used for each sample in the playground was more flexible. Maybe there could be an option to make a sample depend on the latest available compiler. When a new version is released, the old results would be deleted and executed again on demand. That would need to be implemented in the playground.

Alternatively, there could be an indirection between the link in the docs and the playground link. A microservice sits in between and every time there is a new release, it invalidates the old redirects, extracts the source code from the previous playground link and creates a new sample in the playground which is then cached until a new version is released.

The first option would be more flexible, though.

@beta-ziliani
Copy link
Member

We can consider this solved, right @straight-shoota ?

@straight-shoota
Copy link
Member Author

No? There are no interactive examples on the website. We only have them in https://github.com/crystal-lang/crystal-book (but it shouldn't be hard to copy that feature over)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants