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

sassdoc-extras

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sassdoc-extras - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

18

index.js

@@ -1,10 +0,10 @@

'use strict';
'use strict'
module.exports = exports = function (ctx) {
for (var i = 1; i < arguments.length; ++i) {
exports[arguments[i]](ctx);
exports[arguments[i]](ctx)
}
};
}
[
var extras = [
'description',

@@ -18,5 +18,7 @@ 'markdown',

'sort',
'resolveVariables',
].forEach(function (name) {
exports[name] = require('./src/' + name);
});
'resolveVariables'
]
extras.forEach(function (name) {
exports[name] = require('./src/' + name)
})
{
"name": "sassdoc-extras",
"description": "SassDoc's Toolbelt",
"version": "2.4.1",
"version": "2.4.2",
"keywords": [

@@ -28,13 +28,18 @@ "sassdoc",

"dependencies": {
"marked": "^0.3.0"
"marked": "^0.3.9"
},
"devDependencies": {
"jshint": "^2.6.0",
"mocha": "^2.1.0"
"mocha": "^3.2.0",
"standard": "^10.0.0"
},
"scripts": {
"lint": "jshint index.js src/*.js test/*.js --verbose",
"lint": "standard index.js src/*.js test/*.js --verbose",
"pretest": "npm run lint",
"test": "mocha test/*.test.js"
},
"standard": {
"env": {
"mocha": true
}
}
}
# SassDoc Extras [![npm version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
[![Greenkeeper badge](https://badges.greenkeeper.io/SassDoc/sassdoc-extras.svg)](https://greenkeeper.io/)
Extra tools for SassDoc theme authors. See [documentation](http://sassdoc.com/extra-tools/).

@@ -4,0 +6,0 @@

@@ -1,22 +0,22 @@

'use strict';
'use strict'
module.exports = function byGroupAndType(data) {
var sorted = {};
module.exports = function byGroupAndType (data) {
var sorted = {}
data.forEach(function (item) {
var group = item.group[0];
var type = item.context.type;
var group = item.group[0]
var type = item.context.type
if (!(group in sorted)) {
sorted[group] = {};
sorted[group] = {}
}
if (!(type in sorted[group])) {
sorted[group][type] = [];
sorted[group][type] = []
}
sorted[group][type].push(item);
});
sorted[group][type].push(item)
})
return sorted;
};
return sorted
}

@@ -1,17 +0,17 @@

'use strict';
'use strict'
module.exports = function byType(data) {
var sorted = {};
module.exports = function byType (data) {
var sorted = {}
data.forEach(function (item) {
var type = item.context.type;
var type = item.context.type
if (!(type in sorted)) {
sorted[type] = [];
sorted[type] = []
}
sorted[type].push(item);
});
sorted[type].push(item)
})
return sorted;
};
return sorted
}

@@ -1,6 +0,6 @@

'use strict';
'use strict'
var fs = require('fs');
var path = require('path');
var s = require('util').format;
var fs = require('fs')
var path = require('path')
var s = require('util').format

@@ -10,16 +10,16 @@ /**

*/
module.exports = function description(ctx) {
module.exports = function description (ctx) {
if (!ctx.descriptionPath) {
return;
return
}
ctx.description = tryLoadFile(ctx);
};
ctx.description = tryLoadFile(ctx)
}
function tryLoadFile(ctx) {
var desc = ctx.descriptionPath;
var filePath = path.resolve(ctx.dir || process.cwd(), desc);
function tryLoadFile (ctx) {
var desc = ctx.descriptionPath
var filePath = path.resolve(ctx.dir || process.cwd(), desc)
try {
return fs.readFileSync(filePath, { encoding: 'utf8' });
return fs.readFileSync(filePath, { encoding: 'utf8' })
} catch (e) {

@@ -29,9 +29,9 @@ if (e.code === 'ENOENT') {

s('Description file not found: `%s` given.', desc)
));
))
} else {
ctx.emit('warning', e);
ctx.emit('warning', e)
}
}
return false;
return false
}

@@ -1,2 +0,2 @@

'use strict';
'use strict'

@@ -7,10 +7,10 @@ /**

*/
module.exports = function display(ctx) {
module.exports = function display (ctx) {
ctx.data = ctx.data.filter(function (item) {
var displayItemAccess = ctx.display.access ? (ctx.display.access.indexOf(item.access) !== -1) : false;
var isAlias = item.alias;
var displayAlias = ctx.display.alias;
var displayItemAccess = ctx.display.access ? (ctx.display.access.indexOf(item.access) !== -1) : false
var isAlias = item.alias
var displayAlias = ctx.display.alias
return displayItemAccess && !(isAlias && !displayAlias);
});
};
return displayItemAccess && !(isAlias && !displayAlias)
})
}

