4

我一直在使用 Xcode 5 使用支持的注释语法记录我的代码的能力(请参阅这个 SO 问题)。Xcode 6 通过 Objective-C 源代码支持它,不幸的是不支持 Swift 源代码。

我想在 .swift 源上执行内联文档。知道如何做或最佳实践吗?

提前致谢,

路易斯

4

2 回答 2

8

以下是在 Xcode 6 中记录 swift 代码的一些内容。它有很多错误并且对冒号很敏感,但总比没有好:

class Foo {

    /// This method does things.
    /// Here are the steps you should follow to use this method
    ///
    /// 1. Prepare your thing
    /// 2. Tell all your friends about the thing.
    /// 3. Call this method to do the thing.
    ///
    /// Here are some bullet points to remember
    ///
    /// * Do it right
    /// * Do it now
    /// * Don't run with scissors (unless it's tuesday)
    ///
    /// :param: name The name of the thing you want to do
    /// :returns: a message telling you we did the thing
    func doThing(name : String) -> String {
        return "Did the \(name) thing";
    }
}

正如您所期望的那样,上面的内容通过格式化的数字列表、项目符号、参数和返回值文档呈现在快速帮助中。

这些都没有记录 - 提交雷达以帮助他们。

于 2014-07-23T02:33:00.687 回答
2

似乎您仍然可以添加功能描述:

/**
This is a description of my function
*/
func myFunc() {

}
///this is a description of my second function
func myFunc2(){

}

但目前不支持任何 headerdoc 标记。它可能会在 Xcode 6 发布时得到支持。

于 2014-06-29T13:41:11.290 回答