4

I've been using the Xcode 5's ability to document my code with the supported comment syntax (see this SO question). Xcode 6 supports it with Objective-C sources, unfortunately not with Swift sources.

I would like to perform inline documentation on a .swift source. Any idea how to do it or best practices?

Thanks in advance,

Luis

Community
  • 1
  • 1
Luis Palacios
  • 396
  • 1
  • 3
  • 14
  • 1
    Duplicate of [Does swift have documentation comments or tools?](http://stackoverflow.com/questions/24047991/does-swift-have-documentation-comments-or-tools) ? – Martin R Jun 29 '14 at 11:22

2 Answers2

8

Here are some things that work for documenting swift code in Xcode 6. It is very buggy and sensitive to colons, but it's better than nothing:

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";
    }
}

The above is rendered in Quick Help as you would expect with formatted numeric lists, bullet points, parameter and return value documentation.

None of this is documented - file a Radar to help them along.

nduplessis
  • 12,236
  • 2
  • 36
  • 53
ShakenManChild
  • 661
  • 1
  • 5
  • 2
2

It seems like you can still add descriptions of functions:

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

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

}

but none of the headerdoc tags are currently supported. It'll probably be supported by the time Xcode 6 is released.

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142