Writing your own extensionsExtending HyperlatexBabelDocumenting codeContentsIndex

Documenting code

The cppdoc package can be used to document code in C++ or Java. This is experimental, and may either be extended or removed in future Hyperlatex distributions. There are far more powerful code documentation tools available--I'm playing with the cppdoc package because I find a simple tool that I understand well more helpful than a complex one that I forget to use and therefore don't use.

The package defines a command cppinclude to include a C++ or Java header file. The header file is stripped down before it is interpreted by Hyperlatex, using certain comments to control the inclusion:

Note that the cppenv environment and the \cppmethod command are not provided by cppdoc. You have to define them in your document. A simple definition would be:

\newenvironment{cppenv}{\begin{example}}{\end{example}}
\newcommand{\cppmethod}[1]{\paragraph{#1}}

You can use \cpplabel to put a label in the section documenting a certain class. \cpplabel{Engine} will place an ordinary label class:Engine in the document, and will also remember that Engine is the name of a class known in the project (and will therefore be converted to a link inside a cppenv environment and the argument to \cppmethod).

The command \cppclass takes a single class name as an argument, and creates a link if a label for that class has been defined in the document.

If you use \cppextras, then the vertical bar character is made active. You can use a pair of vertical bars as a shortcut for the \cppclass command.


July 13, 2005

Writing your own extensionsExtending HyperlatexBabelDocumenting codeContentsIndex