문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
develop:doc:doxygen:docblocks [2011/07/19 09:55] starlits |
develop:doc:doxygen:docblocks [2011/07/19 11:59] (현재) starlits |
||
---|---|---|---|
줄 54: | 줄 54: | ||
/// 지금부터 처리됩니다. | /// 지금부터 처리됩니다. | ||
</ | </ | ||
- | - A third option is to use a special | + | - 세번째 옵션은 하나이상의 라인을 스펜(span)하지 않는 특별한 |
/// Brief description. | /// Brief description. | ||
/** Detailed description. */ | /** Detailed description. */ | ||
줄 62: | 줄 62: | ||
//! Detailed description | //! Detailed description | ||
//! starts here. | //! starts here. | ||
- | </ | + | </ |
- | ==== 주의사항 | + | ==== 부가설명 |
- | - As you can see doxygen | + | - doxygen는 매우 유연한 프로그램이다. 다중상세설명을 원한다면, |
//! Brief description, | //! Brief description, | ||
//! really a detailed description since it spans multiple lines. | //! really a detailed description since it spans multiple lines. | ||
줄 71: | 줄 71: | ||
*/ | */ | ||
</ | </ | ||
- | + | - They will be joined. Note that this is also the case if the descriptions are at different places in the code! In this case the order will depend on the order in which doxygen parses | |
- | + | - Qt 스타일을 이용하여 | |
- | Furthermore, | + | |
- | + | ||
- | Here is an example of a documented piece of C++ code using the Qt style: < | + | |
//! A test class. | //! A test class. | ||
/*! | /*! | ||
줄 140: | 줄 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: < | + | |
/** | /** | ||
| | ||
줄 219: | 줄 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 ===== | ||
줄 242: | 줄 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 */ | ||
줄 267: | 줄 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. | ||
줄 280: | 줄 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. | ||
줄 293: | 줄 276: | ||
\package to document a Java package. | \package to document a Java package. | ||
\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). | ||
+ | - 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 */ | ||
</ | </ | ||
+ | - Here is an example of a C header named structcmd.h that is documented using structural commands: | ||
+ | /*! \file structcmd.h | ||
+ | \brief A Documented file. | ||
+ | | ||
+ | Details. | ||
+ | */ | ||
+ | /*! \def MAX(a,b) | ||
+ | \brief A macro that returns the maximum of \a a and \a b. | ||
+ | |||
+ | Details. | ||
+ | */ | ||
+ | /*! \var typedef unsigned int UINT32 | ||
+ | \brief A type definition for a . | ||
+ | | ||
+ | Details. | ||
+ | */ | ||
+ | |||
+ | /*! \var int errno | ||
+ | \brief Contains the last error code. | ||
+ | |||
+ | \warning Not thread safe! | ||
+ | */ | ||
+ | |||
+ | /*! \fn int open(const char *pathname, | ||
+ | \brief Opens a file descriptor. | ||
+ | |||
+ | \param pathname The name of the descriptor. | ||
+ | \param flags Opening flags. | ||
+ | */ | ||
+ | |||
+ | /*! \fn int close(int fd) | ||
+ | \brief Closes the file descriptor \a fd. | ||
+ | \param fd The descriptor to close. | ||
+ | */ | ||
+ | |||
+ | /*! \fn size_t write(int fd,const char *buf, size_t count) | ||
+ | \brief Writes \a count bytes from \a buf to the filedescriptor \a fd. | ||
+ | \param fd The descriptor to write to. | ||
+ | \param buf The data buffer to write. | ||
+ | \param count The number of bytes to write. | ||
+ | */ | ||
+ | |||
+ | /*! \fn int read(int fd,char *buf,size_t count) | ||
+ | \brief Read bytes from a file descriptor. | ||
+ | \param fd The descriptor to read from. | ||
+ | \param buf The buffer to read into. | ||
+ | \param count The number of bytes to read. | ||
+ | */ | ||
+ | |||
+ | #define MAX(a,b) (((a)> | ||
+ | typedef unsigned int UINT32; | ||
+ | int errno; | ||
+ | int open(const char *,int); | ||
+ | int close(int); | ||
+ | size_t write(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. | ||
+ | |||
+ | |||
+ | ===== TIP ===== | ||
+ | - 가끔 클래스 링크가 생성되지 않을 때가 있습니다. \\ (예 : 템플릿내에서 해당 맴버를 참조할 경우 맴버에서는 자동으로 해당 템플릿 함수, 클래스의 링크는 생성되지 않습니다) \\ 이럴때에는 @ref 명령으로 강제로 링크를 설정할 수 있습니다. \\ (이때 주의할 점은 반드시 링크가 존재해야합니다) \\ 강제로 주석중에 참조링크를 넣고 싶을때도 좋습니다. \\ 이때 링크는 클래스명이 적당할 것입니다. < | ||
+ | /** | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | */ | ||
+ | </ | ||
+ | - 주석 블럭안에 C/C++ 예제 소스코드를 넣고 싶다면 @code ... @endcode 로 소스를 감싸주면 됩니다. | ||