jupyter-book: Polyglot code blocks
I’m curious how one would go about writing a book in which the reader can choose a variant, say Python or Julia, for the code blocks. Could we teach MyST to process code-block variants, in which a single notebook contains multiple versions of code blocks, which we can execute separately with each kernel? So when building with a Python kernel, {code-block:julia} would be ignored, and vice-versa. Then we build one or more variants and provide cross-references.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (11 by maintainers)
Interesting project, though it seems to be about mixed-language workflows (where data needs to be passed between languages). I’m interested in the pedagogy, to maintain two versions of a book that use different programming languages. The use case that motivated me to open this issue is creating educational resources that did not lock instructors into a particular language choice (Python vs Julia). Most of the prose would be the same, but the code blocks and occasional admonitions would vary by language.
Gotcha, so similar to https://documentation.mailgun.com/en/latest/api_reference.html
That’s good for an author or reviewer, but too noisy for a student taking a class that just uses one language. I think a global toggle (in a sidebar, or just a different “version”) would be better for a reader who just wants to learn the subject matter of the book.