Doxygen:在使用宏定义名称空间的同时,在 cpp 文件中使用单独的源目录和头目录记录 class

Doxygen: document a class in the cpp file with separate source and header directories while using macros to define namespaces

我正在尝试使用以下文件记录库:

include/mylib/mylib_global.h
include/mylib/SomeClass.h
source/SomeClass.cpp
Doxyfile

include/mylib/mylib_global.h:

#pragma once
#define MYLIB_NAMESPACE_BEGIN namespace mylibns {
#define MYLIB_NAMESPACE_END   }

include/mylib/SomeClass.h:

#pragma once
#include "mylib_global.h"

MYLIB_NAMESPACE_BEGIN

class SomeClass
{
public:
    SomeClass();
};

MYLIB_NAMESPACE_END

source/SomeClass.cpp:

#include "mylib/SomeClass.h"

MYLIB_NAMESPACE_BEGIN

/*!
 * \class SomeClass
 * This is a sample class.
 */

/*!
 * This is a constructor.
 */
SomeClass::SomeClass()
{
}

MYLIB_NAMESPACE_END

Doxy文件:

PROJECT_NAME = mylib
INPUT = .
RECURSIVE = YES
MACRO_EXPANSION = YES

Doxygen 产生以下警告:

Doxygen version used: 1.9.3 (c0b9eafbfb53286ce31e75e2b6c976ee4d345473)
[...]
include/mylib/SomeClass.h:7: warning: Compound mylibns::SomeClass is not documented.
*** Doxygen has finished

如果我执行以下任一操作,它就会起作用:

没有帮助的事情:

如何正确执行此操作?

在文件 source/SomeClass.cpp 中你有:

#include "mylib/SomeClass.h"

但是文件 SomeClass.h 位于 include/mylib 中,因此您必须告诉 doxygen 在哪里可以找到包含文件。这可以通过设置来完成:

INCLUDE_PATH = include

(类似于您可能为编译器所做的类似设置 -I include