使用 Xcode 中的新 DocC 工具,你现在可以使用双反引号来引用其他方法。
如果你所引用的类型、属性或方法与你正在记录的内容不是“同级”的,你可以通过限定引用来引用它。
struct House {
/// The rooms in the house.
var rooms: [Room]
/// The maximum size of the household.
///
/// This is calculated by summing the ``Room/occupancyLimit`` of this
/// house's ``rooms``.
var maximumHouseholdSize: ...
}
struct Room {
/// The maximum number of occupants allowed in the room.
var occupancyLimit: ...
}
这里,对于House.maximumHouseholdSize
的文档注释使用以下方式引用House.rooms
:
``rooms``
因为房间
是最大家庭人数
的同级元素。
它还使用Room.occupancyLimit
引用:
``Room/occupancyLimit``
由于occupancyLimit
不是嵌套在同一种类型中,而是在Room
类型下。
您可以通过使用 ///-Tag:
对其进行标记,并使用x-source-tag://[Tag]
方案引用 Tag
来链接到另一种方法,如下所示:
/// - Tag: someMethod
func someMethod() {
...
}
/// Make sure to call [someMethod](x-source-tag://someMethod) at some point when overriding.
func otherMethod() {
...
}
点击快速帮助弹出框中的 someMethod
链接,将带您进入该方法并以黄色闪烁方式突出显示它。
https://www.myLink
,但它对我不起作用。即使它能起作用,我也会感到非常惊讶,但我还是进行了检查。我正在使用Xcode 9.4。 - Michael使用这个
/**
* <#Description#>
*
* @link UILabel <#UILabel description#>
*
* @return <#return value description#>
*/
或者你可以尝试使用vvDocumenter来添加注释
<#ClassName methodName#>
我认为这是自动完成建议占位符的语法。 - Apoorv Khatreja