I'm thinking of using literate programming to investigate large amount, or hard to understand source code. For the purpose, I'd like refactor the source code into literate programming text with org-mode/babel, so that I can add annotations of my study, questions, and comments freely, while I can tangle back to get the original source code.
I just wondering if any kind soul has already done something similar? At the moment, it could be simple as:
- Input the source code into org-mode/babel buffer, and wrap the whole source code into an initial code chunk;
- Provide a command to extract a region, or a sub-expression into separate code chunk with proper arrangement in terms of chunk name, headers, etc. so that the relationship in the source code can be expressed, and preserved, such as having another code check to aggregate those separated code chunk. (the name of the extracted code chunk may be automated as the first expression in the region, or something semantically making sense, and feasible)
- For more advance application, the tool can scan the source code directory, and generate an initial org-mode file with the source code being parsed into literate programming chunks for each major programming constructs, for each file, the header declaration, and each function/subroutine, etc., with proper arrangement to tangle back the original source code directories, and files.
The essence is to automate the manual operations in refactoring as much as possible.
I feel that this might be a tremendous help to study source code.
Please share pointers, thought, contributions.
Thanks, Yu