Updated 2013-03-05 11:30:39 by RLE

Summary  edit

Richard Suchenwirth 2004-02-18: I received a document in a markup that I later found out was Doxygen formatting. As I didn't have Doxygen installed, I whipped up this little converter that turns it to HTML (on stdout - best pipe into a file), which was sufficient to make it better readable.

Description  edit

The language of Doxygen is of course much more powerful (see http://www.stack.nl/~dimitri/doxygen/commands.html), but for my limited needs this was just good enough. If you need to process more Doxygen commands, just add them (and update this page too, if it's some thing useful). No warranties, but enjoy!
proc xtex2htm {channel filename} {
    while {[gets $channel line]>=0} {
        set line [string map {
            {\li } <li> 
            \\< <i> \\> </i>
            \\verbatim    <pre>
            \\endverbatim </pre>
            <b> <b>   </b> </b>
            & &amp; < &lt; > &gt;
        } $line]
        if {$line eq "/*!"} continue
        if [regexp {\\mainpage (.+)} $line -> l] {
            set line <h1>$l</h1><hr>
        }
        if [regexp {\\section (\S+) (.+)} $line -> l h] {
            set line "<br><br><a name=$l><h2>$h</h2></a>"
            lappend links "<p><b><a href=#$l>$h</a></b>"
        }
        if [regexp {\\subsection (\S+) (.+)} $line -> l h] {
            set line "<p><a name=$l><h3>$h</h3></a>"
            lappend links "<li><a href=#$l>$h</a>"
        }
        if {[string trim $line] eq ""} {set line <p>}
        #--- markup C++ comments in code sections
        if [regexp {^\s*//} $line] {set line <i>$line</i>}

        puts $line
    }
    puts "<hr><h2>Index</h2><p>[join $links \n]"
    puts "<hr><i>Converted from $filename on [clock format [clock sec]]</i>"
}

proc prolog {} {
    puts <HTML><HEAD/><BODY>
}

proc epilog {} {
    puts </BODY></HTML>
}

prolog
if {[llength $argv]} {
    foreach file $argv {
        set fp [open $file]
        xtex2htm $fp $file
        close $fp
    }
} else {
    xtex2htm stdin stdin
}
epilog

George Petasis: There is a small flex tool than act as a doxygen filter, to generate documentation with doxygen from tcl files. It can be found here