Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen not documenting main function in main.cpp

Tags:

c++

main

doxygen

I have a main.cpp that contains a struct, some global constants and a main function.

I ran doxygen and the only documentation I am getting in the output index.html is for my struct.

I want doxygen to document into that index.html file my main() as well. What am I doing incorrectly?

    /// Definition of Pi
    const auto Pi = 3.141592653589793238462643383279502884197169399;

    /// \struct myStruc
    /// \brief myStruc description
    ///
    struct myStruc
    {
         /// Comments inside myStruc
    };

    /// \file

    /// \brief  Main function
    /// \param  argc An integer argument count of the command line arguments
    /// \param  argv An argument vector of the command line arguments
    /// \return an integer 0 upon exit success
    int main(int argc, char** argv)
    {
        /// Comments I would like to be documented in as well
        return 0;
    }
like image 287
user1496542 Avatar asked Aug 20 '12 16:08

user1496542


2 Answers

This is because you are documenting a global object which doxygen, by default, does not document. From the doxygen manual (emphasis mine):

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 */ 

or a

/** @file */ 

line in this file.

So try adding one of the above two lines to your main.cpp file.

like image 64
Chris Avatar answered Oct 13 '22 22:10

Chris


Make sure HIDE_IN_BODY_DOCS is set to NO and use something like this:

/// \file

/// \brief  Main function
/// \param  argc An integer argument count of the command line arguments
/// \param  argv An argument vector of the command line arguments
/// \return an integer 0 upon exit success
int main(int argc, char** argv)
{
  /// Comments I would like to be documented in as well
  return 0;
}
like image 21
doxygen Avatar answered Oct 13 '22 22:10

doxygen