Better literate programming #983
amitu
started this conversation in
Ideas & RFCs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
https://axleos.com/writing-about-writing-about-programming/
What would better literate programming look like with fastn?
A fastn document can contain one or more code blocks. We can create an option to download all the code blocks in that document.
The code blocks source code can be a template, e.g.:
Which will download a file
hello.ftd,-- hello:` in the editor. And this is what will be downloaded.fastn build?How to handle this on build time is tricky, since the template variable can be read from query params etc, and we do not know if all documents must be contain such "embedded" literate program or not.
Splitting Code Across Multiple Blocks
Further literate programming typically allows you to split a code block into multiple blocks, so you focus on each item at a time, so we need a meta language to refer to other code blocks defined in this document, eg
Here we have two code blocks, one with
filenameand other withid.filenameones will be included in generated zip, and they can refer to other code blocks in the current file via@<id>@syntax (not finalised, open for suggestions).We should also support
@<path>:<id>@so blocks defined in other documents can be included.Splitting Things Over Multiple Files
Since we may want to split the whole literate programming thing in multiple blocks, how do we tell fastn that this set of files are to be parsed when the zip file is being computed? One option is we use sitemap somehow.
Other option we include allow explicit
ftd.literatekernel, which when present will act likeftd.jsonetc, so you can download the zip even without fastn doing something magical, the logic of when to return zip can be in your hand.And you can include the other files from other docs:
We have explicitly passed
include, which will look for code snippets in all the included files, when generatinghello-world.zip.Beta Was this translation helpful? Give feedback.
All reactions