@@ -1,2 +0,2 @@

'use strict';
'use strict'

@@ -9,25 +9,25 @@ /**

*/
module.exports = function groupName(ctx) {
ctx.groups = ctx.groups || {};
module.exports = function groupName (ctx) {
ctx.groups = ctx.groups || {}
// Lowercase the slugs.
Object.keys(ctx.groups).forEach(function (slug) {
ctx.groups[slug.toLowerCase()] = ctx.groups[slug];
});
ctx.groups[slug.toLowerCase()] = ctx.groups[slug]
})
ctx.data.forEach(function (item) {
var group = {};
var group = {}
item.group.forEach(function (slug) {
slug = slug.toLowerCase();
slug = slug.toLowerCase()
if (slug in ctx.groups) {
group[slug] = ctx.groups[slug];
group[slug] = ctx.groups[slug]
} else {
group[slug] = ctx.groups[slug] = slug;
group[slug] = ctx.groups[slug] = slug
}
});
})
item.groupName = group;
});
};
item.groupName = group
})
}

@@ -1,7 +0,6 @@

'use strict';
'use strict'
var marked = require('marked');
var marked = require('marked')
module.exports = function markdown(ctx) {
module.exports = function markdown (ctx) {
/**

@@ -11,4 +10,4 @@ * Wrapper for `marked` that takes only one argument to avoid

*/
function md(str) {
return marked(str);
function md (str) {
return marked(str)
}

@@ -20,18 +19,18 @@

*/
function applyKey(fn, key) {
function applyKey (fn, key) {
return function (obj) {
if (key in obj) {
obj[key] = fn(obj[key]);
obj[key] = fn(obj[key])
}
return obj;
};
return obj
}
}
if (ctx.package && ctx.package.description) {
ctx.package.description = md(ctx.package.description);
ctx.package.description = md(ctx.package.description)
}
if (ctx.description) {
ctx.description = md(ctx.description);
ctx.description = md(ctx.description)
}

@@ -41,31 +40,31 @@

if ('description' in item) {
item.description = marked(item.description);
item.description = marked(item.description)
}
if ('output' in item) {
item.output = marked(item.output);
item.output = marked(item.output)
}
if ('content' in item && item.content.description) {
item.content.description = marked(item.content.description);
item.content.description = marked(item.content.description)
}
if ('return' in item && item.return.description) {
item.return.description = marked(item.return.description);
item.return.description = marked(item.return.description)
}
if ('deprecated' in item) {
item.deprecated = marked(item.deprecated);
item.deprecated = marked(item.deprecated)
}
if ('author' in item) {
item.author = item.author.map(md);
item.author = item.author.map(md)
}
if ('throw' in item) {
item.throw = item.throw.map(md);
item.throw = item.throw.map(md)
}
if ('todo' in item) {
item.todo = item.todo.map(md);
item.todo = item.todo.map(md)
}

@@ -76,3 +75,3 @@

applyKey(md, 'description')
);
)
}

@@ -83,3 +82,3 @@

applyKey(md, 'description')
);
)
}

@@ -90,3 +89,3 @@

applyKey(md, 'description')
);
)
}

@@ -97,5 +96,5 @@

applyKey(md, 'description')
);
)
}
});
};
})
}

@@ -1,2 +0,2 @@

'use strict';
'use strict'

@@ -6,4 +6,4 @@ /**

*/
module.exports = function resolveVariables(ctx) {
var cache = {};
module.exports = function resolveVariables (ctx) {
var cache = {}

@@ -13,10 +13,10 @@ ctx.data

.forEach(function (item) {
cache[item.context.name] = item.context.value;
});
cache[item.context.name] = item.context.value
})
for (var item in cache) {
var value = variableValue(cache[item]);
var value = variableValue(cache[item])
if (value) {
cache[item] = cache[value[1]];
cache[item] = cache[value[1]]
}

@@ -28,3 +28,3 @@ }

if (isVariable(item)) {
item.resolvedValue = cache[item.context.name];
item.resolvedValue = cache[item.context.name]
}

@@ -34,6 +34,6 @@

