Doxygen 用于在不同文件中声明的属性,使用?

发布于 2024-12-25 22:48:16 字数 1567 浏览 0 评论 0原文

我使用 mogenerator 生成 核心数据 类。 Mogenerator 产生机器类和人类类。开发人员不应修改机器生成的类,因为每次调用 mogenerator 时都会生成这些类。然而,人类类可以根据开发人员的意愿进行修改。

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

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

示例:

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

FileA.h(无法修改)

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

FileB.h

#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 的唯一匹配的类成员 - 同上

解决方案

FileB.h

#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

I use mogenerator to generate Core Data classes. Mogenerator produces machine classes and human classes. A developer is not supposed to modify machine generated classes, since these are generated each time mogenerator is called. Human classes can, however, be modified as the developer pleases.

Machine classes contain the declaration of every property of the Core Data entity. In Doxygen, how does one document a property defined in file A from file B?

EDIT: Added example to illustrate the question

Example:

Ultimately, the goal here to have something similar to the example below.

FileA.h (can not be modified)

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

FileB.h

#include "FileA.h"

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

Tried (documentation block inside the @interface FileB @end bock):

@property myProperty - Doxygen does not associated the documentation to the property.

\property myProperty - Doxygen does not associated the documentation to the property.

@property FileA::myProperty - Doxygen does not associated the documentation to the property and generates; warning: no uniquely matching class member found for FileB::myProperty

\property FileA::myProperty - Idem

Solution

FileB.h

#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

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

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

发布评论

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

评论(2

森林很绿却致人迷途 2025-01-01 22:48:16

(对我来说)不清楚您是否希望 FileA 被记录,但您无法将文档插入 FileA.h,或者如果您想要 FileA< /code> 未记录,但其成员出现在(记录的)派生类 FileB 中。

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

/**
 * @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 是其成员之一一样。请注意,如果 FileA 中的 myProperty 声明发生更改,您必须手动更新 FileB 的声明以反映这些更改。

Its unclear (to me) whether you want FileA to be documented, but you can't insert the documentation into FileA.h, or if you want FileA to be undocumented, but have its members appear in the (documented) derived class FileB.

If its the former, you can provide documentation for class FileA in FileB.h, this would appear as something like:

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

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

@end

This will cause classes FileA and FileB to appear in the generated docs, with myProperty documented as a member of FileA.

If its the latter, you could declare myProperty as a member of FileB, but use a preprocessor guard to only include the declaration when generating your documentation, something like:

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

@end

This will cause FileB to be documented as if myProperty was one of its members. Be aware that if the declaration of myProperty changes in FileA, you'll have to manually update FileB's declaration to reflect those changes.

爱冒险 2025-01-01 22:48:16

您可以使用 Doxygen 的 ref 命令使用,例如,

\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

请参阅问题的已接受答案引用命名空间中声明的静态常量变量有关全局命名空间前缀 :: 的更多信息。

You can reference an achor (e.g. files, namespaces, classes, functions, variables, enums etc) using Doxygen's ref command using, for example

\ref variable_name

If the variable you want to document is not in the local namespace or scope, you can prefix the variable name with namespace::, where namespace is the scope or class where the variable you are referring to is defined. For example, consider the following two files (modified from examples in the Doxygen manual):

File 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();
};

File 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();

};

Here TEnum is defined in the class Test in the first file. So in the second file, we prefix the variable name with the class in which it is defined, i.e. Test::TEnum.

See the accepted answer to the question Reference static const variables declared in namespace for more information on the global namespace prefix ::.

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