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 1.0.0 to 2.0.0-rc.1

test/fixture/display/expected.json

12

index.js
'use strict';
module.exports = {
byGroupAndType : require('./src/byGroupAndType'),
byType : require('./src/byType.js'),
flat : require('./src/flat'),
eachItem : require('./src/eachItem'),
markdown: require('./src/markdown'),
display: require('./src/display'),
groupName: require('./src/groupName'),
shortcutIcon: require('./src/shortcutIcon')
shortcutIcon: require('./src/shortcutIcon'),
};
{
"name": "sassdoc-extras",
"description": "SassDoc's Toolbelt",
"version": "1.0.0",
"version": "2.0.0-rc.1",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

'use strict';
var eachItem = require('./eachItem');
module.exports = function (data){
module.exports = function byGroupAndType(data) {
var byGroupAndType = {};
eachItem(data, function (item, type){
var group = item.group[0][0];
data.forEach(function (item) {
var group = item.group[0];
var type = item.context.type;
if (byGroupAndType[group] === undefined) {
if (!(group in byGroupAndType)) {
byGroupAndType[group] = {};
}
if (!Array.isArray(byGroupAndType[group][type])){
if (!(type in byGroupAndType[group])) {
byGroupAndType[group][type] = [];

@@ -17,0 +16,0 @@ }

'use strict';
var eachItem = require('./eachItem');
module.exports = function (data) {
module.exports = function byType(data) {
var byType = {};
eachItem(data, function (item, type) {
data.forEach(function (item) {
var type = item.context.type;
if (!(type in byType)) {

@@ -10,0 +10,0 @@ byType[type] = [];

'use strict';
var eachItem = require('./eachItem');
/**

@@ -9,20 +7,10 @@ * Compute a `display` property regarding of access display

*/
module.exports = function (ctx) {
var shouldBeDisplayed = function (item) {
var displayItemAccess = ctx.view.display.access.indexOf(item.access[0]) !== -1;
module.exports = function display(ctx) {
ctx.data = ctx.data.filter(function (item) {
var displayItemAccess = ctx.display.access.indexOf(item.access) !== -1;
var isAlias = item.alias;
var displayAlias = ctx.view.display.alias;
var displayAlias = ctx.display.alias;
return displayItemAccess && !(isAlias && !displayAlias);
};
ctx.data.count = 0;
eachItem(ctx.data, function (item) {
item.display = shouldBeDisplayed(item);
if (item.display) {
ctx.data.count++;
}
});
};
'use strict';
var eachItem = require('./eachItem');
/**

@@ -11,25 +9,21 @@ * Compute a `groupName` object from `group` array with slug as key and

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

@@ -36,0 +30,0 @@

@@ -5,8 +5,4 @@ 'use strict';

module.exports = function (ctx) {
module.exports = function markdown(ctx) {
if (ctx.package && ctx.package.description) {
ctx.package.htmlDescription = marked(ctx.package.description);
}
/**

@@ -24,6 +20,6 @@ * Wrapper for `marked` that takes only one argument to avoid

*/
function applyKey(fn, key, newKey) {
function applyKey(fn, key) {
return function (obj) {
if (key in obj) {
obj[newKey] = fn(obj[key]);
obj[key] = fn(obj[key]);
}

@@ -35,53 +31,59 @@

for (var type in ctx.data) {
for (var name in ctx.data[type]) {
var item = ctx.data[type][name];
if (ctx.package && ctx.package.description) {
ctx.package.description = md(ctx.package.description);
}
if ('description' in item) {
item.htmlDescription = marked(item.description);
}
ctx.data.forEach(function (item) {
if ('description' in item) {
item.description = marked(item.description);
}
if ('author' in item) {
item.htmlAuthor = item.author.map(md);
}
if ('content' in item && item.content.description) {
item.content.description = marked(item.content.description);
}
if ('throws' in item) {
item.htmlThrows = item.throws.map(md);
}
if ('return' in item && item.return.description) {
item.return.description = marked(item.return.description);
}
if ('todo' in item) {
item.htmlTodo = item.todo.map(md);
}
if ('deprecated' in item) {
item.deprecated = marked(item.deprecated);
}
if ('returns' in item) {
item.htmlReturns = item.returns.map(
applyKey(md, 'description', 'htmlDescription')
);
}
if ('author' in item) {
item.author = item.author.map(md);
}
if ('example' in item) {
item.example = item.example.map(
applyKey(md, 'description', 'htmlDescription')
);
}
if ('throw' in item) {
item.throw = item.throw.map(md);
}
if ('parameters' in item) {
item.parameters = item.parameters.map(
applyKey(md, 'description', 'htmlDescription')
);
}
if ('todo' in item) {
item.todo = item.todo.map(md);
}
if ('prop' in item) {
item.prop = item.prop.map(
applyKey(md, 'description', 'htmlDescription')
);
}
if ('example' in item) {
item.example = item.example.map(
applyKey(md, 'description')
);
}
if ('content' in item) {
item.content = item.content.map(
applyKey(md, 'description', 'htmlDescription')
);
}
if ('parameter' in item) {
item.parameter = item.parameter.map(
applyKey(md, 'description')
);
}
}
if ('property' in item) {
item.property = item.property.map(
applyKey(md, 'description')
);
}
if ('since' in item) {
item.since = item.content.map(
applyKey(md, 'description')
);
}
});
};

@@ -5,3 +5,2 @@ 'use strict';

/**

@@ -11,3 +10,3 @@ * Figure out a shortcut icon, and whether it is external or a local

*
* You can specify a local or external URL in `ctx.view.shortcutIcon`.
* You can specify a local or external URL in `ctx.shortcutIcon`.
*

@@ -25,4 +24,4 @@ * For a local file, it will be relative to `ctx.dir`.

*/
module.exports = function (ctx) {
var icon = ctx.view.shortcutIcon;
module.exports = function shortcutIcon(ctx) {
var icon = ctx.shortcutIcon;

@@ -34,3 +33,3 @@ if (!icon) {

if (/^([a-z]+:)?\/\//.test(icon)) {
// External URL
// External URL.
ctx.shortcutIcon = {type: 'external', url: icon};

@@ -37,0 +36,0 @@ return;

var assert = require('assert');
describe('#byGroupAndType', function(){
describe('#byGroupAndType', function () {
var indexByGroupAndType = require('../src/byGroupAndType');
it('should group by group name and type', function(){
var data = [{
'name': 'name',
'context': {'type': 'function'},
'group': ['test']
}, {
'name': 'name1',
'context': {'type': 'function'},
'group': ['nogroup']
}, {
'name': 'name',
'context': {'type': 'mixin'},
'group': ['test']
}, {
'name': 'name1',
'context': {'type': 'mixin'},
'group': ['nogroup']
}];
var data = {
'function' : {
'name' : {
'name' : 'name',
'group' : [['test']]
},
'name1' : {
'name' : 'name1',
'group' : [['nogroup']]
}
},
'mixin' : {
'name' : {
'name' : 'name',
'group' : [['test']]
},
'name1' : {
'name' : 'name1',
'group' : [['nogroup']]
}
}
};
var expected = {
'nogroup' : {
'function' : [{'name' : 'name1', 'group' : [['nogroup']]}],
'mixin' : [{'name' : 'name1', 'group' : [['nogroup']]}]
'nogroup': {
'function': [{'name': 'name1', 'context': {'type': 'function'}, 'group': ['nogroup']}],
'mixin': [{'name': 'name1', 'context': {'type': 'mixin'}, 'group': ['nogroup']}]
},
'test' : {
'function' : [{'name' : 'name', 'group' : [['test']]}],
'mixin' : [{'name' : 'name', 'group' : [['test']]}]
'test': {
'function': [{'name': 'name', 'context': {'type': 'function'}, 'group': ['test']}],
'mixin': [{'name': 'name', 'context': {'type': 'mixin'}, 'group': ['test']}]
}

@@ -44,5 +37,3 @@ };

assert.deepEqual(indexByGroupAndType(data), expected);
});
});
});

@@ -9,18 +9,13 @@ 'use strict';

it('should group by type', function () {
var data = {
'function': {
'name': {
'name': 'name',
},
},
'mixin': {
'name': {
'name': 'name',
},
},
};
var data = [{
'name': 'name',
'context': {'type': 'function'}
}, {
'name': 'name',
'context': {'type': 'mixin'}
}];
var expected = {
'function': [{'name': 'name'}],
'mixin': [{'name': 'name'}],
'function': [{'name': 'name', 'context': {'type': 'function'}}],
'mixin': [{'name': 'name', 'context': {'type': 'mixin'}}],
};

@@ -27,0 +22,0 @@

@@ -9,15 +9,11 @@ /* global describe, it */

var show_input = require('./fixture/display/show.input');
var show_expected = require('./fixture/display/show.expected');
display(show_input);
var input = require('./fixture/display/input');
var expected = require('./fixture/display/expected');
var hide_input = require('./fixture/display/hide.input');
var hide_expected = require('./fixture/display/hide.expected');
display(hide_input);
display(input);
it('should match expected ctx', function () {
assert.deepEqual(show_input, show_expected);
assert.deepEqual(hide_input, hide_expected);
assert.deepEqual(input, expected);
});
});
{
"view": {
"display": {
"access": [
"public",
"private"
],
"alias": true,
"watermark": true
},
"groups": {
"undefined": "Ungrouped",
"foo": "Foo group",
"bar": "Bar group"
},
"theme": "default"
},
"data": {
"function": {
"test-func-group-undef": {
"description": "Test: function group undefined.\n",
"context": {
"type": "function",
"name": "test-func-group-undef"
},
"group": [
[
"undefined"
]
],
"access": [
"public"
],
"groupName": {
"undefined": "Ungrouped"
}
},
"test-func-group-foo": {
"description": "Test: function group foo.\n",
"context": {
"type": "function",
"name": "test-func-group-foo"
},
"group": [
[
"foo"
]
],
"access": [
"public"
],
"groupName": {
"foo": "Foo group"
}
},
"test-func-group-bar": {
"description": "Test: function group bar.\n",
"context": {
"type": "function",
"name": "test-func-group-bar"
},
"group": [
[
"bar"
]
],
"access": [
"public"
],
"groupName": {
"bar": "Bar group"
}
}
}
},
"groups": {

@@ -80,3 +6,49 @@ "undefined": "Ungrouped",

"bar": "Bar group"
}
},
"data": [{
"description": "Test: function group undefined.\n",
"context": {
"type": "function",
"name": "test-func-group-undef"
},
"group": [
"undefined"
],
"access": [
"public"
],
"groupName": {
"undefined": "Ungrouped"
}
}, {
"description": "Test: function group foo.\n",
"context": {
"type": "function",
"name": "test-func-group-foo"
},
"group": [
"foo"
],
"access": [
"public"
],
"groupName": {
"foo": "Foo group"
}
}, {
"description": "Test: function group bar.\n",
"context": {
"type": "function",
"name": "test-func-group-bar"
},
"group": [
"bar"
],
"access": [
"public"
],
"groupName": {
"bar": "Bar group"
}
}]
}
{
"view": {
"display": {
"access": [
"public",
"private"
],
"alias": true,
"watermark": true
"groups": {
"undefined": "Ungrouped",
"foo": "Foo group",
"bar": "Bar group"
},
"data": [{
"description": "Test: function group undefined.\n",
"context": {
"type": "function",
"name": "test-func-group-undef"
},
"groups": {
"undefined": "Ungrouped",
"foo": "Foo group",
"bar": "Bar group"
"group": [
"undefined"
],
"access": [
"public"
]
}, {
"description": "Test: function group foo.\n",
"context": {
"type": "function",
"name": "test-func-group-foo"
},
"theme": "default"
},
"data": {
"function": {
"test-func-group-undef": {
"description": "Test: function group undefined.\n",
"context": {
"type": "function",
"name": "test-func-group-undef"
},
"group": [
[
"undefined"
]
],
"access": [
"public"
]
},
"test-func-group-foo": {
"description": "Test: function group foo.\n",
"context": {
"type": "function",
"name": "test-func-group-foo"
},
"group": [
[
"foo"
]
],
"access": [
"public"
]
},
"test-func-group-bar": {
"description": "Test: function group bar.\n",
"context": {
"type": "function",
"name": "test-func-group-bar"
},
"group": [
[
"bar"
]
],
"access": [
"public"
]
}
}
}
"group": [
"foo"
],
"access": [
"public"
]
}, {
"description": "Test: function group bar.\n",
"context": {
"type": "function",
"name": "test-func-group-bar"
},
"group": [
"bar"
],
"access": [
"public"
]
}]
}
{
"package":{
"description":"Test markdown description.",
"htmlDescription":"<p>Test markdown description.</p>\n"
"package": {
"description": "<p>Test markdown description.</p>\n"
},
"data":{
"function":{
"test-func-markdown":{
"description":"Test: function markdown.\n",
"context":{
"type":"function",
"name":"test-func-markdown"
},
"author":[
"Hugo Giraudel"
],
"todo":[
"Todo description"
],
"parameters":[
{
"type":"String",
"name":"one",
"description":"Param one description",
"htmlDescription":"<p>Param one description</p>\n"
},
{
"type":"String",
"name":"two",
"description":"Param two description",
"htmlDescription":"<p>Param two description</p>\n"
}
],
"throws":[
"Throws description"
],
"returns":[
{
"type":"*",
"description":"Returns description",
"htmlDescription":"<p>Returns description</p>\n"
}
],
"content":[
{
"description":"This should be parsed as Markdown",
"htmlDescription":"<p>This should be parsed as Markdown</p>\n"
}
],
"htmlDescription":"<p>Test: function markdown.</p>\n",
"htmlAuthor":[
"<p>Hugo Giraudel</p>\n"
],
"htmlThrows":[
"<p>Throws description</p>\n"
],
"htmlTodo":[
"<p>Todo description</p>\n"
],
"htmlReturns":[
{
"type":"*",
"description":"Returns description",
"htmlDescription":"<p>Returns description</p>\n"
}
]
}
}
}
"data": [{
"description": "<p>Test: function markdown.</p>\n",
"deprecated": "<p>deprecated</p>\n",
"context": {
"type": "function",
"name": "test-func-markdown"
},
"author": [
"<p>Hugo Giraudel</p>\n"
],
"todo": [
"<p>Todo description</p>\n"
],
"parameter": [{
"type": "String",
"name": "one",
"description": "<p>Param one description</p>\n"
}, {
"type": "String",
"name": "two",
"description": "<p>Param two description</p>\n"
}],
"throw": [
"<p>Throws description</p>\n"
],
"return": {
"type": "*",
"description": "<p>Returns description</p>\n"
},
"content": {
"description": "<p>This should be parsed as Markdown</p>\n"
}
}]
}

@@ -5,45 +5,38 @@ {

},
"data": {
"function": {
"test-func-markdown": {
"description": "Test: function markdown.\n",
"context": {
"type": "function",
"name": "test-func-markdown"
},
"author": [
"Hugo Giraudel"
],
"todo": [
"Todo description"
],
"parameters": [
{
"type": "String",
"name": "one",
"description": "Param one description"
},
{
"type": "String",
"name": "two",
"description": "Param two description"
}
],
"throws": [
"Throws description"
],
"returns": [
{
"type": "*",
"description": "Returns description"
}
],
"content": [
{
"description": "This should be parsed as Markdown"
}
]
"data": [{
"description": "Test: function markdown.\n",
"deprecated": "deprecated",
"context": {
"type": "function",
"name": "test-func-markdown"
},
"author": [
"Hugo Giraudel"
],
"todo": [
"Todo description"
],
"parameter": [
{
"type": "String",
"name": "one",
"description": "Param one description"
},
{
"type": "String",
"name": "two",
"description": "Param two description"
}
],
"throw": [
"Throws description"
],
"return": {
"type": "*",
"description": "Returns description"
},
"content": {
"description": "This should be parsed as Markdown"
}
}
}]
}
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