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

json-doc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-doc - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

48

json-doc.js
'use strict';
var
compileTemplate = require('simple-template-js');
compile = require('simple-template-js');
var renderRoot = compileTemplate([
'# <%= ctx.title %>',
'<%= ctx.description || "" %>',
'| property | type | description |',
'|----------|------|-------------|'
].join('\n'), 'path,ctx');
var
defaultTemplate = [
'<% if (path.length === 0) { %>',
'# <%= prop.title %>\n',
'<%= prop.description || "" %>\n',
'| property | type | description |\n',
'|----------|------|-------------|\n',
'<% } else { %>',
'| <%= path.join(".") %> | <%= prop.enum ? "enum" : prop.type %> | <%= prop.description %> |\n',
'<% } %>'
].join('');
var render = compileTemplate([
'| <%= path.join(".") %> ',
'| <%= ctx.enum ? "enum" : ctx.type %> ',
'| <%= ctx.description %> |'
].join(''), 'path,ctx');
function walk(out, path, ctx) {
if (path.length === 0) {
out.push(renderRoot(path, ctx));
} else {
out.push(render(path, ctx));
}
if (ctx.properties) {
for (var name in ctx.properties) {
walk(out, path.concat(name), ctx.properties[name]);
function walk(out, path, prop, render) {
out.push(render(path, prop));
if (prop.properties) {
for (var name in prop.properties) {
walk(out, path.concat(name), prop.properties[name], render);
}

@@ -33,8 +27,8 @@ }

function jsonDoc(schema) {
var out = [];
walk(out, [], schema);
return out.join('\n');
function jsonDoc(schema, template) {
var out = [], render = compile(template || defaultTemplate, 'path,prop');
walk(out, [], schema, render);
return out.join('');
}
module.exports = jsonDoc;
{
"name": "json-doc",
"version": "0.0.1",
"version": "0.0.2",
"description": "Make Markdown from JSON Schema",

@@ -5,0 +5,0 @@ "author": "snoguchi",

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