split main() into main() (for printing) and write_docs (for docs)