summaryrefslogtreecommitdiffstats
path: root/doc/starting.doc
blob: e89f717b374e0537c4f080cd6d67e51896403b90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
/******************************************************************************
 *
 * $Id$
 *
 * Copyright (C) 1997-1999 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * All output generated with Doxygen is not covered by this license.
 *
 */
/*! \page starting Getting started

The executable \c doxygen is the main program that parses the sources and 
generates the documentation. See section \ref doxygen_usage for more
detailed usage information.

The executable \c doxytag is only needed if you want to generate references 
to external documentation (i.e. documentation that was generated by Doxygen) 
for which you do not have the sources or to create a search index for 
the search engine. See section \ref doxytag_usage for more detailed usage 
information.

The executable \c doxysearch is only needed if you want to use the search 
engine. See section \ref doxysearch_usage for more detailed usage information.

\subsection step1 Step 1: Creating a configuration file

Doxygen uses a configuration file to determine all of its settings.
Each project should get its own configuration file. A project can consist
of a single source file, but can also be an entire source tree that is 
recursively scanned.

To simplify the creation of a configuration file, Doxygen can create a 
template configuration file for you. To do this call \c doxygen with the \c -g 
option:

\verbatim
doxygen -g <config-file>
\endverbatim
where \<config-file\> is the name of the configuration file. If you omit
the file name, a file named \c Doxyfile will be created. If a file with the
name \<config-file\> already exists, Doxygen will rename it to 
\<config-file\>.bak before generating the configuration template.

The configuration file has a format that is similar to that of a (simple) 
Makefile. It contains of a number of assignments (tags) of the form:

<tt>TAGNAME = VALUE</tt> or <br>
<tt>TAGNAME = VALUE1 VALUE2 ... </tt><br>

You can probably leave the values of most tags to their default value. 

The \c INPUT tag is the only tag for which you are required to provide
a value. See section \ref config for more details about the configuration file.
For a small project consisting of a few C and/or C++ source and header files, 
you can add the names of the files after the \c INPUT tag. 
If you have a larger project consisting of a source directory or tree
this may become tiresome. In this case you should put the root directory or 
directories after the \c INPUT tag, and add one or more file 
patterns to the \c FILE_PATTERN tag. Only files that match one of the 
patterns will be parsed (if the patterns are omitted all files will be parsed).
For recursive parsing of a source tree you must set 
the \c RECURSIVE tag to \c YES. To further finetune the list of files
that is parsed the \c EXCLUDE and \c EXCLUDE_PATTERNS tags can be used.

If you start using Doxygen for an existing project (thus without any 
documentation that Doxygen is aware of), you can still get an idea of
what the documented result would be. To do so, you must set the \c EXTRACT_ALL 
tag in the configuration file to \c YES. Then, Doxygen will pretend 
everything in your sources is documented. Please note that warnings of
undocumented members will not be generated as long as \c EXTRACT_ALL is set
to \c YES.

\subsection step2 Step 2: Running doxygen

To generate the documentation you can now enter:
\verbatim
doxygen <config-file>
\endverbatim

Doxygen will create a \c html, \c latex and/or \c man directory inside 
the output directory. 
As the names suggest the \c html directory contains the
generated documentation in HTML format and the \c latex directory contains the
generated documentation in \f$\mbox{\LaTeX}\f$ format. Man pages are put
in a man3 directory inside the \c man directory.

The default output directory is the directory in which \c doxygen
is started. The directory to which the output is written can be changed 
using the \c OUTPUT_DIRECTORY , \c HTML_OUTPUT, \c LATEX_OUTPUT, and
\c MAN_OUTPUT tags of the configuration file. If the output directory does not 
exist, \c doxygen will try to create it for you.

\addindex browser
The generated HTML documentation can be viewed by pointing a HTML browser
to the \c index.html file in the \c html directory. For the best results
a browser that supports cascading style sheets (CSS) should be used
(I'm currently using Netscape 4.0 to test the generated output).
\addindex LaTeX

The generated \f$\mbox{\LaTeX}\f$ documentation must first be compiled by 
a \f$\mbox{\LaTeX}\f$ compiler. (I use teTeX distribution version 0.4
that contains \f$\mbox{\TeX}\f$ version 3.14159). To simplify the process 
of compiling the generated
documentation, \c doxygen writes a \c Makefile into the \c latex directory. 
By typing \c make in the \c latex directory the dvi file \c refman.dvi
will be generated. This file can then be viewed using \c xdvi or 
converted into a postscript file \c refman.ps by typing <code>make ps</code> 
(this requires \c dvips ). The Postscript file can be send to a postscript
printer. If you do not have a postscript printer, you can try to use 
ghostscript to convert postscript into something your printer understands.

The generated man pages can be viewed using the \c man program. You do need
to make sure the man directory is in the man path (see the MANPATH
environment variable). Notice that there are some limitations to the 
capabilities of the man page format, so some information 
(like class diagrams, cross references and formulas) will be lost.

\subsection step3 Step 3: Documenting the sources

Although documenting the source is presented as step 3, in a new project 
this should ofcourse be step 1. Here I assume
you already have some code and you want Doxygen to generate a nice document 
describing the API and maybe the internals as well.

If the \c EXTRACT_ALL option is set to \c NO in the configuration file 
(the default), then doxygen will only generate documentation for 
\e documented members, files, classes and namespaces. So how do you document 
these? For members, classes and namespaces there are basicly two options:
<ol>
<li>Place a \e special documentation block in front of the declaration or
    definition of the member, class or namespace. For file, class and namespace
    members it is also allowed to place the documention directly after the 
    member. See section \ref specialblock to learn more about special 
    documentation blocks.
<li>Place a special documentation block somewhere else (another file or 
    another location) \e and put a <em>structural command</em> in the 
    documentation block. A structural command links a documentation block 
    to a certain object that can be documented (e.g. a member, class, 
    namespace or file). See section \ref structuralcommands to learn more 
    about structural commands.
</ol>
Files can only be documented using the second option.
The text inside a special documentation block is parsed
before it is written to the HTML and/or \f$\mbox{\LaTeX}\f$ output files.

\addindex parsing
During parsing the following steps take place:
<ul>
<li> The special commands inside the documentation are executed. See
     section \ref commands for an overview of all commands.
<li> If a line starts with some whitespace followed by one or more asterixes 
     (<tt>*</tt>) then the whitespace and asterixes are removed.
<li> All resulting blank lines are treated as a paragraph separators.
     This saves you from placing new-paragraph commands yourself, 
     in order to make the generated documentation readable.
<li> Links are created for words corresponding to documented classes. 
<li> Links to members are created when certain patterns are found in the
     text. See section \ref autolink
     for more information on how the automatic link generation works.
<li> HTML tags that are in the documentation are interpreted and converted 
     to \f$\mbox{\LaTeX}\f$ equivalents for the \f$\mbox{\LaTeX}\f$ output. 
     See section \ref htmlcmds for an overview of all supported HTML tags.
</ul>

\subsection specialblock Special documentation blocks

The following types of special documentation blocks are supported by Doxygen:
<ul>
<li>The Qt style, where special documentation blocks look like:
\verbatim
/*!
  ... text ...
*/
\endverbatim and the one line version:
\verbatim
//! ... one line of text ...
\endverbatim
<li>The JavaDoc style, where special documentation blocks look like:
\verbatim
/**
 * ... text ...
 */
