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

raml2md

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raml2md - npm Package Compare versions

Comparing version 0.4.1 to 1.0.0

examples/example.md

6

changelog.md

@@ -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

77

lib/raml2md.js

@@ -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);

7

package.json
{
"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

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