Socket
Socket
Sign inDemoInstall

markdown-documentation-generator

Package Overview
Dependencies
113
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.1 to 2.6.0

49

index.js

@@ -8,3 +8,4 @@ #!/usr/bin/env node

var formatters = require('./lib/md-formats');
var listFiles = require('./lib/log');
var logFiles = require('./lib/log');
var log = require('./lib/log').generic;
var sanitize = require('./lib/sanitize');

@@ -47,3 +48,3 @@ var sorting = require('./lib/sorts');

handlebarsPartials: {
"jquery": sanitize.path('./', 'template/jquery.js'),
"jquery": path.resolve(__dirname, 'template/jquery.js'),
"sticky": sanitize.path('./', 'template/sticky.js')

@@ -60,2 +61,6 @@ },

smartypants: true
},
logging: {
prefix: "[Style Guide]",
level: "verbose"
}

@@ -76,3 +81,3 @@ };

fs.writeFileSync(configFilePath, JSON.stringify(options,null,'\t'));
listFiles(configFilePath, 'create');
logFiles(configFilePath, 'create');
}

@@ -158,3 +163,3 @@

//Resolve paths for only a custom rootFolder
if (customOptions.rootFolder){
if (customOptions.rootFolder) {
defaults.highlightFolder = getPath(defaults.highlightFolder);

@@ -167,2 +172,7 @@ defaults.templateFile = getPath(defaults.templateFile);

let logging = Object.assign({}, defaults.logging, customOptions.logging || {});
_sg.logLevel = logging.level;
_sg.logPre = _sg.brand(logging.prefix);
//Overwrite default sections with custom ones if they exist

@@ -195,3 +205,3 @@ defaults.sections = customOptions.sections || defaults.sections;

try {
listFiles(_sg.brand('Configuration'));
logFiles(_sg.brand('Configuration'));
//Read passed object or .styleguide file

@@ -208,6 +218,5 @@ customOptions = customOptions || fs.readJSONSync('.styleguide', 'utf8');

if (_.isUndefined(customOptions)) {
console.info(_sg.warn(
_sg.logPre +
log(_sg.warn(
'No configuration file (\'.styleguide\') or options found, using defaults.'
));
), 1);

@@ -233,9 +242,9 @@ customOptions = {

try {
listFiles(_sg.brand('Template: ') + options.templateFile);
logFiles(_sg.brand('Template: ') + options.templateFile);
_sg.templateSource = fs.readFileSync(path.resolve(_sg.root, options.templateFile), 'utf8');
listFiles(_sg.brand('Theme: ') + options.themeFile);
logFiles(_sg.brand('Theme: ') + options.themeFile);
_sg.themeSource = fs.readFileSync(path.resolve(_sg.root, options.themeFile), 'utf8');
listFiles(_sg.brand('Highlight Style: ') +
logFiles(_sg.brand('Highlight Style: ') +
path.relative(_sg.root, path.join(options.highlightFolder, options.highlightStyle + '.css')));

@@ -323,4 +332,4 @@ _sg.highlightSource = fs.readFileSync(path.join(

if (_.isUndefined(sectionIdentifier)) {
console.info(_sg.logPre + _sg.warn("Warning: '" + chalk.bold(articleData.currentSection) +
"' is not a registered section in your configuration. (" + articleData.filelocation + ")"));
log(_sg.warn("Warning: '" + chalk.bold(articleData.currentSection) +
"' is not a registered section in your configuration. (" + articleData.filelocation + ")"), 1);
sectionIdentifier = '';

@@ -620,3 +629,3 @@ }

listFiles(path.relative(_sg.root, filePath));
logFiles(path.relative(_sg.root, filePath));

@@ -663,3 +672,3 @@ if (err) {

else {
listFiles(options.htmlOutput, 'create');
logFiles(options.htmlOutput, 'create');
}

@@ -677,3 +686,3 @@ });

else {
listFiles(options.jsonOutput, 'create');
logFiles(options.jsonOutput, 'create');
}

@@ -701,3 +710,3 @@ });

console.info(_sg.logPre + _sg.info('Reading ' + extensions + ' files...'));
log(_sg.info('Reading ' + extensions + ' files...'), 2);

@@ -726,4 +735,4 @@ //Send back file contents once walker has reached its end

if (fileContents.length <= 0) {
console.info('\n'+
_sg.warn(_sg.logPre +
log('\n'+
_sg.warn(
'Could not find anything to document.')+

@@ -736,3 +745,3 @@ '\n Please check the following:'+

chalk.blue.bold('github.com/UWHealth/markdown-documentation-generator/')
);
, 1);
}

@@ -739,0 +748,0 @@

@@ -14,11 +14,11 @@ /* jshint node: true */

*/
module.exports = function (fileName, create) {
module.exports = function (fileName, create, level) {
if (create) {
if (create && canShowLog(level || 2)) {
var time = getTime();
return console.info(_sg.logPre + 'Created ' + _sg.good(fileName) + chalk.grey(' ['+time+']'));
return console.info(_sg.logPre, 'Created ' + _sg.good(fileName) + chalk.grey(' ['+time+']'));
}
if (_sg.fileList) {
return console.info(_sg.logPre + 'Reading ' + _sg.info(fileName));
if (_sg.fileList || canShowLog(3)) {
return console.info(_sg.logPre, 'Reading ' + _sg.info(fileName));
}

@@ -28,2 +28,22 @@

module.exports.generic = function(message, level, includeTime) {
const time = includeTime ? chalk.grey(' [' + getTime() + ']') : '';
if (canShowLog(level)) {
return console.info(_sg.logPre, message, time);
}
}
function canShowLog(level) {
const levels = {
"silent": 0,
"minimal": 1,
"default": 2,
"verbose": 3
}
const userLevel = levels[_sg.logLevel] || 2;
return level <= userLevel;
}
function getTime() {

@@ -30,0 +50,0 @@ var time = new Date();

@@ -22,3 +22,3 @@ /* jshint node: true */

try {
listFiles(_sg.brand('Partial: ') + path.relative(_sg.root, file));
listFiles(_sg.brand('Partial: ') + path.relative(_sg.root, file), false, 3);
return fs.readFileSync(file, 'utf8');

@@ -39,13 +39,14 @@ }

module.exports = function(json, options) {
//Register Swag helpers
helpers.registerHelpers(handlebars);
findPathPartials(_sg.templateSource, options.templateFile);
//Run through partials, check if they exist, and register them
for(var partial in options.handlebarsPartials) {
if ({}.hasOwnProperty.call(options.handlebarsPartials, partial)) {
var currentPartial = checkPartial(
path.resolve(_sg.root, options.handlebarsPartials[partial]),
partial
checkAndRegisterPartial(
partial,
path.resolve(_sg.root, options.handlebarsPartials[partial])
);
handlebars.registerPartial(partial, currentPartial);
}

@@ -64,3 +65,3 @@ }

}catch(err) {
console.error(_sg.logPre + _sg.error("Error compiling template"));
console.error(_sg.logPre + _sg.error(new Error("Error compiling template")));
console.error(err);

@@ -71,1 +72,22 @@ process.exit(1);

};
function findPathPartials(template, templatePath) {
const regex = /{{>\s?['"]?((\.|\/)[a-zA-Z\/\.-]*)/g;
let matches;
let partialsFound = {};
while((matches = regex.exec(template)) !== null) {
checkAndRegisterPartial(
matches[1],
path.resolve(path.dirname(templatePath), matches[1])
)
}
}
function checkAndRegisterPartial(partial, partialPath) {
const currentPartial = checkPartial(partialPath, partial);
findPathPartials(currentPartial, partialPath);
handlebars.registerPartial(partial, currentPartial);
}
{
"name": "markdown-documentation-generator",
"version": "2.4.1",
"version": "2.6.0",
"description": "Searches files for markdown and generates a static style/documentation guide. A fork of markdown-styleguide-generator.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,2 +5,42 @@ {

{
"category": "Category",
"id": "styles-category-article",
"articles": [
{
"id": "styles-category-article",
"section": {
"name": "styles",
"styles": true
},
"category": "Category",
"heading": "Article",
"code": [],
"markup": [],
"comment": "<p>Some comments about this thing.</p>",
"priority": 50,
"filelocation": "about.md"
}
]
},
{
"category": "Category TEST",
"id": "styles-category_test-another_article",
"articles": [
{
"id": "styles-category_test-another_article",
"section": {
"name": "styles",
"styles": true
},
"category": "Category TEST",
"heading": "Another Article",
"code": [],
"markup": [],
"comment": "<p>Some more comments about this other thing.</p>",
"priority": 50,
"filelocation": "about.md"
}
]
},
{
"category": "Layout",

@@ -172,3 +212,3 @@ "id": "styles-layout-arrangement_object",

"markup": [],
"comment": "<h2 id=\"-base-colors\" class=\"sg-heading sg-heading-2\"><code id=\"variable--base-colors\" class=\"sg-global-variable sg-code sg-codespan sg-global\" data-code-id=\"$base-colors\">$base-colors</code></h2>\n\n <h3 id=\"map-key-color-value-\" class=\"sg-heading sg-heading-3\">Map (key : color value)</h3>\n<p>Sets up consistent color names to be used for color-palette. Dark and light values will be automatically generated. Key values should be accessed through <code id=\"function-colors\" class=\"sg-global-function sg-code sg-codespan sg-global\" data-code-id=\"colors()\">colors()</code>.\n<br>\n<code class=\"sg-code sg-codespan\">type</code>, <code class=\"sg-code sg-codespan\">links</code>, and <code class=\"sg-code sg-codespan\">bg</code> key values are required for some starter styles. If you choose not to use them, you need to replace their references.</p><p>Supports a nested map style like the following:</p>\n<div class=\"sg-markup sg-codeblock\">\n<pre class=\"sg-markup_wrap\"><code class=\"hljs sg-code undefined\"><span class=\"hljs-variable\">$base-colors</span>: (\n <span class=\"hljs-string\">&apos;type&apos;</span>: (\n <span class=\"hljs-string\">&apos;base&apos;</span>: <span class=\"hljs-number\">#020202</span>,\n <span class=\"hljs-string\">&apos;light&apos;</span>: <span class=\"hljs-number\">#232323</span>,\n <span class=\"hljs-string\">&apos;dark&apos;</span>: <span class=\"hljs-number\">#000</span>\n ),\n <span class=\"hljs-string\">&apos;links&apos;</span>: (\n <span class=\"hljs-string\">&apos;base&apos;</span>: blue,\n <span class=\"hljs-string\">&apos;light&apos;</span>: sky,\n <span class=\"hljs-string\">&apos;dark&apos;</span>: navy\n ),\n <span class=\"hljs-string\">&apos;bg&apos;</span>: (\n <span class=\"hljs-string\">&apos;base&apos;</span>: <span class=\"hljs-number\">#fff</span>,\n <span class=\"hljs-string\">&apos;dark&apos;</span>: <span class=\"hljs-number\">#ddd</span>\n )\n);\n</code></pre>\n</div>",
"comment": "<h2 id=\"-base-colors\" class=\"sg-heading sg-heading-2\"><code id=\"variable--base-colors\" class=\"sg-global-variable sg-code sg-codespan sg-global\" data-code-id=\"$base-colors\">$base-colors</code></h2>\n\n <h3 id=\"map-key-color-value-\" class=\"sg-heading sg-heading-3\">Map (key : color value)</h3>\n<p>Sets up consistent color names to be used for color-palette. Dark and light values will be automatically generated. Key values should be accessed through <code id=\"function-colors\" class=\"sg-global-function sg-code sg-codespan sg-global\" data-code-id=\"colors()\">colors()</code>.\n<br>\n<code class=\"sg-code sg-codespan\">type</code>, <code class=\"sg-code sg-codespan\">links</code>, and <code class=\"sg-code sg-codespan\">bg</code> key values are required for some starter styles. If you choose not to use them, you need to replace their references.</p><p>Supports a nested map style like the following:</p>\n<div class=\"sg-markup sg-codeblock\">\n<pre class=\"sg-markup_wrap\"><code class=\"hljs sg-code \"><span class=\"hljs-variable\">$base-colors</span>: (\n <span class=\"hljs-string\">&apos;type&apos;</span>: (\n <span class=\"hljs-string\">&apos;base&apos;</span>: <span class=\"hljs-number\">#020202</span>,\n <span class=\"hljs-string\">&apos;light&apos;</span>: <span class=\"hljs-number\">#232323</span>,\n <span class=\"hljs-string\">&apos;dark&apos;</span>: <span class=\"hljs-number\">#000</span>\n ),\n <span class=\"hljs-string\">&apos;links&apos;</span>: (\n <span class=\"hljs-string\">&apos;base&apos;</span>: blue,\n <span class=\"hljs-string\">&apos;light&apos;</span>: sky,\n <span class=\"hljs-string\">&apos;dark&apos;</span>: navy\n ),\n <span class=\"hljs-string\">&apos;bg&apos;</span>: (\n <span class=\"hljs-string\">&apos;base&apos;</span>: <span class=\"hljs-number\">#fff</span>,\n <span class=\"hljs-string\">&apos;dark&apos;</span>: <span class=\"hljs-number\">#ddd</span>\n )\n);\n</code></pre>\n</div>",
"priority": 50

@@ -229,2 +269,22 @@ },

{
"category": "Category",
"id": "styles-category-article",
"headings": [
{
"id": "styles-category-article",
"name": "Article"
}
]
},
{
"category": "Category TEST",
"id": "styles-category_test-another_article",
"headings": [
{
"id": "styles-category_test-another_article",
"name": "Another Article"
}
]
},
{
"category": "Layout",

@@ -231,0 +291,0 @@ "id": "styles-layout-arrangement_object",

@@ -13,3 +13,3 @@ module.exports = {

"ext": "js hbs css scss styleguide",
"args": ["ls"]
"args": []
};

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc