2009/02/01

HTML crosslinked documentation from source code files

I know that modern IDEs can navigate through source code files very easily. But...what if I want to browse through source code files in my Palm TX ? Netbeans, Eclipse and other IDEs are not available for it, but I can read HTML pages offline easily with Plucker. Maybe I simply don't want to open an IDE only to browse the source code, without actually coding.

There are tools that can generate HTML pages from source code, so you can browse through them easily. They can even beautify the code with syntax highlighting and (this is my favourite) provide links between the different elements of the documentation. So, when you browse class Foo and it extends from BaseFoo, you can simply click on the word BaseFoo and you navigate to the class BaseFoo, and so on.

I've been searching for tools of this kind and I found some of them.

I like Doxygen a lot, it can make a wonderful and complete documentation of the source code, including this crosslinking source code navigation. It can optionally use another tool called htags to include the source code with this crosslinking navigation (instead of its own system). And this little tool attracted my attention...htags. It is an extremely simple and fast yet powerful tool that can generate HTML crosslinked documentation from source code.

If you have a Linux (or other *nix), you can simply install htags with a package manager, the whole package where it belongs is global. If you use Windows, you can download global from this site. There are other binaries in the download page of global.

With htags you can go to the source code root directory, write:

htags -g

...and that's all! You have your browsable crosslinked HTML documentation in a directory called HTML. I have tested it with Java files, but it supports other languages as well (C, C++, Yacc, PHP and Assembler).

If you want more features (like class diagrams, Javadoc-style complementary documentation, more flexibility with configuration, etc.), you can use Doxygen. It also supports more languages (C++, C, Java, Objective-C, Python, IDL, Fortran, VHDL, PHP, C#, and to some extent D). But if you only need plain source code with syntax highlighting and crosslinked navigation, give htags a try!