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

drafter

Package Overview
Dependencies
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drafter

Node API Blueprint Parser

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.6K
increased by13.75%
Maintainers
5
Weekly downloads
 
Created
Source

logo

Drafter NPM Package Build Status

The Drafter NPM package is an API Blueprint parser for Node. This package is a wrapper around the underlying C++ parser Drafter. Drafter NPM optionally depends on the C++ binding to Drafter Protagonist. If for any reason Protagonist is not installable, this package will fallback to using the slower, pure JavaScript version of Drafter, drafter.js.

Installation

Drafter can be installed from NPM. If you want to use Drafter from a web browser, check out drafter.js.

$ npm install drafter

Usage

var drafter = require('drafter');

Once you've included drafter, you can parse an API Blueprint asynchronously:

var options = {
  generateSourcemap: true,
};

drafter.parse('# API Blueprint...', options, function(err, result) {
  if (err) {
    console.log(err);
  } else {
    console.log(result);
  }
});

Alternatively, you can use Drafter synchronously:

try {
  var result = drafter.parse('# API Blueprint...', options);
  console.log(result);
} catch (err) {
  console.log(err);
}

Parsing Options

Options can be passed to the parser as an optional second argument to both the asynchronous and synchronous interfaces:

var options = {
  generateSourceMap: true
}

drafter.parse('# My API', options, callback);

The available options are:

NameDescription
requireBlueprintNameRequire parsed blueprints have a title (default: false)
generateSourceMapEnable sourcemap generation (default: false)
typeSet the output structure type as either ast or refract (default: refract)

NOTE: The ast option is deprecated in favour of refract.

License

MIT License. See the LICENSE file.

FAQs

Package last updated on 31 Oct 2016

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