Doxygen 用于在不同文件中声明的属性,使用?
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(对我来说)不清楚您是否希望
FileA
被记录,但您无法将文档插入FileA.h
,或者如果您想要FileA< /code> 未记录,但其成员出现在(记录的)派生类
FileB
中。如果是前者,您可以在
FileB.h
中提供类FileA
的文档,这将显示为以下内容:这将导致类
FileA
和FileB
出现在生成的文档中,并将myProperty
记录为FileA
的成员。如果是后者,您可以将
myProperty
声明为FileB
的成员,但使用预处理器保护仅在生成文档时包含该声明,例如:这将导致
FileB
将被记录,就像myProperty
是其成员之一一样。请注意,如果FileA
中的myProperty
声明发生更改,您必须手动更新FileB
的声明以反映这些更改。Its unclear (to me) whether you want
FileA
to be documented, but you can't insert the documentation intoFileA.h
, or if you wantFileA
to be undocumented, but have its members appear in the (documented) derived classFileB
.If its the former, you can provide documentation for class
FileA
inFileB.h
, this would appear as something like:This will cause classes
FileA
andFileB
to appear in the generated docs, withmyProperty
documented as a member ofFileA
.If its the latter, you could declare
myProperty
as a member ofFileB
, but use a preprocessor guard to only include the declaration when generating your documentation, something like:This will cause
FileB
to be documented as ifmyProperty
was one of its members. Be aware that if the declaration ofmyProperty
changes inFileA
, you'll have to manually updateFileB
's declaration to reflect those changes.您可以使用 Doxygen 的
ref
命令使用,例如,如果要记录的变量不在本地命名空间或范围内,则可以在变量名称前加上前缀
namespace::
,其中namespace
是定义您所引用的变量的范围或类。例如,考虑以下两个文件(根据 Doxygen 手册中的示例进行修改):文件 1:
文件 2:
此处
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 exampleIf the variable you want to document is not in the local namespace or scope, you can prefix the variable name with
namespace::
, wherenamespace
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:
File 2:
Here
TEnum
is defined in the classTest
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
::
.