如何正确格式化类实例引用

How to properly format a class instance reference

本文关键字:实例 引用 格式化 何正确      更新时间:2023-10-16

我有这篇文档:

 /**
 * This method creates an import job for the given @arg item
 *
 * The default implementation should be suitable for most needs,
 * it'll create an instance of @class ImportProjectJob
 *
 * @return a job that imports the project
 */
virtual KJob* createImportJob(ProjectFolderItem* item);

然而,@class并不意味着要这样使用,并且在doxygen中没有类似@instanceof的东西。我应该如何格式化这个?

根据Doxygen的自动链接生成规则,如果某些文档文本与已记录的类的名称匹配,并且该文本使用interCaps命名样式,则Doxygen将自动将该文本转换为指向该文档页面的链接。因此,如果你只使用"ImportProjectJob",Doxygen会找到那个类(如果它已经被文档化的话),并将文本转换为指向它的链接

但是,如果您的类/函数不使用interCaps命名,则可以通过@ref:显式链接到文档实体

 * The default implementation should be suitable for most needs,
 * it'll create an instance of @ref ImportProjectJob

仅供参考:@arg用于启动函数参数定义列表。类似于:

@arg @c AlignLeft left alignment.
@arg @c AlignCenter center alignment.
@arg @c AlignRight right alignment

您要查找的是@p,它是用于引用参数名称等的内联格式。

只需使用@ref而不是@class,并记录声明它的类。

通常(默认情况下,即AUTOLINK_SUPPORTYES时),甚至不需要显式引用它。Doxygen在检测到名称时会自动链接它。

顺便说一下,您对@arg的使用并不像预期的那样。将@p用于内联引用,将@param用于记录方法参数。


 /**
  * @brief This method creates an import job for the given @p item
  *
  * @details The default implementation should be suitable for most needs,
  *   it'll create an instance of ImportProjectJob
  *
  * @param item this is a folder item
  *
  * @return a job that imports the project
  */
 virtual KJob* createImportJob(ProjectFolderItem* item);

这就是声明CCD_ 13的地方:

 /**
  * @brief short desc of the class
  * 
  * @details A long description
  */
 class ImportProjectJob : public KJob
 {};