How can I do literate programming in TeX where TeX, or some variant, is both the used programming language and what is used for typesetting the document? Is there more than one way to do it or different approaches for different TeX variants? I would appreciate some examples.
|
|
Given that the question is on how to do literate programming for TeX code then one answer as already mentioned in the comment by David is using The doc/docstrip combination is not the best possible way to do things (there are better approaches that could be imagined), but it offers one immense advantage, which probably explains why a large proportion of packages these days are documented in this manner:
On the downside
However, it served fairly well as it seems. Documentation is found as part of the LaTeX distribution. For documentation look at |
|||||||||||||||||
|
|
ConTeXt uses different form of comments to document macro code. For example, lines beginning with To generate documentation, you need to run
It is possible to use this feature with plainTeX/LaTeX as well. Process the file using
This will create a
You can then define appropriate macros to handle |
|||||
|
|
I think a good alternative can be noweb. Pros are:
There are not cons in my knowledge. You can find some examples of noweb code on @wasteofspace : as far as I know |
|||||||
|
|
There is the For languages that support multiline comments one simple method is along the lines (where (* starts a language comment and *) ends it):
Run the file through the language compiler as is, or through LaTeX after commenting out the initial |
||||
|
|
|
One should also notice that there is |
|||||
|

