Comparing version 0.4.1 to 1.0.0
@@ -0,1 +1,7 @@ | ||
1.0.0 - January 26, 2015 | ||
- **Finalized API**, in line with raml2html | ||
- Added resource-level descriptions | ||
- Hiding empty resources | ||
- No longer depends on raml2html, using raml2obj directly | ||
0.4.1 - September 10, 2014 | ||
@@ -2,0 +8,0 @@ - Reinstated raml2md-as-a-library functionality |
@@ -5,12 +5,67 @@ #!/usr/bin/env node | ||
var raml2html = require('raml2html'); | ||
var raml2obj = require('raml2obj'); | ||
var handlebars = require('handlebars'); | ||
var program = require('commander'); | ||
var fs = require('fs'); | ||
var pjson = require('../package.json'); | ||
function getDefaultConfig() { | ||
function _emptyResourceCheckHelper(options) { | ||
if (this.methods || (this.description && this.parentUrl)) { | ||
return options.fn(this); | ||
} | ||
} | ||
function render(source, config, onSuccess, onError) { | ||
config = config || {}; | ||
config.raml2MdVersion = pjson.version; | ||
// Register handlebar helpers | ||
for (var helperName in config.helpers) { | ||
if (config.helpers.hasOwnProperty(helperName)) { | ||
handlebars.registerHelper(helperName, config.helpers[helperName]); | ||
} | ||
} | ||
// Register handlebar partials | ||
for (var partialName in config.partials) { | ||
if (config.partials.hasOwnProperty(partialName)) { | ||
handlebars.registerPartial(partialName, config.partials[partialName]); | ||
} | ||
} | ||
raml2obj.parse(source, function(ramlObj) { | ||
ramlObj.config = config; | ||
var result; | ||
if (typeof config.template === 'string') { | ||
result = handlebars.compile(config.template)(ramlObj); | ||
} else { | ||
result = config.template(ramlObj); | ||
} | ||
if (config.processOutput) { | ||
config.processOutput(result, onSuccess, onError) | ||
} else { | ||
onSuccess(result); | ||
} | ||
}, onError); | ||
} | ||
function getDefaultConfig(mainTemplate, resourceTemplate) { | ||
if (typeof mainTemplate !== 'function') { | ||
mainTemplate = fs.readFileSync(mainTemplate || __dirname + '/template.handlebars', 'utf8'); | ||
} | ||
if (typeof resourceTemplate !== 'function') { | ||
resourceTemplate = fs.readFileSync(resourceTemplate || __dirname + '/resource.handlebars', 'utf8'); | ||
} | ||
return { | ||
'template': require('./template.handlebars'), | ||
'partials': { | ||
'resource': require('./resource.handlebars') | ||
template: mainTemplate, | ||
helpers: { | ||
emptyResourceCheck: _emptyResourceCheckHelper | ||
}, | ||
partials: { | ||
resource: resourceTemplate | ||
}, | ||
processOutput: function(data, onSuccess) { | ||
@@ -23,12 +78,10 @@ data = data.replace(/\n{3,}/g, '\n\n'); | ||
function render(source, config, onSuccess, onError) { | ||
raml2html.render(source, config, onSuccess, onError); | ||
} | ||
if (require.main === module) { | ||
program | ||
.usage('[options] [RAML input file]') | ||
.version(pjson.version) | ||
.option('-i, --input [input]', 'RAML input file') | ||
.option('-o, --output [output]', 'Markdown output file') | ||
.option('-t, --template [template]', 'Path to custom template.handlebars file') | ||
.option('-r, --resource [resource]', 'Path to custom resource.handlebars file') | ||
.parse(process.argv); | ||
@@ -48,4 +101,4 @@ | ||
// Start the parsing process | ||
render(input, getDefaultConfig(), function(result) { | ||
// Start the rendering process | ||
render(input, getDefaultConfig(program.template, program.resource), function(result) { | ||
if (program.output) { | ||
@@ -52,0 +105,0 @@ fs.writeFileSync(program.output, result); |
{ | ||
"name": "raml2md", | ||
"description": "RAML to Markdown documentation generator", | ||
"version": "0.4.1", | ||
"version": "1.0.0", | ||
"author": { | ||
@@ -13,4 +13,5 @@ "name": "Kevin Renskers", | ||
"dependencies": { | ||
"commander": "^2.2.0", | ||
"raml2html": "1.0.x" | ||
"commander": "2.2.x", | ||
"handlebars": "1.3.x", | ||
"raml2obj": "1.0.x" | ||
}, | ||
@@ -17,0 +18,0 @@ "homepage": "https://github.com/kevinrenskers/raml2md", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
18831
97
0
3
+ Addedhandlebars@1.3.x
+ Addedraml2obj@1.0.x
+ Addedraml2obj@1.0.0(transitive)
- Removedraml2html@1.0.x
- Removedarray-buffer-byte-length@1.0.1(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.2(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddeep-equal@2.2.3(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddom-serializer@0.2.2(transitive)
- Removeddomelementtype@1.3.12.3.0(transitive)
- Removeddomhandler@2.2.1(transitive)
- Removeddomutils@1.5.1(transitive)
- Removeddunder-proto@1.0.0(transitive)
- Removedentities@1.0.02.2.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-get-iterator@1.1.3(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedglob@7.2.3(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-bigints@1.0.2(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhtmlparser2@3.7.3(transitive)
- Removedi@0.3.7(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinternal-slot@1.0.7(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-array-buffer@3.0.4(transitive)
- Removedis-bigint@1.1.0(transitive)
- Removedis-boolean-object@1.2.0(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-date-object@1.0.5(transitive)
- Removedis-map@2.0.3(transitive)
- Removedis-number-object@1.1.0(transitive)
- Removedis-regex@1.2.0(transitive)
- Removedis-set@2.0.3(transitive)
- Removedis-shared-array-buffer@1.0.3(transitive)
- Removedis-string@1.1.0(transitive)
- Removedis-symbol@1.1.0(transitive)
- Removedis-weakmap@2.0.2(transitive)
- Removedis-weakset@2.0.3(transitive)
- Removedisarray@0.0.12.0.5(transitive)
- Removedmarked@0.3.19(transitive)
- Removedmath-intrinsics@1.0.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedminimize@0.8.2(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedncp@0.4.2(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedraml2html@1.0.6(transitive)
- Removedraml2obj@0.3.0(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedsafe-regex-test@1.0.3(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstop-iteration-iterator@1.0.0(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedutile@0.2.1(transitive)
- Removedwhich-boxed-primitive@1.1.0(transitive)
- Removedwhich-collection@1.0.2(transitive)
- Removedwhich-typed-array@1.1.16(transitive)
Updatedcommander@2.2.x