使用doxygen分别提取类的公共方法列表

Extract the list of public methods of a class separately using Doxygen

本文关键字:方法 列表 doxygen 提取 使用      更新时间:2023-10-16

我正在为我的C 项目使用doxygen,该项目将托管在github中。

我想在读书文件中包含类的方法列表,我正在考虑自动化它的方法。

我将在存储库中包含整个生成的HTML页面,但认为通过在readme文件中包括主类的成员来给出API的想法。

到目前为止,我找不到生成降价文件的方法。我的下一个想法是编写一些将自动复制成员列表并将其包含在readme文件中的shell脚本,为此,我需要分别生成类的成员函数列表。

是否可以配置doxygen只能单独输出类的成员列表?

我最近有一个项目,我想将几个功能识别为公共API的一部分。我觉得不需要将它们放入读数文件中,所以我所做的并不是您真正追求的,而是您可能会发现它潜在的妥协。

我创建了一个与:

的组
/**
defgroup public_api Public API
brief This is a list of the primary functions that comprise the
public API.
*/

然后我在主页上引用了它:

/**
mainpage Some Project
...
See ref public_api "Public API" for details on these functions.
*/

然后,我明确将每个公共API函数标记为该组。

/**
brief Perform any necessary initialisation before processing.
ingroup public_api
This function must be called prior to any of the other public
api functions to allow initialisation to be performed prior to use.

 */
void init();

网络结果是单个页面上从主页链接到的函数的列表。我知道这并不是您所追求的,但是我有点像Doxygen将所有文档都带入一个易于导航的地方。

如果您确实解决了问题以满意,请发布。我一直对doxygen的非典型用途感兴趣。

您可以从doxygen XML输出中提取类成员列表。将GENERATE_XML设置为配置文件中的YES,生成看起来像这样的XML文件:

xml/classtest.xml

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.7.6.1">
<compounddef id="classTest" kind="class" prot="public">
<compoundname>Test</compoundname>
  <sectiondef kind="public-func">
      <memberdef kind="function" id="classTest_1a99f2bbfac6c95612322b0f10e607ebe5" 
         prot="public" static="no" const="no" 
         explicit="no" inline="no" virt="non-virtual">
         <type></type>
         <definition>Test::Test</definition>
         <argsstring>()</argsstring>
         <name>Test</name>
         <briefdescription>  </briefdescription>
         <detaileddescription>
               <para>A constructor. A more elaborate description of the constructor. </para>        
         </detaileddescription>
         <inbodydescription>  </inbodydescription>
        <location file="/home/davidl/SO/test.cpp" line="23"/>
      </memberdef>
  </sectiondef>
</compounddef>
</doxygen>