【问题标题】:How to document argument label and not parameter name of Swift function in XCode?如何在 XCode 中记录参数标签而不是 Swift 函数的参数名称?
【发布时间】:2018-03-13 18:38:12
【问题描述】:

我知道如何记录函数的参数名称,例如:

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

但我无法记录参数标签(带或不带参数名称):

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

毕竟,记录标签比参数名称更重要,因为它是在函数调用中使用的。

注意:我一直无法在 Apple 的文档中找到诀窍,或者我错过了什么?

【问题讨论】:

    标签: swift xcode markdown documentation


    【解决方案1】:

    不能直接引用函数文档中的参数标签

    作为一种解决方法,您可以在参数描述中提及标签,如下所示:

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

    通过使用反引号,它与参数本身很好地融合在一起:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 2017-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多