Swiftpack.co -  ldstreet/PlayDocs as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ldstreet/PlayDocs
Command line tool for converting Swift Playgrounds to Markdown and HTML.
.package(url: "https://github.com/ldstreet/PlayDocs.git", from: "0.1.0")

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...

Convert

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/MyFile.md --open

New

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 https://github.com/ldstreet/PlayDocs.git && cd PlayDocs && make install

πŸƒβ€β™‚οΈ Marathon

Add to your Marathonfile:

marathon add https://github.com/ldstreet/PlayDocs.git

Or use the inline dependency syntax:

import PlayDocsKit // https://github.com/ldstreet/PlayDocs.git

🎁 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: "https://github.com/ldstreet/PlayDocs.git", from: "0.1.0"),

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

GitHub

link
Stars: 2
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Inaugural Release
2 years ago

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.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API