Blame doc/custcmd.doc

Packit 1c1d7e
/******************************************************************************
Packit 1c1d7e
 *
Packit 1c1d7e
 * 
Packit 1c1d7e
 *
Packit 1c1d7e
 * Copyright (C) 1997-2015 by Dimitri van Heesch.
Packit 1c1d7e
 *
Packit 1c1d7e
 * Permission to use, copy, modify, and distribute this software and its
Packit 1c1d7e
 * documentation under the terms of the GNU General Public License is hereby 
Packit 1c1d7e
 * granted. No representations are made about the suitability of this software 
Packit 1c1d7e
 * for any purpose. It is provided "as is" without express or implied warranty.
Packit 1c1d7e
 * See the GNU General Public License for more details.
Packit 1c1d7e
 *
Packit 1c1d7e
 * Documents produced by Doxygen are derivative works derived from the
Packit 1c1d7e
 * input used in their production; they are not affected by this license.
Packit 1c1d7e
 *
Packit 1c1d7e
 */
Packit 1c1d7e
/*! \page custcmd Custom Commands
Packit 1c1d7e
Packit 1c1d7e
\tableofcontents
Packit 1c1d7e
Packit 1c1d7e
Doxygen provides a large number of \ref commands "special commands", 
Packit 1c1d7e
\ref xmlcmds "XML commands", and \ref htmlcmds "HTML commands".
Packit 1c1d7e
that can be used to enhance or structure the documentation inside a comment block. 
Packit 1c1d7e
If you for some reason have a need to define new commands you can do
Packit 1c1d7e
so by means of an \e alias definition. 
Packit 1c1d7e
Packit 1c1d7e
The definition of an alias should be specified in the configuration file using
Packit 1c1d7e
the \ref cfg_aliases "ALIASES" configuration tag.
Packit 1c1d7e
Packit 1c1d7e
\section custcmd_simple Simple aliases
Packit 1c1d7e
The simplest form of an alias is a simple substitution of the form
Packit 1c1d7e
\verbatim
Packit 1c1d7e
 name=value
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
 For example defining the following alias: 
Packit 1c1d7e
\verbatim
Packit 1c1d7e
 ALIASES += sideeffect="\par Side Effects:\n" 
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
 will allow you to
Packit 1c1d7e
 put the command `\sideeffect` (or `@sideeffect`) in the documentation, which 
Packit 1c1d7e
 will result in a user-defined paragraph with heading Side Effects:.
Packit 1c1d7e
Packit 1c1d7e
Note that you can put `\n`'s in the value part of an alias to insert newlines
Packit 1c1d7e
(in the resulting output). You can put `^^` in the value part of an alias to
Packit 1c1d7e
insert a newline as if a physical newline was in the original file.
Packit 1c1d7e
Packit 1c1d7e
Also note that you can redefine existing special commands if you wish.
Packit 1c1d7e
Packit 1c1d7e
Some commands, such as \ref cmdxrefitem "\\xrefitem" are designed to be used in
Packit 1c1d7e
combination with aliases. 
Packit 1c1d7e
Packit 1c1d7e
\section custcmd_complex Aliases with arguments
Packit 1c1d7e
Aliases can also have one or more arguments. In the alias definition you then need
Packit 1c1d7e
to specify the number of arguments between curly braces. In the value part of the
Packit 1c1d7e
definition you can place `\x` markers, where '`x`' represents the argument number starting
Packit 1c1d7e
with 1.
Packit 1c1d7e
Packit 1c1d7e
Here is an example of an alias definition with a single argument:
Packit 1c1d7e
\verbatim
Packit 1c1d7e
ALIASES += l{1}="\ref \1"
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
Packit 1c1d7e
Inside a comment block you can use it as follows
Packit 1c1d7e
\verbatim
Packit 1c1d7e
/** See \l{SomeClass} for more information. */
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
which would be the same as writing
Packit 1c1d7e
\verbatim
Packit 1c1d7e
/** See \ref SomeClass for more information. */
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
Packit 1c1d7e
Note that you can overload an alias by a version with multiple arguments, for instance:
Packit 1c1d7e
\verbatim
Packit 1c1d7e
ALIASES += l{1}="\ref \1"
Packit 1c1d7e
ALIASES += l{2}="\ref \1 \"\2\""
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
Note that the quotes inside the alias definition have to be escaped with a backslash.
Packit 1c1d7e
Packit 1c1d7e
With these alias definitions, we can write
Packit 1c1d7e
\verbatim
Packit 1c1d7e
/** See \l{SomeClass,Some Text} for more information. */
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
inside the comment block and it will expand to
Packit 1c1d7e
\verbatim
Packit 1c1d7e
/** See \ref SomeClass "Some Text" for more information. */
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
where the command with a single argument would still work as shown before.
Packit 1c1d7e
Packit 1c1d7e
Aliases can also be expressed in terms of other aliases, e.g. a new command
Packit 1c1d7e
`\reminder` can be expressed as a \ref cmdxrefitem "\\xrefitem" via an intermediate `\xreflist` command
Packit 1c1d7e
as follows:
Packit 1c1d7e
\verbatim
Packit 1c1d7e
ALIASES += xreflist{3}="\xrefitem \1 \"\2\" \"\3\" "
Packit 1c1d7e
ALIASES += reminder="\xreflist{reminders,Reminder,Reminders}"
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
Packit 1c1d7e
Note that if for aliases with more than one argument a comma is used as a separator,
Packit 1c1d7e
if you want to put a comma inside the command, you will need to escape it with a backslash,
Packit 1c1d7e
i.e. 
Packit 1c1d7e
\verbatim
Packit 1c1d7e
\l{SomeClass,Some text\, with an escaped comma} 
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
given the alias definition of `\l` in the example above.
Packit 1c1d7e
Packit 1c1d7e
\section custcmd_nesting Nesting custom command
Packit 1c1d7e
Packit 1c1d7e
You can use commands as arguments of aliases, including commands
Packit 1c1d7e
defined using aliases.
Packit 1c1d7e
Packit 1c1d7e
As an example consider the following alias definitions
Packit 1c1d7e
Packit 1c1d7e
\verbatim
Packit 1c1d7e
ALIASES += Bold{1}="\1"
Packit 1c1d7e
ALIASES += Emph{1}="\1"
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
Packit 1c1d7e
Inside a comment block you can now use:
Packit 1c1d7e
\verbatim
Packit 1c1d7e
/** This is a \Bold{bold \Emph{and} Emphasized} text fragment. */
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
which will expand to
Packit 1c1d7e
\verbatim
Packit 1c1d7e
/** This is a bold and Emphasized text fragment. */
Packit 1c1d7e
\endverbatim
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
\htmlonly
Packit 1c1d7e

Packit 1c1d7e
Go to the next section or return to the
Packit 1c1d7e
 index.
Packit 1c1d7e
\endhtmlonly
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
*/