Socket
Socket
Sign inDemoInstall

vue-docgen-cli

Package Overview
Dependencies
Maintainers
3
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-docgen-cli - npm Package Compare versions

Comparing version 4.31.1 to 4.32.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [4.32.0](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.31.2...v4.32.0) (2020-09-08)
**Note:** Version bump only for package vue-docgen-cli
## [4.31.2](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.31.1...v4.31.2) (2020-08-23)
**Note:** Version bump only for package vue-docgen-cli
## [4.31.1](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.31.0...v4.31.1) (2020-08-20)

@@ -8,0 +24,0 @@

48

lib/compileTemplates.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -45,9 +64,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -57,2 +69,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.getDependencies = exports.functionalTag = exports.defaultExample = exports.component = exports.props = exports.slots = exports.methods = exports.events = void 0;
var path = __importStar(require("path"));

@@ -76,9 +89,10 @@ var vue_docgen_api_1 = require("vue-docgen-api");

var utils_1 = require("./templates/utils");
exports.mdclean = utils_1.mdclean;
Object.defineProperty(exports, "mdclean", { enumerable: true, get: function () { return utils_1.mdclean; } });
var docgen_1 = require("./docgen");
exports.docgen = docgen_1.default;
Object.defineProperty(exports, "docgen", { enumerable: true, get: function () { return docgen_1.default; } });
function getDependencies(doc, compDirName) {
var _a;
if (!doc.tags)
if (!doc.tags) {
return [];
}
var requireDep = ((_a = doc.tags.requires) === null || _a === void 0 ? void 0 : _a.map(function (t) { return path.join(compDirName, t.description); })) || [];

@@ -101,6 +115,6 @@ var examplesDep = getDocsBlocks_1.getExamplesFilePaths(doc.tags, compDirName);

function compileTemplates(absolutePath, config, componentRelativePath, subComponent) {
var _a, _b, _c;
if (subComponent === void 0) { subComponent = false; }
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function () {
var options, templates, cwd, doc, props_2, events_2, methods_2, slots_2, isSubComponent, hasSubComponents, subComponentOptions, renderedUsage, _d, componentRelativeDirectoryPath_1, componentAbsoluteDirectoryPath_1, requiresMd, _e, e_1;
var options, templates, cwd, doc, p, e, m, s, isSubComponent, hasSubComponents, subComponentOptions, renderedUsage, _d, componentRelativeDirectoryPath_1, componentAbsoluteDirectoryPath_1, requiresMd, _e, e_1;
return __generator(this, function (_f) {

@@ -116,3 +130,3 @@ switch (_f.label) {

doc = _f.sent();
props_2 = doc.props, events_2 = doc.events, methods_2 = doc.methods, slots_2 = doc.slots;
p = doc.props, e = doc.events, m = doc.methods, s = doc.slots;
isSubComponent = subComponent;

@@ -122,6 +136,6 @@ hasSubComponents = !!((_a = doc.tags) === null || _a === void 0 ? void 0 : _a.requires);

renderedUsage = {
props: props_2 ? templates.props(props_2, subComponentOptions) : '',
slots: slots_2 ? templates.slots(slots_2, subComponentOptions) : '',
methods: methods_2 ? templates.methods(methods_2, subComponentOptions) : '',
events: events_2 ? templates.events(events_2, subComponentOptions) : '',
props: p ? templates.props(p, subComponentOptions) : '',
slots: s ? templates.slots(s, subComponentOptions) : '',
methods: m ? templates.methods(m, subComponentOptions) : '',
events: e ? templates.events(e, subComponentOptions) : '',
functionalTag: templates.functionalTag

@@ -128,0 +142,0 @@ };

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -38,9 +57,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -50,2 +62,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.extractConfig = void 0;
var path = __importStar(require("path"));

@@ -66,4 +79,5 @@ var singleMd_1 = __importDefault(require("./singleMd"));

// if at a level that has no components (top level) just give up
if (!hasComponents(config))
if (!hasComponents(config)) {
return [2 /*return*/];
}
// if componentsRoot is not specified we start with current cwd

@@ -70,0 +84,0 @@ config.componentsRoot = path.resolve(config.cwd, config.componentsRoot);

@@ -13,7 +13,19 @@ "use strict";

};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;

@@ -50,4 +62,4 @@ };

return false;
}, getDestFile: function (file, config) {
return path.resolve(config.outDir, file).replace(/\.\w+$/, '.md');
}, getDestFile: function (file, conf) {
return path.resolve(conf.outDir, file).replace(/\.\w+$/, '.md');
}, editLinkLabel: 'edit on github' }, (fs.existsSync(configFilePath) ? require(configFilePath) : undefined));

@@ -54,0 +66,0 @@ if (!config.getRepoEditUrl && config.docsRepo) {

@@ -46,2 +46,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isParamTag = exports.getExamplesFilePaths = void 0;
var path_1 = require("path");

@@ -48,0 +49,0 @@ var fs_1 = require("fs");

@@ -13,2 +13,21 @@ "use strict";

};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -50,9 +69,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -77,3 +89,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var watcher, allComponentFiles, requiredComponents, componentFiles, docMap;
var _this = this;
return __generator(this, function (_a) {

@@ -89,7 +100,5 @@ switch (_a.label) {

allComponentFiles = _a.sent();
return [4 /*yield*/, Promise.all(allComponentFiles.map(function (compPath) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
return [2 /*return*/, getRequiredComponents(compPath, optionsApi, cwd)];
}); }); }))];
return [4 /*yield*/, Promise.all(allComponentFiles.map(function (compPath) { return getRequiredComponents(compPath, optionsApi, cwd); }))];
case 2:
requiredComponents = (_a.sent()).reduce(function (acc, components) { return acc.concat(components); }, []);
requiredComponents = (_a.sent()).reduce(function (acc, comps) { return acc.concat(comps); }, []);
componentFiles = allComponentFiles.filter(function (compPath) { return !requiredComponents.includes(compPath); });

