Skip to content

Commit ae49051

Browse files
author
season
committed
log
1 parent 4c43359 commit ae49051

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export default {}
5454
"plugins/markdown",
5555
"plugins/summarize"
5656
],
57+
"jsdoc-vue-component": {
58+
"log": true
59+
},
5760
"markdown": {
5861
"tags": ["author", "classdesc", "description", "param", "property", "returns", "see", "throws", "vue"]
5962
},

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const compiler = require('vue-template-compiler');
44
const stripIndent = require('strip-indent');
55
const indentString = require('indent-string');
66
const parse = require('./parse');
7+
const log = require('./util').log;
78

89
// get markdown comment
910
function getMarkDown(obj) {
@@ -92,6 +93,8 @@ const markdownCodes = {};
9293
exports.handlers = {
9394
beforeParse (e) {
9495
if (/\.vue$/.test(e.filename)) {
96+
log(`parse file begin: ${e.filename}`);
97+
9598
const parsedComponent = compiler.parseComponent(e.source);
9699
const code = parsedComponent.script ? parsedComponent.script.content : '';
97100
const parsed = parse(code);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsdoc-vue-component",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "A simple plugin for jsdoc (`pase vue SFC info to description`)",
55
"main": "index.js",
66
"repository": {

parse.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const esprima = require('esprima');
22
const esquery = require('esquery');
33
const escodegen = require('escodegen');
4+
const log = require('./util').log;
45

56
function parseProps(item) {
7+
log('parse props begin ...');
8+
69
let props = [];
710

811
// props: [], array
@@ -112,6 +115,8 @@ function parseProps(item) {
112115
}
113116

114117
function parseMethods(item) {
118+
log('parse methods begin ...');
119+
115120
let methods = [];
116121

117122
// error methods format
@@ -140,6 +145,8 @@ function parseMethods(item) {
140145
}
141146

142147
function parseComponents(item) {
148+
log('parse components begin ...');
149+
143150
let components = [];
144151

145152
// error format
@@ -158,6 +165,8 @@ function parseComponents(item) {
158165
}
159166

160167
function parseCode(code) {
168+
log('parse code begin ...');
169+
161170
const ast = esprima.parseModule(code);
162171
const propertyList = esquery(ast, "ExportDefaultDeclaration > .declaration > .properties");
163172

util.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let config = {
2+
log: true
3+
}
4+
5+
try {
6+
const env = require('jsdoc/env')
7+
config = Object.assign({}, config, env.conf['jsdoc-vue-component']);
8+
} catch (e) {
9+
console.log(e);
10+
}
11+
12+
function log(message) {
13+
if (!config.log) return;
14+
console.log('jsdoc-vue-component: ');
15+
console.log(message);
16+
}
17+
18+
exports.config = config;

0 commit comments

Comments
 (0)