在 table 中收集代码内的所有特定评论

Collect all specific comments inside code in a table

假设我有一个记录器函数,我在我的代码中调用了它。我的日志通常会显示问题或错误存在的可能性。需要更多的行动和调查来确认问题或错误。例如,维护人员或测试人员应该抓取输入,在编辑器中打开它,如果输入中包含特定字符串,则问题或错误得到确认。

我想在代码的日志功能上面的注释中记录确认错误的过程。我还想提取所有这些类型的评论并从中创建,比如 HTML table。所以我可以将 table 交给测试人员或维护人员,让他们为我找到正确的错误。

我用一个简单的代码来展示它。我知道这很愚蠢,但确实有效:

std::ifstream t("file.txt");
std::string input;
// Read the whole file into input string

// DIAGNOSTICS COMMENT
// NOHELLO_BUG
// Diagnostics steps: 1.Open input file file.txt 2. Search hello inside the file, if hello exists inside the file, there should be a bug, send file.txt to the developer!
if (input.find("hello") == std::string::npos)
{
   logger::log("hello not found inside input file!");
   return false;
}

Doxygen 中是否有用于此目的的任何命令,尽管也欢迎任何其他解决方案。最明显的方法是自己编写 table,但是维护 table 也将是一场灾难。

Doxygen 含有 a.o。命令 \todo\bug

来自文档:

\todo { paragraph describing what is to be done }

Starts a paragraph where a TODO item is described. The description will also add an item to a separate TODO list. The two instances of the description will be cross-referenced. Each item in the TODO list will be preceded by a header that indicates the origin of the item.

\bug { bug description }

Starts a paragraph where one or more bugs may be reported. The paragraph will be indented. The text of the paragraph has no special internal structure. All visual enhancement commands may be used inside the paragraph. Multiple adjacent \bug commands will be joined into a single paragraph. Each bug description will start on a new line. Alternatively, one \bug command may mention several bugs.

此外,doxygen 包含命令 \xreflist,您可以使用它来定义自己的列表。

文档的小节选 (https://www.doxygen.nl/manual/commands.html#cmdxrefitem):

\xrefitem "(heading)" "(list title)" { text }

This command is a generalization of commands such as \todo and \bug. It can be used to create user-defined text sections which are automatically cross-referenced between the place of occurrence and a related page, which will be generated. On the related page all sections of the same type will be collected.

The first argument is an identifier uniquely representing the type of the section. The second argument is a quoted string representing the heading of the section under which text passed as the fourth argument is put. The third argument (list title) is used as the title for the related page containing all items with the same key. The keys "todo", "test", "bug" and "deprecated" are predefined.