---
title: "#137: Rich Comments in Xcode Playgrounds 🎪💭"
url: https://littlebitesofcocoa.com/137-rich-comments-in-xcode-playgrounds
author: Jake Marsh
published: 2015-12-01
topics: ["Playgrounds"]
description: "Xcode Playgrounds are great for trying out code quickly, or testing out a new API or framework. They can also be a wonderful form of interactive documentation."
---

# #137: Rich Comments in Xcode Playgrounds 🎪💭

By Jake Marsh, December 1, 2015. HTML: https://littlebitesofcocoa.com/137-rich-comments-in-xcode-playgrounds

_Xcode Playgrounds_ are great for trying out code quickly, or testing out a new API or framework. They can also be a wonderful form of interactive documentation.

Today we'll look at a few ways we can write our own interactive docs using _rich comments_ in _Xcode Playgrounds_.

One of the primary ways we'll turn our _Playgrounds_ into documentation is through _rich comments_.

_Playgrounds_ have two "markup" modes: raw vs. rendered. As their names suggest, each mode specifies whether **Xcode** should "render" _rich comments_ in our _Playground_, or make them editable.

We'll begin by creating a new _Playground_. Then we'll select **Editor** > **Show Rendered Markup** to switch modes.

Right away, we can see the top comment changes from:

``` swift
//: Playground - noun: a place where people can play
```

To this:

<img src='https://media.littlebitesofcocoa.com/bite-assets/137-rich-comments-in-xcode-playgrounds-example.png' style='max-width: 388px;' />

We can write our own _rich comments_ by adding a `:` symbol after the `//` in any comment to convert it to a rich one. Neat!

_Rich comments'_ Markup syntax is <i>heavily</i> inspired by [Markdown](https://daringfireball.net/projects/markdown/). (It's basically just [Markdown](https://daringfireball.net/projects/markdown/)).

[Apple has a syntax guide](https://developer.apple.com/library/ios/documentation/Xcode/Reference/xcode_markup_formatting_ref/GeneralMarkupSyntax.html#//apple_ref/doc/uid/TP40016497-CH52-SW1), but here's the idea:

``` swift
//: We can write regular text, **bold** text or *italic* text.
//: ## Headers
```

We can include links in our _rich comments_:

``` swift
//: A great [link](http://littlebitesofcocoa.com).
```

We can allow readers to navigate pages with some special links:

``` swift
//: [Next](@next) or [Previous](@previous)
```

Or link to specific pages (names will need to be URL encoded):

``` swift
//: [View Models](View%20Models)
```

We can even include images in our rich comments. We just need to first add them to our _Playground's_ **Resources** **group**, then use **Markdown's** normal image syntax:

``` swift
//: ![](playgrounds-rock.gif)
```
