Sorry, that's not correct. When writing a literate program you should also include a chunk containing a Makefile. Extract the Makefile and let it construct the program.
I did this with the whole Clojure programming language. The whole source code for all of Clojure, as well as the test cases, are in the PDF. The sequence (from scratch is):
Extract the Makefile from the Latex document. Run the Makefile. This:
1) extracts the code and tests
2) compiles the code
3) runs the tests
4) recreates the PDF from the Latex
So you edit the Latex text and/or code with any editor and then re-run the Makefile. This
will rebuild your program, runs the tests, and re-makes the PDF.If you have the PDF open next to your editor it is likely that the PDF viewer will reload the changes immediately.
This ensures that (a) your program compiles, (b) your program passes tests, and (c) the PDF builds correctly.
I've been working on literate programs for years. See https://en.wikipedia.org/wiki/Axiom_(computer_algebra_system.... I've even given a talk on the subject See https://www.youtube.com/watch?v=Av0PQDVTP4A).
I find literate programming to be the MOST important change in programming since I started in 1970.