printing batch of source code
I want to analyze an open source application by reading its source code. I don't like reading from the screen. Instead, I'd like to print the code and read offline.
The application is based on a framework, and therefore consists of a lot of small files. It's not reasonable to print file per page. Instead, it's better to print everything at once. Here is my approach.
First, I visit directories with the source code and issue commands like these:
for i in *rb; do colorer -h -dc -igrayscale $i >$i.html; done
for i in *rhtml; do colorer -h -dc -t asp -igrayscale $i >$i.html; done
The commands above produce HTML files with syntax highlighting. Now I want to join the files to one file and separate chunks by headings. The corresponding command is:
find . -name '*.html' | xargs -I _ x.sh _
where x.sh is a helper file:
#!/bin/sh
echo '<h4>' $1 '</h4>' >>s.html
cat $1 >>s.html
The rest is simple. Open s.html in browser, copy/paste text to OpenOffice, massage the text for printing, and finally print.