1 /******************************************************************************
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
17 /*! \page custcmd Custom Commands
21 Doxygen provides a large number of \ref commands "special commands",
22 \ref xmlcmds "XML commands", and \ref htmlcmds "HTML commands".
23 that can be used to enhance or structure the documentation inside a comment block.
24 If you for some reason have a need to define new commands you can do
25 so by means of an \e alias definition.
27 The definition of an alias should be specified in the configuration file using
28 the \ref cfg_aliases "ALIASES" configuration tag.
30 \section custcmd_simple Simple aliases
31 The simplest form of an alias is a simple substitution of the form
35 For example defining the following alias:
37 ALIASES += sideeffect="\par Side Effects:\n"
40 put the command \\sideeffect (or \@sideeffect) in the documentation, which
41 will result in a user-defined paragraph with heading <b>Side Effects:</b>.
43 Note that you can put \\n's in the value part of an alias to insert newlines.
45 Also note that you can redefine existing special commands if you wish.
47 Some commands, such as \ref cmdxrefitem "\\xrefitem" are designed to be used in
48 combination with aliases.
50 \section custcmd_complex Aliases with arguments
51 Aliases can also have one or more arguments. In the alias definition you then need
52 to specify the number of arguments between curly braces. In the value part of the
53 definition you can place \\x markers, where 'x' represents the argument number starting
56 Here is an example of an alias definition with a single argument:
58 ALIASES += l{1}="\ref \1"
61 Inside a comment block you can use it as follows
63 /** See \l{SomeClass} for more information. */
65 which would be the same as writing
67 /** See \ref SomeClass for more information. */
70 Note that you can overload an alias by a version with multiple arguments, for instance:
72 ALIASES += l{1}="\ref \1"
73 ALIASES += l{2}="\ref \1 \"\2\""
75 Note that the quotes inside the alias definition have to be escaped with a backslash.
77 With these alias definitions, we can write
79 /** See \l{SomeClass,Some Text} for more information. */
81 inside the comment block and it will expand to
83 /** See \ref SomeClass "Some Text" for more information. */
85 where the command with a single argument would still work as shown before.
87 Aliases can also be expressed in terms of other aliases, e.g. a new command
88 \\reminder can be expressed as a \\xrefitem via an intermediate \\xreflist command
91 ALIASES += xreflist{3}="\xrefitem \1 \"\2\" \"\3\" " \
92 ALIASES += reminder="\xreflist{reminders,Reminder,Reminders}" \
95 Note that if for aliases with more than one argument a comma is used as a separator,
96 if you want to put a comma inside the command, you will need to escape it with a backslash,
99 \l{SomeClass,Some text\, with an escaped comma}
101 given the alias definition of \\l in the example above.
103 \section custcmd_nesting Nesting custom command
105 You can use commands as arguments of aliases, including commands
106 defined using aliases.
108 As an example consider the following alias definitions
111 ALIASES += Bold{1}="<b>\1</b>"
112 ALIASES += Emph{1}="<em>\1</em>"
115 Inside a comment block you can now use:
117 /** This is a \Bold{bold \Emph{and} Emphasized} text fragment. */
121 /** This is a <b>bold <em>and</em> Emphasized</b> text fragment. */