AppCode 2021.2 Help

Documenting code

In AppCode, you can generate and view documentation for your Swift and Objective-C code. For Objective-C, you can add HeaderDoc, Doxygen, and appledoc comments and generate full-fledged documentation in various formats using corresponding tools. For Swift, the Markdown syntax is available for code documentation formatting.

Generate comments

Place the caret before the declaration of a method or function that you want to document and do the following:

  • For Objective-C: depending on the comment style you want to use, type ///, //!, /**, or /*! and press :

    Create Objective-C comments
  • For Swift: type /// or /** and press .

    Create Swift comments

View documentation

  • Place the caret at the symbol you want to view documentation for and press ⌃ Q. If the symbol is supplied with proper documentation comments or SDK documentation, the Quick Documentation popup appears:

    Quick documentation popup
  • If you want documentation to be shown in a tool window, press ⌃ Q twice. Press ⌃ Q twice to switch between the popup and tool window modes.

  • If you want documentation to be shown on mouse hover, select the Show quick documentation on hover checkbox in Preferences | Editor | General.

Reliable rename

While renaming a function or its parameters, the documentation comments need to be updated accordingly. In case of the Rename refactoring ⇧ F6, AppCode updates documentation comments along with other references.

Rename comments

Typing assistance

Basic typing assistance for documentation comments is provisioned by AppCode auto-complete feature:

Autocomplete comments

Rendered view for Objective-C documentation comments

With AppCode, Objective-C documentation comments can be shown in an easier-to-read format. In this Rendered View mode, items are shown grouped by their tags, while the tags themselves are skipped.

Toggling rendered view for documentation comments

Note the rendered view limitations:

  • Opening the referenced web pages is not available.

  • EOL block comments are rendered only if they start the line.

Toggle and configure the rendered view

  • To enter the Rendered View mode, hover the mouse pointer over a comment and click the Toggle Rendered View icon in the gutter or press ⌃ ⌥ Q. The icon turns into the Toggle Rendered View icon.

  • To quit the Rendered View mode, click the Toggle Rendered View icon in the gutter, or select Toggle Rendered View from the context menu of a Objective-C documentation comment, or press ⌃ ⌥ Q.

  • To turn on the Rendered View mode for all Objective-C documentation comments in the current file, select Render All Doc Comments from the context menu in the gutter.

    Enabling rendered view for all documentation comments
  • If necessary, select Adjust Font Size from the context menu and change the font size using the slider.

    Adjusting the font size in rendered view
  • To show all Objective-C documentation comments rendered by default, open the Preferences dialog ⌃ ⌥ S, go to Editor | General | Appearance, and select the Render documentation comments checkbox.

    Turn on Rendered Objective-C documentation comments by default
  • To hide the Rendered View gutter icons, select Configure Gutter Icons from the context menu in the gutter and then clear the Documentation comments in-place rendering checkbox on the Preferences | Editor | General | Gutter Icons page that opens.

Last modified: 07 July 2021