如何使用Doxygen记录在不同文件中声明的属性?

问题描述 投票:1回答:2

我使用mogenerator生成Core Data类。 Mogenerator生产机器类和人类。开发人员不应该修改机器生成的类,因为每次调用mogenerator时都会生成这些类。但是,可以根据开发人员的喜好修改人类。

机器类包含Core Data实体的每个属性的声明。在Doxygen中,如何从文件B中记录文件A中定义的属性?

编辑:添加示例来说明问题

例:

最终,这里的目标是与下面的例子类似。

FileA.h(无法修改)

@interface FileA : NSObject
{
   NSString* myProperty;
}
@end

Phelabaha

#include "FileA.h"

@interface FileB : FileA
{
   /**
    * @property myProperty
    *
    * This is the documentation of "myProperty" 
    * defined in FileA but documented in FileB
    */
}
@end

尝试(@interface FileB @end bock中的文档块):

@property myProperty - Doxygen没有将文档与属性相关联。

\ property myProperty - Doxygen没有将文档与属性相关联。

@property FileA :: myProperty - Doxygen没有将文档与属性相关联并生成;警告:没有为FileB :: myProperty找到唯一匹配的类成员

\ property FileA :: myProperty - 我要去

Phelabaha

#include "FileA.h"

   /**
    * @property FileA::myProperty
    *
    * This is the documentation of "myProperty" 
    * defined in FileA but documented in FileB
    *
    * Documentation block MUST BE outside FileB class
    *
    */

@interface FileB : FileA
{
}
@end
objective-c documentation doxygen documentation-generation mogenerator
2个回答
1
投票

我不清楚(对我来说)你是否想要记录FileA,但你不能将文档插入FileA.h,或者如果你想要FileA没有文档,但是它的成员出现在(记录的)派生类FileB中。

如果它是前者,你可以在FileA中提供类FileB.h的文档,这将显示如下:

/**
 * @class FileA
 * Documentation for FileA
 *
 * @var FileA::myProperty
 * Documentation for myProperty
 */

/**
 * Documentation for FileB
 */
@interface FileB : FileA
{
}

@end

这将导致类FileAFileB出现在生成的文档中,myProperty被记录为FileA的成员。

如果是后者,您可以将myProperty声明为FileB的成员,但是在生成文档时使用预处理器防护仅包含声明,例如:

/**
 * document FileB
 */
@interface FileB : FileA
{
#ifdef DOXYGEN
    /**
     * This is the documentation of "myProperty" 
     * defined in FileA but documented in FileB
     */
    NSString* myProperty;
#endif
}

@end

这将导致FileB被记录,好像myProperty是其成员之一。请注意,如果myPropertyFileA声明发生变化,您必须手动更新FileB的声明以反映这些变化。


0
投票

您可以使用Doxygen的ref命令引用achor(例如文件,命名空间,类,函数,变量,枚举等),例如

\ref variable_name

如果要记录的变量不在本地名称空间或作用域中,则可以在变量名前加上namespace::,其中namespace是定义所引用变量的作用域或类。例如,请考虑以下两个文件(根据Doxygen手册中的示例进行修改):

档案1:

///  A test class.
/**
  A more elaborate class description.
*/
class Test
{
  public:

  /// An enum.
  /** More detailed enum description. */
  enum TEnum {
               TVal1, ///< Enum value TVal1.
               TVal2, ///< Enum value TVal2.
               TVal3  ///< Enum value TVal3.
             }
      /// Enum pointer.
      /** Details. */
      *enumPtr,
      /// Enum variable.
      /** Details. */
      enumVar;

  /// A constructor.
  /**
    A more elaborate description of the constructor.
  */
  Test();
};

文件2:

//  Another test class.
/**
  This class depends on the variable \ref Test::TEnum, defined in another file.
  It doesn't, actually, but I've said it does.
*/
class AnotherTest
{
  public:

  /// A constructor
  AnotherTest();

};

这里TEnum在第一个文件中的类Test中定义。因此,在第二个文件中,我们在变量名称前面加上定义它的类,即Test::TEnum

有关全局名称空间前缀Reference static const variables declared in namespace的更多信息,请参阅问题::的已接受答案。

© www.soinside.com 2019 - 2024. All rights reserved.