Document Functions Defined by a Macro in Doxygen

I have a class that does not actually exist, but is defined using a macro:

#define DEFCLASS(name,datatype) Class name { \
    public: \
        void clear(); \
        datatype obj; \
    };
DEFMETHOD(StringContainer, const char*)

...

StringContainer foo("hi!");

Of course, this should have been implemented using templates, but I did not write it, I can’t change it, and its large base is based on it.

Now the question is, what would I like to document StringContainer in doxygen. However, this is not a class that really exists, so if I do this:

/*!
    \class StringContainer
    \brief A string container

    \fn void StringContainer::clear()
    \brief Clears the container
*/

I get warnings from oxygen:

warning: documented function `StringContainer::clear' was not declared or defined.

And the documentation does not contain this function. I know this is a bit complicated, but is there a way to get doxygen to have “faith” and create documentation for StringContainer, although it is not defined in the source code?

Decision

.h, doxygen , , . .dox. , .dox, :

class StringContainer {
public:
    /*! Removes the contents of the container. */
    void clear();
    const char *obj;
};

, StringContainer.

+5
3

, , "EXPAND_AS_DEFINED" . Doxygen :

EXPAND_AS_DEFINED = DEFCLASS

, , "DEFCLASS", Doxygen. (.. , "STDMETHOD", , , , "STDMETHOD" Doxygen)

VS 2010 , Doxygen .

:

Base.h:

#pragma once

#define DEFCLASS(name,datatype) class name { \
    public: \
        name(){} \
        void clear(){}; \
        datatype obj; \
    };

DEFCLASS(StringContainer, const char*)


/*!
    \class StringContainer
    \brief A string container

    \fn void StringContainer::clear()
    \brief Clears the container
*/

Base.cpp:

#include "Base.h"

int main()
{
    StringContainer foo;
    foo.clear();


    return 0;
}

DoxygenTest.doxygen

MACRO_EXPANSION        = YES
EXPAND_ONLY_PREDEF     = YES
EXPAND_AS_DEFINED      = DEFCLASS
+4

MACRO_EXPANSION "yes" doxygen (http://www.star.bnl.gov/public/comp/sofi/doxygen/config.htm). doxygen "" StringContainer.

+1

doxygen: http://www.doxygen.org/preprocessing.html. , , DECLARE_INTERFACE STDMETHOD, , .

Thus, this may be an alternative solution if you do not want to write a dummy class in a separate file.

0
source

All Articles