Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 25 and Version 26 of code/C++_styleguide


Ignore:
Timestamp:
Sep 21, 2008, 8:42:55 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/C++_styleguide

    v25 v26  
    134134
    135135== Comments ==
    136 
    137 === Introductory Comment ===
    138 Every file that contains source code must be documented with an introductory comment that provides information on the file name and its contents:
    139 {{{
    140 /**
    141 @file
    142 @brief
    143     A brief description.
    144 
    145     More description... (new paragraph after @brief)
    146 */
    147 }}}
    148 Note: try not to fill in the filename. It is obvious and the comment compiler (Doxygen) will do it automatically and you don't have to adjust it when renaming the file.
    149 
    150 === Classes ===
    151 In the header file, just above the class declaration, explain what the class does and where it is used. You could even add an example if it helps understanding the class.
    152 {{{
    153 /**
    154 @brief
    155     A brief description.
    156     More brief description.
    157 
    158     Details follow here.
    159     Maybe an example or something.
    160 */
    161 class ClassName
    162 {
    163     ...
    164 }}}
    165 
    166 === Class Members ===
    167 Add a brief description to every member of a class:
    168 {{{
    169     private:
    170         int value_;           //!< A brief description
    171         int longerValueName_; //!< A brief description
    172 }}}
    173 The < after //! indicates that the member is located in front of the comment instead of after the comment.
    174 
    175 If you need a more detailed description, use:
    176 {{{
    177     private:
    178         int value_; //!< A detailed description
    179                     //!< More detailed description
    180                     //!< ...
    181 }}}
    182 or
    183 {{{
    184     private:
    185         int value_; /**<
    186                         A detailed description
    187                         More detailed description
    188                         ...
    189                     */
    190 }}}
    191 
    192 === Functions ===
    193 Doxygen documentation (javadoc like for C++) is placed in the source file, just above the function header. If the function is inline, place the comment there but keep it short. [[br]]
    194 When writing documentation in the source file don't make it all jam-packed to enhance readability. Here is an example to demonstrate formatting:
    195 {{{
    196 /**
    197 @brief
    198     A brief description.
    199     More brief description.
    200 
    201     Details follow here.
    202     Maybe an example or something.
    203 @param param1
    204     Parameter description for parameter named 'param1'
    205 @param param2
    206     Parameter description for parameter named 'param2'
    207 @return
    208     Describe what the function returns
    209 @note
    210     Something important to remember.
    211 @author
    212     The mighty whoever
    213 */
    214 returntype functionname(type1 param1, type2 param2)
    215 {
    216     ...
    217 }}}
    218 
    219 === Inline Functions ===
    220 Inline functions need documentation as well, but we don't want a messy headerfile. Keep the comments short and put all doxygen code on one line:
    221 {{{
    222 /** @brief A brief description. @param param1 description [...] @return description */
    223 inline returntype functionname(type1 param1 [, ...]) { ... }
    224 }}}
     136Comment your code and add [wiki:Doxygen] Comments to all files, classes, structs, functions and member variables.[[br]]
     137Read [wiki:Doxygen this] to learn more about Doxygen.
    225138
    226139----