Xcode - Add Custom Documentation for Swift Closure

513 views Asked by At

Question:

  • What is the correct format to add documentation (using built in functionality not 3rd party) to a custom Swift closure in Xcode 8 ?
  • Could you provide the Apple documentation link to refer ?
  • How to specify the closure parameters ?
  • How to specify the closure return type ?

Example:

struct S1 {

    /// This block is executed after completion
    var completion : (String, Int) -> (Bool)
}

Note:

Xcode 8 has built in functionality to add documentation to custom code.

This can be done, by doing one of the following:

  • Command + Option + Click on code

  • Keep cursor on code and Editor > Structure > Add documentation

1

There are 1 answers

2
DrSvanHay On BEST ANSWER

Reference:

Workaround:

If those tags are not supported for the given location the only possible workaround seems to be right now:

struct S1 {
    
    /// description
    ///
    /// __returns__
    /// blah blah
    ///
    /// __parameters__
    /// blah blah
    var completion : (String, Int) -> (Bool)
}