snaptoken / leg

Tools for making step-by-step code walkthroughs
MIT License
132 stars 2 forks source link

New file format: .litdiff #4

Closed paigeruten closed 6 years ago

paigeruten commented 6 years ago

I don't think having the code (steps.diff) separate from the tutorial text (doc/) is ideal. I think the tutorial text should be inline with the code in the steps.diff file. That way you can write the tutorial and actually see the code of each step that you're writing about.

In the git repo representation, the tutorial text in between steps should go in the commit messages of empty commits between actual step commits. So the git repo contains the entire tutorial, like a gitorial, and you can reorder bits of the tutorial text at the same time as you reorder the steps in the tutorial using rebase.

Step commits can also have tutorial text in the commit message, which could be rendered differently from text that isn't associated with a particular step. I'm thinking the first line of the commit message could serve as a summary/name for each step, which could optionally be rendered as part of each step in the tutorial output. Then the text below that would be the paragraph(s) that explain the step in detail, which could be rendered either above or below the diff in the rendered tutorial.

The steps.diff file should be splittable into multiple files, so you can have one file per chapter for example. I'm thinking of using the file extension .litdiff, for "literate diff", similar to CoffeeScript's .litcoffee. So you'd have 01-setup.litdiff, 02-enteringRawMode.litdiff, 03-rawInputAndOutput.litdiff, etc.

Currently, the diff for each step in steps.diff begins with a ~~~ step: line, and continues until the first completely blank line (even blank lines in diffs have a space character at the beginning). So it should be fine to just have tutorial text in between steps, with no special formatting or markup or anything. There will need to be a way of associating paragraph(s) with a particular step though. A paragraph coming after a step might be explaining that step, or it could be explaining the next step, or it could be segueing from one step to the next in which case it shouldn't be tied to either step. If it's tied to a step, then the paragraph(s) should appear in the git commit message for that step, otherwise it should appear in the git commit message of an empty commit between those steps. So, we do need some kind of markup to say whether a paragraph is associated with a particular step. (It matters because you might want to render a tutorial in a very structured way, for example displaying only a single step per page, in which case you'd only want to show the text associated with that step on that step's page.)

OK, this is getting lengthy, this is just me getting a bunch of ideas down. This'll hopefully become a lot more clear and concise after I've had time to think about it some more. To summarize what needs to be done:

Most of the above is done! Just lots of little (some not so little) things to get done now:

Branch: litdiff Parallel branch for converting kilo-tutorial to litdiff: https://github.com/snaptoken/kilo-tutorial/tree/litdiff

paigeruten commented 6 years ago

Closing this and creating new issues for each unchecked todo item.