Command line tool for converting Swift Playgrounds to Markdown and HTML.

What's New

Inaugural Release


Inaugural release of PlayDocs. PlayDocs is both a command line tool and Swift library that allows you to:

  • Convert Xcode Playgrounds to Markdown (.md)
  • Convert Xcode Playgrounds to HTML (.html)
  • Create Xcode Playgrounds

All new versions may contain breaking changes until 1.0.0 is released.

PlayDocs 🏓

Build Status Swift Version SPM Platforms Git Version license Twitter

💡 Overview

PlayDocs is command line tool for converting Swift Playgrounds to Markdown and HTML. Playgrounds have supported rendering markdown from the beginning, so why not leverage that for generating documentation that can live both in your repository as executable code and on your wiki or blog as documention or a post?

⚙️ Usage

You can use PlayDocs both as a commandline tool or as a framework in your own code.

As a commandline tool...


Here is the basic command for generating a markdown file via a Playground:

playdocs convert ./MyPlayground.playground --open

And if you want it to output as html:

playdocs convert ./MyPlayground.playground --html --open

To specify a destination:

playdocs convert ./MyPlayground.playground --destination /path/to/file/ --open


PlayDocs can also help you easily create new Playground files so you can get your doc started fast:

playdocs new HelloPlayDocs --open

If you want the Playground to target MacOS:

playdocs new HelloPlayDocs --macos --open

And if you don't want any boilerplate in your Playground:

playdocs new HelloPlayDocs --macos --empty --open

As a package...

To make your conversions in swift, you can use PlayDocsKit

// Convert swift source from a swift source string to a markdown string
public func convertToMarkdown(from source: SwiftSource) -> MarkdownSource

// Convert swift source from a file to a markdown file
public func convertToMarkdown(from source: URL, to destination: URL) throws

// Convert swift source from a string to an html string
public func convertToHTML(from source: SwiftSource) throws -> HTMLSource

// Convert swift source from a file to a html file
public func convertToHTML(from source: URL, to destination: URL) throws

// Custom conversion allowing caller to convert each Chunk as seen fit
public func convert(from source: SwiftSource, prepending header: String = "", appending footer: String = "", conversion convert: (Chunk) -> String) -> String

🖍 Syntax Highlighting

Syntax highlighting for all Swift code is applied via John Sundell's Splash

Note: For now, the theme for syntax highlighting is hardcoded, but in the future this project should make the theme configurable.

⬇️ Installing

To install the commandline tool:

🌱 Mint

$ mint install ldstreet/PlayDocs

🔧 Make

Run in terminal:

git clone && cd PlayDocs && make install

🏃‍♂️ Marathon

Add to your Marathonfile:

marathon add

Or use the inline dependency syntax:

import PlayDocsKit //

🎁 Swift Package Manager

To use PlayDocsKit add the following to your Package.swift file.

// 🏓 A framework for converting Playgrounds and Swift files to markdown and html
.package(url: "", .branch("master")),

.target(name: "MyPackage", dependencies: ["PlayDocsKit"]),


  • Swift Tools 4.2.0
View More Packages from this Author


Last updated: Wed Nov 22 2023 18:16:26 GMT-1000 (Hawaii-Aleutian Standard Time)