Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are documentation comments in Xcode? [duplicate]

This question is for reference purposes.

In the "Fonts & Colors" tab of the Settings window of Xcode, there's a setting for documentation comments (and keywords)? What are they?

like image 678
Constantino Tsarouhas Avatar asked Jul 07 '11 03:07

Constantino Tsarouhas


People also ask

How do you write a documentation comment in Swift?

Type /// or /** */ to begin a documentation comment and then use DocC's special dialect of Markdown to write the content. This dialect supports many keywords like - Parameters: for describing function arguments or - Returns: for describing return values.

How do I comment in Xcode?

6. Comments By selecting a few lines of code (pressing ⇧+↑ or ⇧+↓), you can comment a bunch of lines in a single shot with the ⌘ + / shortcut. If the lines are already comments, the same shortcut will uncomment them.

What is Doc C?

DocC syntax — called documentation markup — is a custom variant of Markdown that adds functionality for developer documentation-specific features, like cross-symbol linking, term-definition lists, code listings, and asides.

How do you add a comment to a swift code?

There are two ways to add comments in Swift: // - Single Line comments. /*... */ - Multiline Comments.


2 Answers

Feel free to enhance this answer.

Documentation comments are just (Objective-C) comments marked as documentation. They are treated the same way as normal comments, except that you can set another color and font in Xcode. Some documentation software may even use these comments to create automatically documentation from given header files and other source code.

Documentation comment keywords are keywords that give semantical meaning to text that follows after the keyword in a documentation comment.

You can create inline documentation comments with three slashes (instead of two in normal comments), and block doc. comments with two stars instead of one (instead of one in normal comments). Example:

// Normal inline comment /// Documentation comment  /* Normal block comment */ /** Documentation block comment */ 

You can create documentation comment keywords by specifying a keyword (one word only) after the "at" symbol. Example:

- (void)sendMessage: (id)sender; /// @description Sends the receiver. /// @available Version 1.0 through 2.2 

Appledoc is a tool for creating a documentation set from your source code (including documentation comments and method signatures) and getting it to install and reload inside Xcode when needed. It's a command-line program and has instructions for how to incorporate it into your Xcode build process.

Once you have a documentation set you can add it to Xcode via Preferences > Downloads > Documentation.

The special keywords starting with an @-sign is also called HeaderDoc tags. A list of them can be found in the HeaderDoc User Guide. Please note that some of them are Objective-C and some are C++.

like image 104
3 revs, 3 users 82% Avatar answered Sep 18 '22 14:09

3 revs, 3 users 82%


For those who did not watch the latest keynote: With Xcode 5 this feature will be built in. It is already available in the current developer preview (called quick help, like announced here).

Code hint example

like image 34
Quxflux Avatar answered Sep 18 '22 14:09

Quxflux