How to do the documentation in objective C?

Good news for all! :D Finally after waiting a long time Apple has introduced a parser comments for our projects. According to the new features in XCode 5:

Project documentation from framework API reference documentation and structured comments in your own source code are displayed in the quick help panel and in code completion popover views. Doxygen and HeaderDoc structured comments are supported formats.

and from the Clang 3.2 release notes:

Clang parses the comments and can detect syntactic and semantic errors in comments. These warnings are off by default. Pass -Wdocumentation flag to enable warnings about documentation comments.

If you want to see an example of this new feature I recommend you take a look at the following article: Documentation in Xcode 5


I don't know what IDE you're using but doxygen lets you generate documentation from comments in Objective-C (as well as C, C++, Java, and some others).

If you're using Xcode (just assuming, since you're using Objective-C), there does seem to be some level of integration (not tested by me, just found on Google): http://developer.apple.com/tools/creatingdocsetswithdoxygen.html


The standard way, as @DiegoPalomar suggested, is to use HeaderDoc, Apple's own tool for embedding structured comments in source code.

It comes with Xcode, so no installation required. It comes with a command-line script that generates HTML output of your documentation.

Docs for HeaderDoc:

  • Introduction
  • HeaderDoc command-line tool
  • HeaderDoc markup

Here's an example:

/*!
 *  Takes in a number and adds 4 to it.
 *
 *  @param myNumber a number of type NSInteger.
 *
 *  @return The number with 4 added to it.
 */
- (NSInteger)addFour:(NSInteger)myNumber {
    return myNumber + 4;
}

Big plus: when you alt-click on your documented method, your doc appears in the balloon:

enter image description here

HeaderDoc is open-source too: http://www.opensource.apple.com/source/headerdoc/