\endverbatim and the one line version:
\verbatim
/// ... one line of text ...
\endverbatim
</ul>

Here is an example of a documented piece of C++ code using the Qt style:
\verbinclude qtstyle.cpp
 \htmlonly
 Click <a href="$(DOXYGEN_DOCDIR)/examples/qtstyle/html/class_test.html">here</a>
 for the corresponding HTML documentation that is generated by Doxygen.
 \endhtmlonly

The one-line comments should contain a brief description, 
whereas the multi-line comment blocks contain a more detailed description.
The brief descriptions are included in the member overview of a class, 
namespace or file and are printed using a small italic font 
(this description can be omitted by setting \c BRIEF_STDMETHOD_DESC to \c NO in 
the config file). By default the brief descriptions are also the first 
sentence of the detailed description 
(this can be changed by setting the \c REPEAT_BRIEF tag to \c NO). 
Both the brief and the detailed descriptions are optional 
for the Qt style. 

Here is the same piece of code, this time documented using the JavaDoc 
style:
\verbinclude jdstyle.cpp
 \htmlonly
 Click <a href="$(DOXYGEN_DOCDIR)/examples/jdstyle/html/class_test.html">here</a>
 for the corresponding HTML documentation that is generated by Doxygen.
 \endhtmlonly

Notice that the first sentence of the documentation (until the <tt>.</tt>) 
is treated as a brief description, whereas the documentation block as a whole 
forms the detailed description. The brief description is required for the 
JavaDoc style.

