Cheat Sheet: Documentation and DocC

Created June 10, 2023

Code comments

One line and multi-line comments

Within your code base, you can add comments that will be seen in the documentation:

/// One line comment


Shortcut for documentation template

Use the shortcut Option-Command-Slash while your cursor is on a method name, to produce a documentation template for that method. shortcut-template.png


Create a document directory

You can create a DocC documentation directory by right clicking on your project folder, selecting “New File”, and then “Documentation Catalog” add-doc-catalog.png

Place it at the same level of your source files, so it will be recognized. level-as-source-files.png

Add articles

Right click on the document director, select “New File” and then select “Article”. article-1.png article-2.png

Link to other articles

You can refer to other articles by using the format <doc:MyArticle> where “MyArticle” is the name of the article I want to link to. doc-link.png

Link to code

You can refer to your code by creating links in the format ``MyClass`` where "MyClass" is the name of the class you want to link to. link-to-code.png

Add images

Add images into the “Resources” folder in the document directory. Then you can refer to the images by name using the format: ![Screenshot of page](MyScreenShot) where “MyScreenShot” is the name of the resource. my-screen-shot.png

Build the documentation

From the Xcode menu, you can click on “Product” and then “Build Documentation”. The keyboard shortcut is Control-Shift-Command-D. build-documentation-menu.png