Hyping Up your Programs

In a complete abuse of HTML, I've written a program that will accept your source files and output a "nice" version: one which has keywords in bold and comments in italics. And if you've got some embedded HTML comments, you can even have those wrapped nicely, whilst

      leaving the compilable portion,
         in a fixed-width font,
      laid out as you originally typed it.
    

The program does not try and do anything clever. If you want your if statements indented in some interesting way, look elsewhere.

For an example of what the output can look like, here's the result of running enhype on its own source file, following the language definition in one of my enhype.kw files.

As you can guess, the main purpose of enhype is to convince your manager that, though the code might not actually work, it just looks so darned pretty that you really are worth what they pay you.

As is often the way, my enhype binary is supposed to be called from a shell script. You're quite welcome to write your own, but the script I supply behaves (roughly) as follows:


The enhype driver script

The script expects a mixture of swithes and file names on its command line. So far there aren't many switches. If no switches change the behaviour then, for a given file, and attempt is made to guess the language (by a cursory examination of the filename), and a "title" block is created (a minimal HTML header containing the name of the file). The switches so far are:

-d

Normally enhype's output contains code and documentext mixed together. This swtich sets "documentation only" mode for subsequent files.

-m

Revert to "mixed mode" (ie undo a previous -d).

-L lang

Use lang as the language for all subsequent files, over-riding the "guessing" logic. You can turn guessing back on by giving the empty string as lang.

-T

Suppress the automatic title block for subsequent files. This is very useful if the files themselves contain all the necessary HTML lines, presumably embedded in comments.

-t

Re-instate the automatic title block generation for subsequent files (ie undo a previous -T).

Files that are guessed to be Java sources are given special treatment. The normal javadoc tags are converted into things the enhype binary will find interesting, so your listings will come out with the javadoc comments looking pretty.

The language guessed is used to trigger a search along your KW_PATH environment variable (no, I know you haven't got one, but the script supplies a default).


Preparing your files for enhype

If you just want a slightly prettied-up listing, nothing need be done. The default action is to print comments and strings in italics, and keywords in bold. For a small extra price, namely the addition of <doc> and </doc> markers, you can include comments that get nicely formatted as HTML. And if there are some things you just don't want listed, legally unenforceable copyright blocks, huge coding-guidelines-require headers that obscure the program, or whatever, these can be supressed by wrapping them in a <hide>..</hide> block.


By now either you've got bored and gone off somewhere else or you're keen to try it out. If the former, bon voyage. If the latter, first read the legal bits to make sure you're happy about not having to pay me, then grab a copy of the sources and follow the installation instructions.