What is the markup format for documentation on the

2020-06-18 09:13发布

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.

Example:

/**
 Foo

 - parameter completion: A block to execute
 */
func foo(completion: (Bool) -> Void) {
    // do something
}

This is what shows up if I option + click in Xcode on the function above to view documentation:

Image of Xcode documentation view of a function

Apple's APIs show the completion block parameter table filled out. This is an example of a CloudKit API documentation view:

Image of Xcode documentation view of a function

1条回答
我欲成王,谁敢阻挡
2楼-- · 2020-06-18 09:33

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
}

enter image description here

查看更多
登录 后发表回答