简体   繁体   中英

How to use doxygen to copy documentation from a non-exported c++ class

i am trying to document a C++ project that is composed like this:

I have class A with a lot of documented code with doxygen.

Then i create via a wrapper script a new class B that uses class A and exposes just a few of A's public methods in a 1-to-1 way:

A.h
---
class A {
public:
 /*! 
 * \brief Awesomw A method
 *  This method will be used in B
 */
 void someAfunc();
}


B.h
----
class A;
class B {
private:
 A *m_pA;
public:
 void someAfunc();
}

B.cpp
-----
#include <A.h>
#include <B.h>
/*!
\copydoc A::someAfunc() 
*/
void B::someAfunc()
{
   m_pA->someAfunc();
}

If i run doxygen i can get the documentation for both classes A and B with the same content for someAfunc() method,

What i am trying to do is to not generate doxygen documentation for class A.

If i try to use EXCLUDE_SYMBOLS i will just get the class B generated but unfortunately the someAfunc() will not be documented.

I am using doxygen 1.9.1 on Linux

Interesting question, though a bit uncommon way of providing methods (I think).

There is no real simple way to accomplish this, but digging a bit in my box of tricks and for the provided example:

Ah

class A {
public:
 /*
  * [A_someAfunc_brief]
  Awesome A method.
  * [A_someAfunc_brief]
  *
  * [A_someAfunc]
  This method will be used in B
  * [A_someAfunc]
 */

 /*!
  * \brief
  * \snippet{doc} A.h  A_someAfunc_brief
  *
  * \snippet{doc} A.h  A_someAfunc
 */
 void someAfunc();
}

B.cpp

#include <A.h>
#include <B.h>
/*!
 * \brief
 * \snippet{doc} A.h  A_someAfunc_brief
 *
 * \snippet{doc} A.h  A_someAfunc
*/
void B::someAfunc()
{
   m_pA->someAfunc();
}

Doxyfile

EXCLUDE_SYMBOLS=A
QUIET=YES
EXAMPLE_PATH=.

I first wanted to go for:

 /*
  * [A_someAfunc]
  \brief Awesome A method.

  This method will be used in B
  * [A_someAfunc]
 */

but this gave some problems with the \brief command due to the moment of processing the snippet{doc} and \brief commands. I also looked at the possibility:

 /*!
  * \brief
  * [A_someAfunc]
  Awesome A method.

  This method will be used in B
  * [A_someAfunc]
 */

but this gave some problems with the [...] part in the class A when this was included.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM