Swift中块参数文档的标记格式是什么? [英] What is the markup format for documentation on the parameters of a block in Swift?
问题描述
如果您添加文档标记,Swift中一个块的参数将显示一个表,其中包含块的参数,但是我不知道如何填写该表.我已经在 Xcode标记参考格式,但是我找不到任何内容.
The parameters of a block in Swift shows up with a table for parameters of the block if you add markup for documentation but I can not figure out how to fill out this table. I have searched for it in the Xcode markup reference formatting but I couldn't find anything on it.
示例:
/**
Foo
- parameter completion: A block to execute
*/
func foo(completion: (Bool) -> Void) {
// do something
}
如果我在上述功能的Xcode中使用option + click
来查看文档,就会显示以下内容:
This is what shows up if I option + click
in Xcode on the function above to view documentation:
Apple的API显示填写的完成块参数表.这是CloudKit API文档视图的示例:
Apple's APIs show the completion block parameter table filled out. This is an example of a CloudKit API documentation view:
推荐答案
您必须给参数起个名字,但在其前加上下划线:
You have to give a name to the parameter, but precede it with an underscore:
/**
Foo
- parameter completion: A block to execute
- parameter aflag: Some Bool flag
*/
func foo(completion: (_ aflag: Bool) -> Void) {
// do something
}
这篇关于Swift中块参数文档的标记格式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!