Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the markup format for documentation on the parameters of a block in Swift?

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

like image 932
lostAtSeaJoshua Avatar asked Jan 31 '17 23:01

lostAtSeaJoshua


People also ask

How do I use markup in Swift Playground?

Use markup to create playgrounds that show formatted text in rendered documentation mode and to show Quick Help for your Swift code symbols. Markup for playgrounds includes page level formatting for headings and other elements, formatting spans of characters, showing inline images, and several other features.

How do I use markup for Swift symbols?

Markup for Swift symbols is used for Quick Help and for the description shown in symbol completion. For example, the description in the markup in Figure 1-2 is used for the description in symbol completion shown in Figure 1-3 .

What are the different types of markup syntax?

Markup Syntax. Markup uses simple Markdown-like character delimiter syntax with custom extensions. There are four types of elements: Single line elements format a line of text such as creating a heading. Multiline elements format multiple lines of text such as creating lists or callouts.

Where can I find Swift standard library documentation?

The Swift standard library defines a base layer of functionality for writing Swift programs. Documentation for the standard library is presently hosted on the Apple Developer website. There are a number of packages that are part of the core Swift project. Below is a list of packages that currently offer hosted documentation.


1 Answers

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

like image 139
Mike Taverne Avatar answered Sep 24 '22 06:09

Mike Taverne