Skip to content

Commit

Permalink
Use Drafter NPM Package for API Blueprint Parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kylef committed Jul 19, 2016
1 parent 4ae89e6 commit 0a2b3f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
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

0 comments on commit 0a2b3f6

Please sign in to comment.