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

jsdoc-to-markdown

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdoc-to-markdown - npm Package Compare versions

Comparing version 0.1.9 to 0.2.0

helpers/constructor-has-docs.js

84

bin/cli.js

@@ -5,53 +5,45 @@ #!/usr/bin/env node

var cliArgs = require("command-line-args"),
cp = require("child_process"),
path = require("path"),
util = require("util"),
boil = require("boil-js"),
mfs = require("more-fs"),
dope = require("console-dope");
dope = require("console-dope"),
jsdoc2md = require("../lib/jsdoc-to-markdown");
var cli = cliArgs([
{ name: "template", alias: "t", type: String,
description: "A custom handlebars template to insert the rendered documentation into" },
{ name: "preset", alias: "p", type: String, value: "default",
description: "Use a preset template" },
{ name: "json", alias: "j", type: Boolean,
description: "Output the template data only" },
{ name: "help", alias: "h", type: Boolean,
description: "Print usage information" },
{ name: "src", type: Array, defaultOption: true,
description: "The javascript source files. The default option." },
{ name: "index", type: Boolean,
description: "Print usage information" },
{ name: "skip-heading", type: Boolean,
description: "Skip the module heading" },
]);
var usage = cli.usage({
forms: [ "$ jsdoc2md <options> <source_files>" ]
});
require("../")(boil);
try{
var argv = cli.parse();
} catch(err){
halt(err);
}
var argv = cliArgs([
{ name: "template", alias: "t", type: String },
{ name: "preset", alias: "p", type: String },
{ name: "json", alias: "j", type: Boolean },
{ name: "src", type: Array, defaultOption: true },
]).parse();
if (!argv.src){
dope.red.error("specify at least one source file");
process.exit(1);
if (argv.help){
dope.log(usage);
process.exit(0);
}
var jsdocTemplatePath = path.resolve(__dirname, "..", "jsdoc-template"),
cmd = util.format(
"%s -t %s %s",
path.resolve(__dirname, "..", "node_modules", ".bin", "jsdoc"),
jsdocTemplatePath,
argv.src.join(" ")
);
jsdoc2md.render(argv, function(err, result){
if (err) halt(err);
process.stdout.write(result);
});
function render(data){
var template = "";
if (argv.template){
template = mfs.read(argv.template);
} else if (argv.preset){
template = mfs.read(path.resolve(__dirname, "..", "templates", argv.preset + ".hbs"));
} else {
template = mfs.read(path.resolve(__dirname, "..", "templates", "default.hbs"));
}
console.log(boil.render(template, data));
function halt(err){
dope.red.error("Error: " + err.message);
dope.log(usage);
process.exit(1);
}
cp.exec(cmd, { maxBuffer: 1000 * 1024 }, function(err, stdout, stderr){
if (err){
console.error(err)
throw err;
}
if (argv.json){
console.log(stdout);
} else {
render(JSON.parse(stdout));
}
});
module.exports = function(handlebars){
handlebars.registerHelper("anchorName", function(input){
return input && input.replace(/:/g, "_").replace(/~/g, ".");
handlebars.registerHelper("anchorName", function(longname){
return longname && longname.replace(/:/g, "_").replace(/~/g, ".");
});
};

@@ -0,1 +1,3 @@

var a = require("array-tools");
module.exports = function(handlebars){

@@ -2,0 +4,0 @@ handlebars.registerHelper("instantiate", function(input){

@@ -1,18 +0,68 @@

var FileSet = require("file-set"),
var fileSet = require("file-set"),
boil = require("boil-js"),
mfs = require("more-fs"),
path = require("path");
path = require("path"),
cp = require("child_process"),
util = require("util"),
mfs = require("more-fs"),
a = require("array-tools");
module.exports = function(handlebars){
var fileSet = new FileSet(path.resolve(__dirname, "..", "partials", "*.hbs"));
fileSet.files.forEach(function(file){
handlebars.registerPartial(
path.basename(file, ".hbs"),
mfs.read(file)
);
});
exports.render = render;
var fileSet = new FileSet(path.resolve(__dirname, "..", "helpers", "*.js"));
fileSet.files.forEach(function(file){
require(file)(handlebars);
var partials = fileSet(path.resolve(__dirname, "../partials/*.hbs"));
partials.files.forEach(function(file){
boil.registerPartial(
path.basename(file, ".hbs"),
mfs.read(file)
);
});
var helpers = fileSet(path.resolve(__dirname, "../helpers/*.js"));
helpers.files.forEach(function(file){
require(file)(boil);
});
var compiled = {
default: boil.compile(mfs.read(path.resolve(__dirname, "../presets/default.hbs"))),
globals: boil.compile(mfs.read(path.resolve(__dirname, "../presets/globals.hbs"))),
modules: boil.compile(mfs.read(path.resolve(__dirname, "../presets/modules.hbs")))
};
function render(options, done){
options.src = fileSet(options.src).files;
if (!options.src.length){
done(new Error("specify at least one source file"));
return;
}
var jsdocTemplatePath = path.resolve(__dirname, "..", "lib"),
cmd = util.format(
"%s -t %s %s",
path.resolve(__dirname, "..", "node_modules", ".bin", "jsdoc"),
jsdocTemplatePath,
options.src.join(" ")
);
function renderTemplate(data){
data.argv = options;
if (options.template){
var template = mfs.read(options.template);
if (template){
return boil.render(template, data);
} else {
done(new Error(template === null ? "Template file doesn't exist" : "Template file is empty"));
}
} else {
return compiled[options.preset](data);
}
}
cp.exec(cmd, { maxBuffer: 1000 * 1024 }, function(err, stdout, stderr){
if (err) done(err);
if (options.json){
done(null, stdout);
} else {
done(null, renderTemplate(JSON.parse(stdout)));
}
});
};
}
{
"name": "jsdoc-to-markdown",
"author": "Lloyd Brookes",
"version": "0.1.9",
"version": "0.2.0",
"description": "Render JSdoc documentation as markdown",

@@ -9,3 +9,5 @@ "repository": "https://github.com/75lb/jsdoc-to-markdown",

"scripts": {
"test": ""
"test": "",
"docs": "node test/render.js",
"watch": "baldrick --do 'npm run docs' --when test/input/*/*.js partials/* --change --speak"
},

@@ -22,5 +24,5 @@ "bin": {

"dependencies": {
"array-tools": "^1.0.2",
"array-tools": "^1.1.0",
"boil-js": "^0.1.0",
"command-line-args": "^0.2.0",
"command-line-args": "^0.3.0",
"console-dope": "^0.3.3",

@@ -27,0 +29,0 @@ "file-set": "^0.1.0",

@@ -8,1 +8,2 @@ [![view on npm](http://img.shields.io/npm/v/jsdoc-to-markdown.svg)](https://www.npmjs.org/package/jsdoc-to-markdown)

=================
coming soon.. not yet stable enough to document..

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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