Jean-Baptiste Yunès
Jean-Baptiste Yunès

Reputation: 36401

How to document argument label and not parameter name of Swift function in XCode?

I know how to document the parameter name of a function like:

/**
 - parameters:
   - param: the parameter
 */
func myFunc(param: Int) {...}

but I am unable to document the argument label (either with or without the parameter name):

/**
 - parameters:
   - label: the label
   - param: the parameter
 */
func myFunc(label param: Int) {...}

After all, documenting the label is more important than the parameter name, as it is what is used at function calls.

Note: I've been unable to find the trick in Apple's documentation, or I did I miss something?

Upvotes: 1

Views: 398

Answers (1)

glyvox
glyvox

Reputation: 58049

You cannot directly refer to the argument label in the documentation of a function.

As a workaround, you can mention the label in the description of the parameter, like this:

/**
 - parameters:
     - param: (argument label: `label`) the parameter
 */
func myFunc(label param: Int) {...}

With the usage of back-ticks, it blends in nicely with the parameter itself:

example function documentation

Upvotes: 1

Related Questions