doxygen:使用宏定义命名空间时,在CPP文件中使用单独的源和标头目录的类记录类

发布于 2025-01-21 17:02:39 字数 1752 浏览 1 评论 0原文

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

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

doxyfile:

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

如果我执行以下任何操作,它有效:

  • 将CPP移至include/。但是我不想在那里。
  • 将文档移至标题。但是我想简短。
  • 名称空间mylibns {而不是CPP中的宏。但是我希望名称空间可配置。
  • macro_expansion = no。但这也将从文档中删除命名空间。
  • 在doxygen注释中明确说明名称空间:\ class mylibns :: SomeClass。但是,这只有助于解决此特定问题(Doxygen也无法解决过载功能)。

没有帮助的事情:

  • 输入参数指定更长路径的任何组合。
  • extract_all = yes
  • clang_assisted_pa​​rsing = yes

我如何正确执行此操作?

I'm trying to document a library with the following files:

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

Doxyfile:

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

Doxygen produces the following warning:

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

If I do any of the following, it works:

  • Move the cpp to include/. But I don't want it there.
  • Move the documentation to the header. But I'd like to keep it short.
  • namespace mylibns { instead of the macro in the cpp. But I want the namespace to be configurable.
  • MACRO_EXPANSION = NO. But that would also remove the namespace from the documentation.
  • Explicitly state the namespace in the doxygen comment: \class mylibns::SomeClass. However that only helps with this specific issue (doxygen also fails to resolve overloaded functions).

Things that don't help:

  • Specifying any combination of longer paths for the INPUT parameter.
  • EXTRACT_ALL = YES
  • CLANG_ASSISTED_PARSING = YES

How do I do this properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命硬 2025-01-28 17:02:39

在文件source/someclass.cpp中,您有:

#include "mylib/SomeClass.h"

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

INCLUDE_PATH = include

类似于您可能为编译器所做的用-i include(例如)的设置所做的事情)

In the file source/SomeClass.cpp you have:

#include "mylib/SomeClass.h"

but the file SomeClass.h is located in include/mylib so you have to tell doxygen where to find the include file. This can be done by means of the setting:

INCLUDE_PATH = include

(analogous what you probably have done for the compiler with the setting like -I include)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文