Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swift-playground-builder

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swift-playground-builder

Create Xcode Playgrounds for the Swift programming language with rich documentation generated from Markdown

  • 0.2.0
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Swift Playground Builder

Create Xcode Playgrounds for the Swift programming language with rich documentation generated from Markdown

Playground example

Markdown Format

Swift code is extracted from the Markdown with the same syntax used to specify languages for code blocks in GitHub-flavored Markdown. All other text is parsed normally as Markdown using marked.

# A Swift Tour

Tradition suggests that the first program in a new language should print the words "Hello, world"
on the screen. In Swift, this can be done in a single line:

```swift
println("Hello, world!")
```

Install

  1. This tool requires Node.js. Download the installer from the Node.js website and follow the instructions.

  2. In your Terminal, run the following command to install the Playground Builder:

    $ npm install -g swift-playground-builder
    
  3. That's it! You should now be able to use the playground command.

Command-line Usage

Usage: playground <paths>... [options]

paths     Markdown files(s), or directory containing Markdown files,
          from which to build the Playground(s)

Options:

   -d, --destination   Directory in which to output the Playground(s)

   -p, --platform      Specifies which platform's frameworks can be imported
                       in the Playground(s); only one platform can be choosen
                       [options: ios, osx] [default: osx]

   -n, --noreset       Don't allow edited code to be reset from the
                       "Editor → Reset Playground" menu in Xcode

   -v, --version       Print swift-playground-builder version and exit

Node.js Usage

You can also import the Playground Builder as a Node.js module.

var buildPlayground = require('swift-playground-builder');

Arguments

  • paths (String or Array, required) Path to Markdown file or directory containg Markdown files. An array of file and/or directory paths is also acceptable.

  • outputDirectory (String, optional) Path to directory in which to output the built Playground(s). If not specified, the value of process.cwd() is used by default.

  • options (Object, optional) See the "Options" section below for available options.

  • callback (Function, optional) Function to be called once all Playground files have been output. First argument is err which contains an Error, if any.

Options

  • allowsReset (default: true) A Playground's code can be modified and saved. The Playground can be reset to its original code from the "Editor → Reset Playground" menu. This menu can be disabled for a Playground by setting this option to false.`

  • platform (default: osx) Set the platform to osx or ios to be able to import each platform's respective frameworks.

Example

var buildPlayground = require('swift-playground-builder');

// outputs `Introduction.playground` to CWD
buildPlayground('Introduction.md');

// outputs `Variables.playground` to `/User/json/Playgrounds`
buildPlayground('Variables.md', '/User/jason/Playgrounds');

// outputs `Constants.playground` and `Closures.playground` to CWD
buildPlayground(['Constants.md', 'Closures.md'], {
  allowsReset: false,
  platform: 'ios'
});

// outputs playgrounds for Markdown files in `./playgrounds` directory,
// then invokes callback function
buildPlayground(['./playgrounds'], function(err) {
  if (err) { throw err; }
  console.log('Done building playgrounds!');
});

TODO

  • Improved default stylesheet
  • Ability to pass custom stylesheet
  • Tests

FAQs

Package last updated on 08 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc