This will generate a PDF documenting code in the given folder.
pip3 install code-listing-generator
(requires python3)
- Navigate to the directory containing files (or subdirectories with more files) that you want to include in the listing.
- run the command
generate-code-listing. There are a few options you can use here, see below.- If you want to be able to select files from all subdirectories of the current directory, and have the result copied to your clipboard (for example, to paste into overleaf), I recommend you try
generate-code-listing -rpc. - If you have a local installation of LaTeX including PDFLatex, you can use
generate-code-listing -rpmto instruct the program to make acode-writeupsubdirectory of the current directory, save the code there, and compile it usingpdflatex.
- If you want to be able to select files from all subdirectories of the current directory, and have the result copied to your clipboard (for example, to paste into overleaf), I recommend you try
If you forget these while using the program, you can run generate-code-listing -h to display a short version.
-r: find files recursively. This instructs the program to look in all subdirectories of the current directory and include files found there.-p: prompt user for each file. This allows the user to select some files and not others to be included in the directory listing. If used in conjunction with-r, it asks whether the user would like to enter each subdirectory, preventing having to manual exclude lots of irrelevant files.-c: copy result to clipboard. This simply copies the generated result to the system clipboard, it should use the correct tool depending on OS. Relies onpyperclip, which requiresxcliporxselon Linux. Also prints the LaTeX output to STDOUT, in case the copying doesn't work or the clipboard contents gets lost on the way to Overleaf.-m: make. This instructs the program to create a new directorycode-writeupand save the outputted file inside that folder aswriteup.tex. It then compiles this into a PDF withpdflatex--the result will be in thecode-writeupfolder it created.
If anything seems broken or you want me to change anything, open an issue (or submit a PR fixing it, if you want)