简体   繁体   English

如何在Swift中为枚举关联值添加文档

[英]How to add documentation to enum associated values in Swift

Is there a way to add descriptions to associated values of enums in Swift 3? 有没有办法在Swift 3中为枚举的关联值添加描述? I want them to show up in the symbol documentation popup (option+click), like they do for function parameters in Xcode 8. 我希望它们出现在符号文档弹出窗口(选项+单击)中,就像它们对Xcode 8中的函数参数一样。

This is my enum: 这是我的枚举:

enum Result {
    /**
    Request succeeded.

    - Parameters:
      - something: Some description.
      - otherThing: Other description.
    */
    case Success(something: Int, otherThing: Int)

    /**
    Request failed.

    - Parameter error: Error.
    */
    case Error(error: Error)
}

I tried using - Parameters: , but it doesn't work in enums. 我尝试使用- Parameters: ,但它在枚举中不起作用。

Do it like this: 像这样做:

/// Enum Description
enum Enum {
    /// enum1 Description
    /// - value1: value1 Description
    /// - value2: value2 Description
    case enum1(value1: Int, value2: String)

    /// enum2 Description
    case enum2
}

Show result: 显示结果: 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM