Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Drafter NPM Package for API Blueprint Parsing #277

Merged
merged 1 commit into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"chokidar": "^1.4.1",
"cli-color": "^1.1.0",
"pretty-error": "^1.2.0",
"protagonist": "^1.3.2",
"drafter": "^1.0.0",
"serve-static": "^1.10.0",
"socket.io": "^1.3.7",
"yargs": "^3.31.0"
Expand Down
6 changes: 3 additions & 3 deletions src/main.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fs = require 'fs'
path = require 'path'
protagonist = require 'protagonist'
drafter = require 'drafter'

INCLUDE = /( *)<!-- include\((.*)\) -->/gmi
ROOT = path.dirname __dirname
Expand Down Expand Up @@ -82,7 +82,7 @@ exports.render = (input, options, done) ->
# Handle custom directive(s)
input = includeDirective options.includePath, input

# Protagonist does not support \r ot \t in the input, so
# Drafter does not support \r ot \t in the input, so
# try to intelligently massage the input so that it works.
# This is required to process files created on Windows.
filteredInput = if not options.filterInput then input else
Expand All @@ -91,7 +91,7 @@ exports.render = (input, options, done) ->
.replace(/\t/g, ' ')

benchmark.start 'parse'
protagonist.parse filteredInput, type: 'ast', (err, res) ->
drafter.parse filteredInput, type: 'ast', (err, res) ->
benchmark.end 'parse'
if err
err.input = input
Expand Down
6 changes: 3 additions & 3 deletions test/basic.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bin = require '../lib/bin'
fs = require 'fs'
http = require 'http'
path = require 'path'
protagonist = require 'protagonist'
drafter = require 'drafter'
sinon = require 'sinon'

root = path.dirname(__dirname)
Expand Down Expand Up @@ -164,13 +164,13 @@ describe 'API Blueprint Renderer', ->
done()

it 'Should error on drafter failure', (done) ->
sinon.stub protagonist, 'parse', (content, options, callback) ->
sinon.stub drafter, 'parse', (content, options, callback) ->
callback 'error'

aglio.render blueprint, 'default', (err, html) ->
assert err

protagonist.parse.restore()
drafter.parse.restore()

done()

Expand Down