Unlike most other documentation systems, Doxygen also allows you to put
the documentation of members (including global functions) in front of 
the \e definition. This way the documentation can be placed in the source 
file instead of the header file. This keeps the header file compact, and allows the 
implementer of the members more direct access to the documentation.
As a compromise the brief description could be placed before the
declaration and the detailed description before the member definition
(assuming you use the Qt style comments).

\subsection structuralcommands Structural commands

So far we have assumed that the documentation blocks are always located in 
front of the declaration or definition of a file, class or namespace or in
front of one of its members. 
Although this is often comfortable, it may sometimes be better to put the 
documentation somewhere else. For some types of documentation blocks (like file
documentation) this is even required. Doxygen allows you to put your
documentation blocks practically anywhere (the exception is inside the body 
of a function or inside a normal C style comment block), as long as you put a 
structural command inside the documentation block.

Structural commands (like all other commands) start with a backslash 
(<tt>\\</tt>) followed by a command name and one or more parameters.
For instance, if you want to document the class \c Test in the example
above, you could have also put the following documentation block somewhere
in the input that is read by Doxygen:
\verbatim
/*! \class Test
    \brief A test class.

    A more detailed class description.
*/
\endverbatim

Here the special command \c \class is used to indicated that the
comment block contains documentation for the class \c Test.
Other structural commands are:
<ul>
<li>\c \struct to document a C-struct.
<li>\c \union to document a union.
<li>\c \enum to document an enumeration type.
<li>\c \fn to document a function.
<li>\c \var to document a variable or typedef or enum value.
<li>\c \def to document a \#define.
<li>\c \file to document a file.
<li>\c \namespace to document a namespace.
</ul>
See section \ref commands for detailed information about these and other 
commands. Notice that the documentation block belonging to a file 
should always contain a structural command.

To document a member of a C++ class, you must also document the class 
itself. The same holds for namespaces. To document a C function, typedef, 
enum or preprocessor definition you must first document the file that 
contains it (usually this will be a header file, because that file contains 
the information that is exported to other source files).

Here is an example of a C header named \c structcmd.h that is documented 
using structural commands:
\verbinclude structcmd.h
 \htmlonly
 Click <a href="$(DOXYGEN_DOCDIR)/examples/structcmd/html/structcmd.h.html">here</a>
 for the corresponding HTML documentation that is generated by Doxygen.
 \endhtmlonly

\par Notice:
  Because each comment block in the example above contains a structural command, all
  the comment blocks could be moved to another location or input file 
  (the source file for instance), without affecting the generated 
  documentation. The disadvantage of this approach is that prototypes are
  duplicated, so all changes have to be made twice!

\subsection memberdoc Documenting compound members.