item.property.forEach(function (prop) {
var value = variableValue(prop.default);
var value = variableValue(prop.default)
prop.resolvedValue = value ? cache[value[1]] : prop.default;
});
prop.resolvedValue = value ? cache[value[1]] : prop.default
})
}

@@ -43,9 +43,9 @@

item.parameter.forEach(function (param) {
var value = variableValue(param.default);
var value = variableValue(param.default)
param.resolvedValue = value ? cache[value[1]] : param.default;
});
param.resolvedValue = value ? cache[value[1]] : param.default
})
}
});
};
})
}

@@ -57,5 +57,5 @@ /**

*/
function isVariable(item) {
function isVariable (item) {
return typeof item.context.type === 'string' &&
item.context.type.toLowerCase() === 'variable';
item.context.type.toLowerCase() === 'variable'
}

@@ -68,4 +68,4 @@

*/
function variableValue(value) {
return /^\s*\$([a-z0-9_-]+)$/i.exec(value);
function variableValue (value) {
return /^\s*\$([a-z0-9_-]+)$/i.exec(value)
}

@@ -1,4 +0,4 @@

'use strict';
'use strict'
var path = require('path');
var path = require('path')

@@ -22,7 +22,7 @@ /**

*/
module.exports = function shortcutIcon(ctx) {
var icon = ctx.shortcutIcon;
module.exports = function shortcutIcon (ctx) {
var icon = ctx.shortcutIcon
if (!icon) {
return;
return
}

@@ -32,4 +32,8 @@

// External URL.
ctx.shortcutIcon = {type: 'external', url: icon};
return;
ctx.shortcutIcon = {
type: 'external',
url: icon
}
return
}

@@ -40,4 +44,4 @@

url: path.basename(icon),
path: path.resolve(ctx.dir, icon),
};
};
path: path.resolve(ctx.dir, icon)
}
}

@@ -1,2 +0,2 @@

'use strict';
'use strict'

@@ -7,9 +7,9 @@ /**

*/
module.exports = function display(ctx) {
module.exports = function display (ctx) {
if (!ctx.sort) {
return;
return
}
ctx.data = ctx.data.sort(compareData(ctx.sort));
};
ctx.data = ctx.data.sort(compareData(ctx.sort))
}

@@ -22,8 +22,8 @@ /**

*/
function compareData(sort) {
function compareData (sort) {
return function (a, b) {
for (var i = 0; i < sort.length; ++i) {
var parts = parseCriteria(sort[i]);
var key = parts[0];
var desc = parts[1];
var parts = parseCriteria(sort[i])
var key = parts[0]
var desc = parts[1]

@@ -33,60 +33,60 @@ var comparison = compare(

getComparisonValue(key, b)
);
)
if (desc) {
comparison = invert(comparison);
comparison = invert(comparison)
}
if (comparison) {
return comparison;
return comparison
}
}
return 0;
};
return 0
}
}
function getComparisonValue(key, item) {
function getComparisonValue (key, item) {
switch (key) {
case 'group': return item.group[0].toLowerCase();
case 'file': return item.file.path;
case 'line': return item.context.line.start;
case 'access': return parseAccess(item.access);
default: throw new Error('Unknown sort criteria `' + key + '`');
case 'group': return item.group[0].toLowerCase()
case 'file': return item.file.path
case 'line': return item.context.line.start
case 'access': return parseAccess(item.access)
default: throw new Error('Unknown sort criteria `' + key + '`')
}
}
function parseAccess(access) {
function parseAccess (access) {
switch (access) {
case 'public': return 1;
case 'private': return 2;
default: return 3;
case 'public': return 1
case 'private': return 2
default: return 3
}
}
function parseCriteria(key) {
var last = key[key.length - 1];
var invert = false;
function parseCriteria (key) {
var last = key[key.length - 1]
var invert = false
if (last === '<' || last === '>') {
key = key.substr(0, key.length - 1);
}
if (last === '<' || last === '>') {
key = key.substr(0, key.length - 1)
}
if (last === '>') {
invert = true;
}
if (last === '>') {
invert = true
}
return [key, invert];
return [key, invert]
}
function invert(comparison) {
return !comparison ? 0 : -1 * comparison;
function invert (comparison) {
return !comparison ? 0 : -1 * comparison
}
function compare(a, b) {
function compare (a, b) {
switch (true) {
case a > b: return 1;
case a === b: return 0;
default: return -1;
case a > b: return 1
case a === b: return 0
default: return -1
}
}
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