문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
develop:doc:doxygen:docblocks [2011/07/19 10:24] starlits |
develop:doc:doxygen:docblocks [2011/07/19 11:59] (현재) starlits |
||
---|---|---|---|
줄 137: | 줄 137: | ||
int (*handler)(int a,int b); | int (*handler)(int a,int b); | ||
}; | }; | ||
- | </ | + | </ |
- | + | - 멀티 라인 주석 블록에 대한 자세한 설명을 포함하는 반면 한 라인 주석은 간단한 설명이 포함되어 있습니다. | |
- | + | - 간략설명(brief descriptions)은 class, namespace, file 의 멤버 개요가 포함되어 있으며 작은 기울임꼴 글꼴을 사용하여 인쇄됩니다 | |
- | The one-line comments contain a brief description, | + | - 기본적으로 |
- | + | ||
- | + | ||
- | The brief descriptions | + | |
- | + | ||
- | + | ||
- | By default a JavaDoc | + | |
/** Brief description (e.g.\ using only a few words). Details follow. */ | /** Brief description (e.g.\ using only a few words). Details follow. */ | ||
</ | </ | ||
- | + | - Here is the same piece of code as shown above, this time documented using the JavaDoc style and JAVADOC_AUTOBRIEF set to YES: < | |
- | Here is the same piece of code as shown above, this time documented using the JavaDoc style and JAVADOC_AUTOBRIEF set to YES: < | + | |
/** | /** | ||
| | ||
줄 216: | 줄 209: | ||
int (*handler)(int a,int b); | int (*handler)(int a,int b); | ||
}; | }; | ||
- | </ | + | </ |
- | + | - 대부분의 다른 문서와 달리 | |
- | + | ||
- | Unlike most other documentation systems, | + | |
===== Putting documentation after members ===== | ===== Putting documentation after members ===== | ||
줄 239: | 줄 230: | ||
int var; ///< Brief description after the member | int var; ///< Brief description after the member | ||
</ | </ | ||
- | + | - Note that these blocks have the same structure and meaning as the special comment blocks in the previous section only the < indicates that the member is located in front of the block instead of after the block. | |
- | Note that these blocks have the same structure and meaning as the special comment blocks in the previous section only the < indicates that the member is located in front of the block instead of after the block. | + | |
- | + | ||
- | Here is an example of the use of these comment blocks: < | + | |
/*! A test class */ | /*! A test class */ | ||
줄 264: | 줄 253: | ||
==== 주의사항 ==== | ==== 주의사항 ==== | ||
- | These blocks can only be used to document members and parameters. They cannot be used to document files, classes, unions, structs, groups, namespaces and enums themselves. Furthermore, | + | - These blocks can only be used to document members and parameters. They cannot be used to document files, classes, unions, structs, groups, namespaces and enums themselves. Furthermore, |
===== Documentation at other places ===== | ===== Documentation at other places ===== | ||
- | 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 or after one of its members. Although this is often comfortable, | + | - 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 or after one of its members. Although this is often comfortable, |
- | + | | |
- | uctural commands (like all other commands) start with a backslash (\), or an at-sign (@) if you prefer JavaDoc style, followed by a command name and one or more parameters. For instance, if you want to document the class Test in the example above, you could have also put the following documentation block somewhere in the input that is read by doxygen: < | + | |
/*! \class Test | /*! \class Test | ||
\brief A test class. | \brief A test class. | ||
줄 277: | 줄 265: | ||
*/ | */ | ||
</ | </ | ||
- | + | - Here the special command \class is used to indicate that the comment block contains documentation for the class Test. Other structural commands are: < | |
- | + | ||
- | Here the special command \class is used to indicate that the comment block contains documentation for the class Test. Other structural commands are: < | + | |
\struct to document a C-struct. | \struct to document a C-struct. | ||
\union to document a union. | \union to document a union. | ||
줄 291: | 줄 277: | ||
\interface to document an IDL interface. | \interface to document an IDL interface. | ||
</ | </ | ||
- | + | - To document a member of a C++ class, you must also document the class itself. The same holds for namespaces. To document a global 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). | |
- | + | | |
- | To document a member of a C++ class, you must also document the class itself. The same holds for namespaces. To document a global 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). | + | |
- | + | ||
- | + | ||
- | + | ||
- | Let's repeat that, because it is often overlooked: to document global objects (functions, typedefs, enum, macros, etc), you must document the file in which they are defined. In other words, there must at least be a < | + | |
/*! \file */ | /*! \file */ | ||
</ | </ | ||
/** @file */ | /** @file */ | ||
</ | </ | ||
- | + | - Here is an example of a C header named structcmd.h that is documented using structural commands: | |
- | Here is an example of a C header named structcmd.h that is documented using structural commands: | + | |
/*! \file structcmd.h | /*! \file structcmd.h | ||
\brief A Documented file. | \brief A Documented file. | ||
줄 362: | 줄 342: | ||
int read(int, | int read(int, | ||
</ | </ | ||
- | + | - 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! Because of this you should first consider if this is really needed, and avoid structural commands if possible. I often receive examples that contain \fn command in comment blocks which are place in front of a function. This is clearly a case where the \fn command is redundant and will only lead to problems. | |
- | 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! Because of this you should first consider if this is really needed, and avoid structural commands if possible. I often receive examples that contain \fn command in comment blocks which are place in front of a function. This is clearly a case where the \fn command is redundant and will only lead to problems. | + | |