I have an enumeration in Swift:
enum DateFormat{
case ShortDateFormat //7/28/2014 ShortStyle
case LongDateFormat //July 28, 2014 LongStyle
case LongFormatWithDay //Monday, July 28, 2014 FullStyle
case CurrentDayThreeLetters //Mon
}
And I'd like to have this documented similar to how intellisense works in C#, where the moment I type DateFormat.ShortDateFormat
, the popup will tell me that this produces 7/28/2014.
I'd also like to do this with hard-to-remember functions I wrote that return specific things to make it easier on me so I don't have to go back to the file and look up exactly what it did (not that I have many of those functions, mind you) !
How could I do such a thing ?
HeaderDoc tags work in Objective-C and Swift although in Swift, the format is a little different. In Objective - C, the proper format to document a method was this:
/*!
* @discussion This is an example discussion.
* @param bar - This is an example of a parameter.
* @return An example for a return type
*/
-(id)foo:(bar)foobar;
The result when alt-clicking foo: is this
In swift, the way to document is a little different:
/**
This is an example discussion
:param: bar This is an example parameter.
:returns: This is an example return type.
*/
func foo(foobar: AnyObject) -> AnyObject {...}
This gives the same example when alt-clicking as above.
For an enum, its the same principle as above using the /** */
format but also uses ///
for individual enum descriptions as well.
/**
Example enum description
- First: First example
- Second: Second example
- Third: Third example
- Fourth: Fourth example
*/
enum Example {
///First example
case First
///Second example
case Second
///Third example
case Third
///Fourth example
case Fourth
}
The result is a neatly formatted, bulleted list:
And when alt-clicking one of the actual cases: .
You will get your desired effect using the autocomplete as shown below:
To do this, you simply need to add triple forward slashes (///) to do this and it will work.
/// My Comment Here to Appear In "Intellisense" Popup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With