Search code examples
swiftenumscode-documentation

How to document an enum case with parameters?


Given an enum that has a case with parameters, how can I document these parameters?

For example these code comments:

/// Various coffee types.
enum Coffee {

  /// A Cappuccino.
  /// - parameters:
  ///   - cream: Is true if cream is added.
  case cappuccino(cream: Bool)
}

produce this pop-up which is lacking the cream parameter documentation.

enter image description here

So what is the correct markup?


Solution

  • /// Various coffee types.
    enum Coffee {
    
        /// A Cappuccino.
        /// - cream: Is true if cream is added.
        case cappuccino(cream: Bool)
    }
    

    It'll show up as a bullet point when you click on cappuccino but won't show up if you click on the cream parameter.. But it's good enough I guess..