If you want to document the members of a file, struct, union, class, or enum 
and you want to put the documentation for these members inside the compound,
it is sometimes desired to place the documentation block after the member 
instead of before. For this purpose Doxygen has the following 
additional comment blocks:
\verbatim
/*!< ... */
\endverbatim
This block can be used to put a qt style documentation blocks after a member.
The one line version look as follows:
\verbatim
//!< ...
\endverbatim
There are also JavaDoc versions:
\verbatim
/**< ... */
\endverbatim
and
\verbatim
///< ... 
\endverbatim
Notice that these blocks have the same structure and meaning as the 
special comment blocks above only the \< indicates that the member is 
located in front of the block instead of after the block.

Here is an example of a the use of these comment blocks:
\verbinclude afterdoc.h
 \htmlonly
 Click <a href="$(DOXYGEN_DOCDIR)/examples/afterdoc/html/class_test.html">here</a>
 for the corresponding HTML documentation that is generated by Doxygen.
 \endhtmlonly

\warning These blocks can only be used to document \e members.
         They cannot be used to document file classes, unions, structs and 
         enums. Furthermore, the structural commands mentioned in the 
         previous section are ignored inside these comment blocks.

\subsection formulas Including formulas in the documentation

Doxygen allows you to put \f$\mbox{\LaTeX}\f$ formulas in the
output (this works only for the HTML and \f$\mbox{\LaTeX}\f$ formats, 
not for the man page output). To be able to include formulas (as images)
in the HTML documentation, you will also need to have the following tools
installed
<ul>
<li>\c latex: the \f$\mbox{\LaTeX}\f$ compiler, needed to parse the formulas. 
    To test I have used the teTeX 0.4 distribution.
<li>\c dvips: a tool to convert dvi files to postscript files 
    I have used version 5.58f from Radical Eye software for testing.
<li>\c gs: the ghostscript interpreter for converting postscript files 
    to bitmaps. I have used Aladdin Ghostscript 5.01 for testing.
</ul>

There are two ways to include formulas in the documentation.
<ol>
<li>Using in-text formulas that appear in the running text. 
    These formulas should be put between a pair of \\f\$ 
    commands, so
\verbatim
  The distance between \f$(x_1,y_1)\f$ and \f$(x_2,y_2)\f$ is 
  \f$\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\f$.
\endverbatim results in:

  The distance between \f$(x_1,y_1)\f$ and \f$(x_2,y_2)\f$ is 
  \f$\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\f$.
<br>
<li>Unnumbered displayed formulas that are centered on a separate line.
    These formulas should be put between \\f\[ and \\f\] commands.
    An example:
\verbatim
  \f[
    |I_2|=\left| \int_{0}^T \psi(t) 
             \left\{ 
                u(a,t)-
                \int_{\gamma(t)}^a 
                \frac{d\theta}{k(\theta,t)}
                \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi
             \right\} dt
          \right|
  \f]
\endverbatim
  results in:
  \f[
    |I_2|=\left| \int_{0}^T \psi(t) 
             \left\{ 
                u(a,t)-
                \int_{\gamma(t)}^a 
                \frac{d\theta}{k(\theta,t)}
                \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi
             \right\} dt
          \right|
  \f]
</ol>
Formulas should be valid commands in \f$\mbox{\LaTeX}\f$'s math-mode.

\warning Currently, Doxygen is not very fault tolerant in recovering 
from typos in formulas. It may have to be necessary to remove the
file <code>formula.repository</code> that is written in the html directory to 
a rid of an incorrect formula

\subsection preprocessing Preprocessing

Source files that are used as input to doxygen can be parsed by doxygen's
build-in C-preprocessor.

