![]() | ![]() | ![]() | Documenting code | Contents | Index |
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:
/** and up to */ is included.
//+ is included.
//-- is converted to \begin{cppenv},
and the following code is not stripped. This environment is ended
using //--. All known class names inside this environment will
be converted to links.
/// can be used at the end of the
first line of a method. The method name will be extracted as the
argument to \cppmethod,. The method declaration needs to be
followed by a /** or //+ comment documenting the method.
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.
![]() | ![]() | ![]() | Documenting code | Contents | Index |