@@ -108,13 +117,13 @@ docMap = utils_1.getDocMap(

function getRequiredComponents(compPath, optionsApi, cwd) {
var _a, _b;
var _a;
return __awaiter(this, void 0, void 0, function () {
var compDirName, absoluteComponentPath, tags, e_1;
return __generator(this, function (_c) {
switch (_c.label) {
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
compDirName = path.dirname(compPath);
absoluteComponentPath = path.join(cwd, compPath);
_c.label = 1;
_b.label = 1;
case 1:
_c.trys.push([1, 3, , 4]);
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, vue_docgen_api_1.parse(absoluteComponentPath, __assign(__assign({

@@ -124,4 +133,4 @@ // make sure that this is recognized as an option bag

case 2:
tags = (_c.sent()).tags;
if ((_b = (_a = tags) === null || _a === void 0 ? void 0 : _a.requires) === null || _b === void 0 ? void 0 : _b.length) {
tags = (_b.sent()).tags;
if ((_a = tags === null || tags === void 0 ? void 0 : tags.requires) === null || _a === void 0 ? void 0 : _a.length) {
return [2 /*return*/, tags.requires.map(function (t) { return path.join(compDirName, t.description); })];

@@ -131,3 +140,3 @@ }

case 3:
e_1 = _c.sent();
e_1 = _b.sent();
throw new Error("Error parsing " + absoluteComponentPath + " for @requires tags: " + e_1.message);

@@ -134,0 +143,0 @@ case 4: return [2 /*return*/, []];

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -38,9 +57,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -50,2 +62,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.compile = void 0;
var fs = __importStar(require("fs"));

@@ -52,0 +65,0 @@ var path = __importStar(require("path"));

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -38,9 +57,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -50,2 +62,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.compile = void 0;
var path = __importStar(require("path"));

@@ -52,0 +65,0 @@ var utils_1 = require("./utils");

@@ -8,9 +8,11 @@ "use strict";

var frontMatter = [];
if (!config.outFile && deprecated)
if (!config.outFile && deprecated) {
// to avoid having the squiggles in the left menu for deprecated items
// use the frontmatter feature of vuepress
frontMatter.push("title: " + displayName);
if (isSubComponent || hasSubComponents)
}
if (isSubComponent || hasSubComponents) {
// show more than one level on subcomponents
frontMatter.push('sidebarDepth: 2');
}
return (frontMatter.length && !isSubComponent

@@ -17,0 +19,0 @@ ? "\n---\n" + frontMatter.join('\n') + "\n---\n"

@@ -29,5 +29,6 @@ "use strict";

if (opt === void 0) { opt = {}; }
if (Object.keys(methods).length === 0)
if (Object.keys(methods).length === 0) {
return '';
}
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Methods\n\n " + tmpl(methods, opt.isSubComponent || opt.hasSubComponents || false) + "\n ";
});

@@ -12,4 +12,3 @@ "use strict";

var t = pr.description ? pr.description : '';
ret +=
"| " + utils_1.mdclean(p) + " | " + utils_1.mdclean(t) + " | " + utils_1.mdclean(n) + " | " + utils_1.mdclean(v) + " | " + utils_1.mdclean(d) + " |" + '\n';
ret += "| " + utils_1.mdclean(p) + " | " + utils_1.mdclean(t) + " | " + utils_1.mdclean(n) + " | " + utils_1.mdclean(v) + " | " + utils_1.mdclean(d) + " |\n";
});

@@ -16,0 +15,0 @@ return ret;

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.clearCache = exports.findFileCaseInsensitive = exports.mdclean = void 0;
var fs_1 = __importDefault(require("fs"));

@@ -8,0 +9,0 @@ var path_1 = __importDefault(require("path"));

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -38,9 +57,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -50,2 +62,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.findFileCaseInsensitive = exports.getDocMap = exports.writeDownMdFile = void 0;
var path = __importStar(require("path"));

@@ -52,0 +65,0 @@ var fs = __importStar(require("fs"));

{
"name": "vue-docgen-cli",
"version": "4.31.1",
"version": "4.32.0",
"scripts": {

@@ -19,3 +19,3 @@ "compile": "tsc -p ./tsconfig.build.json",

"prettier": "^1.18.2",
"vue-docgen-api": "^4.31.1"
"vue-docgen-api": "^4.32.0"
},

@@ -28,3 +28,3 @@ "devDependencies": {

},
"gitHead": "0c94f679ae9440205744b1a141907d0e2ac3d134"
"gitHead": "eee1e0d9535ef9619080916498d9028853bc6827"
}

@@ -9,4 +9,4 @@ import extractConfig from '../extractConfig'

var mockGetSources: jest.Mock
var mockWatcher: unknown
let mockGetSources: jest.Mock
let mockWatcher: unknown
jest.mock('../getSources', () => {

@@ -20,3 +20,3 @@ mockWatcher = { on: jest.fn(), close: jest.fn() }

var mockSingle: jest.Mock
let mockSingle: jest.Mock
jest.mock('../singleMd', () => {

@@ -27,3 +27,3 @@ mockSingle = jest.fn()

var mockMulti: jest.Mock
let mockMulti: jest.Mock
jest.mock('../multiMd', () => {

@@ -45,21 +45,18 @@ mockMulti = jest.fn()

it('should call multi by default', async done => {
it('should call multi by default', async () => {
await docgen(conf)
expect(mockMulti).toHaveBeenCalled()
expect(mockMulti).toHaveBeenCalledWith(FILES, mockWatcher, conf, DOC_MAP)
done()
})
it('should call single if an outfile is specified', async done => {
it('should call single if an outfile is specified', async () => {
conf.outFile = 'test.md'
await docgen(conf)
expect(mockSingle).toHaveBeenCalledWith(FILES, mockWatcher, conf, DOC_MAP)
done()
})
it('if watch is passed should pass a watcher to compiler', async done => {
it('if watch is passed should pass a watcher to compiler', async () => {
conf.watch = true
await docgen(conf)
expect(mockMulti).toHaveBeenCalledWith(FILES, mockWatcher, conf, DOC_MAP)
done()
})

@@ -66,0 +63,0 @@

import getSources from '../getSources'
var mockWatch: jest.Mock, mockAddWatch: jest.Mock, fakeOn: jest.Mock, mockGlobby: jest.Mock
var fakeWatcher: any
let mockWatch: jest.Mock
let mockAddWatch: jest.Mock
let fakeOn: jest.Mock
let mockGlobby: jest.Mock
let fakeWatcher: any
jest.mock('chokidar', () => {

@@ -46,3 +49,3 @@ mockAddWatch = jest.fn()

describe('getSources', () => {
it('should return component files from chokidar', async done => {
it('should return component files from chokidar', async () => {
const { componentFiles } = await getSources(COMPONENTS_GLOB, 'here', getDocFileName)

@@ -57,6 +60,5 @@ expect(componentFiles).toMatchInlineSnapshot(`

`)
done()
})
it('should return a docMap using the getDocFileName', async done => {
it('should return a docMap using the getDocFileName', async () => {
const { docMap } = await getSources(COMPONENTS_GLOB, 'here', getDocFileName)

@@ -71,10 +73,8 @@ expect(docMap).toMatchInlineSnapshot(`

`)
done()
})
it('should return the watcher so it can be enriched', async done => {
it('should return the watcher so it can be enriched', async () => {
const { watcher } = await getSources(COMPONENTS_GLOB, 'here', getDocFileName)
expect(watcher).toBe(fakeWatcher)
done()
})
})

@@ -10,3 +10,3 @@ import { FSWatcher } from 'chokidar'

var mockWriteDownMdFile: jest.Mock
let mockWriteDownMdFile: jest.Mock
jest.mock('../utils', () => {

@@ -19,5 +19,7 @@ mockWriteDownMdFile = jest.fn(() => Promise.resolve())

var mockCompileMarkdown: jest.Mock
let mockCompileMarkdown: jest.Mock
jest.mock('../compileTemplates', () => {
mockCompileMarkdown = jest.fn(async () => ({ content: FAKE_MD_CONTENT, dependencies: [] }))
mockCompileMarkdown = jest.fn(() =>
Promise.resolve({ content: FAKE_MD_CONTENT, dependencies: [] })
)
return mockCompileMarkdown

@@ -33,3 +35,3 @@ })

const fakeOn = jest.fn()
let w = ({
const w = ({
on: fakeOn.mockImplementation(() => ({ on: fakeOn }))

@@ -46,6 +48,5 @@ } as unknown) as FSWatcher

describe('compile', () => {
it('should get the current components doc', async done => {
it('should get the current components doc', async () => {
await multiMd.compile(conf, {}, w, FAKE_COMPONENT_PATH)
expect(writeDownMdFile).toHaveBeenCalledWith(FAKE_MD_CONTENT, MD_FILE_PATH)
done()
})

@@ -55,10 +56,9 @@ })

describe('default', () => {
it('should build one md from each file passed', async done => {
it('should build one md from each file passed', async () => {
jest.spyOn(multiMd, 'compile').mockImplementation(() => Promise.resolve())
await multiMd.default(FILES, w, conf, {}, multiMd.compile)
expect(multiMd.compile).toHaveBeenCalledTimes(FILES.length)
done()
})
it('should watch file changes if a watcher is passed', async done => {
it('should watch file changes if a watcher is passed', async () => {
conf.watch = true

@@ -70,5 +70,4 @@ fakeOn.mockClear()

expect(fakeOn).toHaveBeenCalledWith('unlink', expect.any(Function))
done()
})
})
})

@@ -9,3 +9,3 @@ import { FSWatcher } from 'chokidar'

var mockWriteDownMdFile: jest.Mock
let mockWriteDownMdFile: jest.Mock
jest.mock('../utils', () => {

@@ -18,5 +18,7 @@ mockWriteDownMdFile = jest.fn(() => Promise.resolve())

var mockCompileMarkdown: jest.Mock
let mockCompileMarkdown: jest.Mock
jest.mock('../compileTemplates', () => {
mockCompileMarkdown = jest.fn(async () => ({ content: FAKE_MD_CONTENT, dependencies: [] }))
mockCompileMarkdown = jest.fn(() =>
Promise.resolve({ content: FAKE_MD_CONTENT, dependencies: [] })
)
return mockCompileMarkdown

@@ -31,3 +33,3 @@ })

const fakeOn = jest.fn()
let w = ({
const w = ({
on: fakeOn.mockImplementation(() => ({ on: fakeOn }))

@@ -44,6 +46,5 @@ } as unknown) as FSWatcher

describe('compile', () => {
it('should get the current components doc', async done => {
it('should get the current components doc', async () => {
await singleMd.compile(conf, [FAKE_COMPONENT_PATH], {}, {}, w)
expect(writeDownMdFile).toHaveBeenCalledWith([FAKE_MD_CONTENT], MD_FILE_PATH)
done()
})

@@ -53,10 +54,9 @@ })

describe('default', () => {
it('should build one md from merging contents', async done => {
it('should build one md from merging contents', async () => {
jest.spyOn(singleMd, 'compile').mockImplementation(() => Promise.resolve())
await singleMd.default(FILES, w, conf, {}, singleMd.compile)
expect(singleMd.compile).toHaveBeenCalledWith(conf, FILES, {}, {}, w)
done()
})
it('should watch file changes if a watcher is passed', async done => {
it('should watch file changes if a watcher is passed', async () => {
conf.watch = true

@@ -67,5 +67,4 @@ fakeOn.mockClear()

expect(fakeOn).toHaveBeenCalledWith('change', expect.any(Function))
done()
})
})
})

@@ -8,3 +8,3 @@ import * as path from 'path'

var mockFs: {
let mockFs: {
readFile: jest.Mock

@@ -34,3 +34,3 @@ writeFile: jest.Mock

writeFile: jest.fn((a, b, c) => c()),
createWriteStream: a => cws,
createWriteStream: () => cws,
existsSync: jest.fn(() => false)

@@ -41,3 +41,4 @@ }

var mockPrettierFormat: jest.Mock, mockResolveConfig: jest.Mock
let mockPrettierFormat: jest.Mock
let mockResolveConfig: jest.Mock
jest.mock('prettier', () => {

@@ -52,3 +53,3 @@ mockPrettierFormat = jest.fn(() => PRETTY_MD)

var mockMkdirp: jest.Mock
let mockMkdirp: jest.Mock
jest.mock('mkdirp', () => {

@@ -59,3 +60,3 @@ mockMkdirp = jest.fn((p, c) => c())

var mockCompileTemplates: jest.Mock
let mockCompileTemplates: jest.Mock
jest.mock('../compileTemplates', () => {

@@ -67,19 +68,16 @@ mockCompileTemplates = jest.fn()

describe('writeDownMdFile', () => {
it('should pretify before saving', async done => {
it('should pretify before saving', async () => {
await writeDownMdFile(UGLY_MD, MD_FILE_PATH)
expect(mockPrettierFormat).toHaveBeenCalledWith(UGLY_MD, { parser: 'markdown' })
done()
})
it('should then save the pretified markdown', async done => {
it('should then save the pretified markdown', async () => {
await writeDownMdFile(UGLY_MD, MD_FILE_PATH)
expect(cws.write).toHaveBeenCalledWith(PRETTY_MD)
done()
})
it('should resolve the config from the filesystem', async done => {
it('should resolve the config from the filesystem', async () => {
mockResolveConfig.mockReturnValue({ semi: false })
await writeDownMdFile(UGLY_MD, MD_FILE_PATH)
expect(mockPrettierFormat).toHaveBeenCalledWith(UGLY_MD, { semi: false, parser: 'markdown' })
done()
})

@@ -102,6 +100,6 @@ })

// normalize path for windows users
Object.keys(docMap).map(k => {
const path = docMap[k]
Object.keys(docMap).forEach(k => {
const rawPath = docMap[k]
delete docMap[k]
docMap[k.replace(/\\/g, '/')] = path
docMap[k.replace(/\\/g, '/')] = rawPath
})

@@ -108,0 +106,0 @@ expect(docMap).toMatchInlineSnapshot(`

@@ -28,3 +28,5 @@ import * as path from 'path'

export function getDependencies(doc: Pick<ComponentDoc, 'tags'>, compDirName: string): string[] {
if (!doc.tags) return []
if (!doc.tags) {
return []
}
const requireDep =

@@ -56,3 +58,3 @@ doc.tags.requires?.map((t: ParamTag) => path.join(compDirName, t.description as string)) || []

const doc = await parse(absolutePath, options)
const { props, events, methods, slots } = doc
const { props: p, events: e, methods: m, slots: s } = doc
const isSubComponent = subComponent

@@ -63,6 +65,6 @@ const hasSubComponents = !!doc.tags?.requires

const renderedUsage = {
props: props ? templates.props(props, subComponentOptions) : '',
slots: slots ? templates.slots(slots, subComponentOptions) : '',
methods: methods ? templates.methods(methods, subComponentOptions) : '',
events: events ? templates.events(events, subComponentOptions) : '',
props: p ? templates.props(p, subComponentOptions) : '',
slots: s ? templates.slots(s, subComponentOptions) : '',
methods: m ? templates.methods(m, subComponentOptions) : '',
events: e ? templates.events(e, subComponentOptions) : '',
functionalTag: templates.functionalTag

@@ -69,0 +71,0 @@ }

@@ -20,3 +20,5 @@ import * as path from 'path'

// if at a level that has no components (top level) just give up
if (!hasComponents(config)) return
if (!hasComponents(config)) {
return
}

@@ -23,0 +25,0 @@ // if componentsRoot is not specified we start with current cwd

@@ -17,3 +17,3 @@ import * as path from 'path'

cwd: string,
watch: boolean = false,
watch = false,
configFileFromCmd?: string,

@@ -49,4 +49,4 @@ pathArray: string[] = []

},
getDestFile: (file: string, config: SafeDocgenCLIConfig): string =>
path.resolve(config.outDir, file).replace(/\.\w+$/, '.md'),
getDestFile: (file: string, conf: SafeDocgenCLIConfig): string =>
path.resolve(conf.outDir, file).replace(/\.\w+$/, '.md'),
editLinkLabel: 'edit on github',

@@ -53,0 +53,0 @@ ...(fs.existsSync(configFilePath) ? require(configFilePath) : undefined)

@@ -31,5 +31,5 @@ import * as path from 'path'

await Promise.all(
allComponentFiles.map(async compPath => getRequiredComponents(compPath, optionsApi, cwd))
allComponentFiles.map(compPath => getRequiredComponents(compPath, optionsApi, cwd))
)
).reduce((acc, components) => acc.concat(components), [])
).reduce((acc, comps) => acc.concat(comps), [])

@@ -36,0 +36,0 @@ const componentFiles = allComponentFiles.filter(

@@ -18,10 +18,12 @@ import { ComponentDoc, ParamTag } from 'vue-docgen-api'

const frontMatter = []
if (!config.outFile && deprecated)
if (!config.outFile && deprecated) {
// to avoid having the squiggles in the left menu for deprecated items
// use the frontmatter feature of vuepress
frontMatter.push(`title: ${displayName}`)
}
if (isSubComponent || hasSubComponents)
if (isSubComponent || hasSubComponents) {
// show more than one level on subcomponents
frontMatter.push('sidebarDepth: 2')
}

@@ -28,0 +30,0 @@ return `${

@@ -54,3 +54,5 @@ import { MethodDescriptor, Param } from 'vue-docgen-api'

export default (methods: MethodDescriptor[], opt: SubTemplateOptions = {}): string => {
if (Object.keys(methods).length === 0) return ''
if (Object.keys(methods).length === 0) {
return ''
}
return `

@@ -57,0 +59,0 @@ ${opt.isSubComponent || opt.hasSubComponents ? '#' : ''}## Methods

@@ -15,4 +15,3 @@ import { PropDescriptor } from 'vue-docgen-api'

ret +=
`| ${mdclean(p)} | ${mdclean(t)} | ${mdclean(n)} | ${mdclean(v)} | ${mdclean(d)} |` + '\n'
ret += `| ${mdclean(p)} | ${mdclean(t)} | ${mdclean(n)} | ${mdclean(v)} | ${mdclean(d)} |\n`
})

@@ -19,0 +18,0 @@ return ret

@@ -21,3 +21,3 @@ import * as path from 'path'

await mkdirp(destFolder)
let writeStream = fs.createWriteStream(destFilePath)
const writeStream = fs.createWriteStream(destFilePath)
if (Array.isArray(content)) {

@@ -24,0 +24,0 @@ content.forEach(cont => {

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