By default doxygen does only partial preprocessing. That is, it 
evaluates conditional compilation statements (like \#if) and 
evaluates macro definitions, but it does not perform macro expansion.

So if you have the following code fragment
\verbatim
#define VERSION 200
#define CONST_STRING const char *

#if VERSION >= 200
  static CONST_STRING version = "2.xx";
#else
  static CONST_STRING version = "1.xx";
#endif
\endverbatim

Then by default doxygen will feed the following to its parser:

\verbatim
#define VERSION
#define CONST_STRING

  static CONST_STRING version = "1.xx";
\endverbatim

You can disable all preprocessing by setting \c ENABLE_PREPROCESSING to \c 
NO in the configuation file. In the case above doxygen will then read
both statements!

In case you want to expand the \c CONST_STRING macro, you should set the
\c MACRO_EXPANSION tag in the config file to \c YES. Then the result 
after preprocessing becomes:

\verbatim
#define VERSION
#define CONST_STRING

  static const char * version = "1.xx";
\endverbatim

Notice that doxygen will now expand \e all macro definitions 
(recursively if needed). This is often too much. Therefore, doxygen also 
allows you to expand only those defines that you explicitly 
specify. For this you have to set the \c EXPAND_ONLY_PREDEF tag to \c YES
and specify the macro definitions after the \c PREDEFINED tag.  

As an example, suppose you have the following obfusciated code fragment
of an abstract base class called \c IUnknown:

\verbatim
/*! A reference to an IID */
#ifdef __cplusplus
#define REFIID const IID &
#else
#define REFIID const IID *
#endif

/*! The IUnknown interface */
DECLARE_INTERFACE(IUnknown)
{
  STDMETHOD(HRESULT,QueryInterface) (THIS_ REFIID iid, void **ppv) PURE;
  STDMETHOD(ULONG,AddRef) (THIS) PURE;
  STDMETHOD(ULONG,Release) (THIS) PURE;
};
\endverbatim

without macro expansion doxygen will get confused, but we may not want to 
expand the REFIID macro, because it is documented and the user that reads 
the documentation should use it when implementing the interface.

By setting the following in the config file:

\verbatim
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION      = YES
EXPAND_ONLY_PREDEF   = YES
PREDEFINED           = "DECLARE_INTERFACE(name)=class name" \
                       "STDMETHOD(result,name)=virtual result name" \
                       "PURE= = 0" \
                       THIS_= \
                       THIS= \
		       __cplusplus
\endverbatim

we can make sure that the proper result is fed to doxygen's parser:
\verbatim
/*! A reference to an IID */
#define REFIID

/*! The IUnknown interface */
class  IUnknown
{
  virtual  HRESULT   QueryInterface ( REFIID iid, void **ppv) = 0;
  virtual  ULONG   AddRef () = 0;
  virtual  ULONG   Release () = 0;
};
\endverbatim

Notice that the \c PREDEFINED tag accepts function like macro definitions
(like \c DECLARE_INTERFACE), normal macro substitutions (like \c PURE
and \c THIS) and plain defines (like \c __cplusplus).

Notice also that preprocessor definitions that are normally defined 
automatically by the preprocessor (like \c __cplusplus), have to be defined 
by hand with doxygen's parser (this is done because these defines
are often platform/compiler specific).

In some cases you may want to substitute a macro name or function by 
something else without exposing the result to further macro substitution.
You can do this but using the <code>:=</code> operator instead of 
<code>=</code>

As an example suppose we have the following piece of code:
\verbatim
#define QList QListT
class QListT
{
};
\endverbatim

Then the only way to get doxygen interpret this as a class definition
for class QList is to define:
\verbatim
PREDEFINED = QListT:=QList
\endverbatim

As you can see doxygen's preprocessor is quite powerful, but if you want
even more flexibility you can always write an input filter and specify it on 
the \c INPUT_FILTER flag.

\subsection moreinfo More information

\addindex QdbtTabular
For a more elaborate example see <a href="http://www.stack.nl/~dimitri/qdbttabular/html/index.html">
the documentation of QdbtTabular</a> \latexonly 
({\tt http://www.stack.nl/$\sim$dimitri/qdbttabular/html})\endlatexonly.
\htmlonly
I hope that was clear. If not, please let me know, so I can improve this document. If you have problems 
take a look at the <a href="faq.html">faq</a> and the <a href="trouble.html">troubleshooting</a> sections. 
\endhtmlonly

*/