Doxygen 在其 1.7.2 版本的更新日志中宣布支持 Apple 的块扩展。我想知道生成文档的语法是什么。我找不到任何提示 - 在 doxygen 配置文件(版本 1.7.2)中也没有。
更新: 1.7.5 版于 2011 年 8 月 14 日发布。我仍然没有找到如何为 Apple 块编写文档。
问问题
800 次
2 回答
1
看看 1.7.1 和 1.7.2 之间的差异,我相信这一行的意思是 Doxygen 扫描器已经更新,以在识别块类型的typedef时支持 Apple 的块语法。例如,您可以像这样记录函数指针 typedef:
///
/// This is a typedef for a function pointer type.
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
///
typedef void (*MyFunctionPtrType)(NSUInteger p1, id<Foo> p2);
并得到这样的输出:
他们对扫描仪的更改似乎增加了对块类型定义的支持,如下所示:
///
/// This is a typedef for a block type.
/// It takes an NSUInteger parameter, an id adopting protocol Foo, and has no return value.
///
typedef void (^MyBlockType)(NSUInteger p1, id<Foo> p2);
事实上,使用最新版本的 Doxygen,它会产生如下输出:
您可以记录块类型的全局变量,但行为有点不稳定。例如,有了这个:
///
/// This is a global variable of type MyBlockType. It logs the parameters to the console.
///
MyBlockType myGlobalBlock = ^(NSUInteger p1, id<Foo> p2){
/**
* This is a block comment inside my block, which would get
* concatted into the "in body" description if this were a function.
* but won't be because this is a block.
*/
NSLog(@"p1: %lu p2: %@", p1, p2);
};
///
/// This is the definition for the function MyFunction
///
void MyFunction(NSUInteger p1, id<Foo> p2)
{
/**
* This is a block comment inside my function, which will get
* concatted into the "in body" description.
*/
NSLog(@"p1: %lu p2: %@", p1, p2);
}
我得到了这个输出,这有点不像我想要的:
幸运的是,我怀疑块类型的全局变量在实践中并不是一种常见的模式,所以 Doxygen 在处理它们方面并不是特别出色这一事实并不是什么大问题。似乎没有任何证据表明对 diff 中的块有任何进一步的支持。
于 2011-12-23T19:20:12.387 回答
0
我不知道 Obj-C,但是对于类型块不是接口成员的情况,如何标记源以生成此输出。使用@related
带有相关接口名称的标签作为其目标:
/**
* @related MyService
*
* The completion handler invoked when `unsubscribe` returns.
*/
typedef void(^MyServiceUnsubscribeCompletion)(NSError *error);
@interface MyService : NSObject
...
@end
Dimitri 自己提供了解决方案: https ://bugzilla.gnome.org/show_bug.cgi?id=720046
于 2015-02-21T08:34:18.800 回答