Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

Commit 8514fc0

Browse files
committed
Fix parser
1 parent 10c402a commit 8514fc0

File tree

8 files changed

+83
-93
lines changed

8 files changed

+83
-93
lines changed

README.md

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export default {
7171
/**
7272
* object/array defaults should be returned from a factory function
7373
* @version 1.0.5
74-
* @ignore
7574
* @since Version 1.0.1
7675
* @see See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names
7776
* @link See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names
@@ -82,6 +81,7 @@ export default {
8281
},
8382
/**
8483
* describe data
84+
* @version 1.0.5
8585
*/
8686
data: [Array],
8787
/**
@@ -90,6 +90,7 @@ export default {
9090
columns: [Array],
9191
/**
9292
* filter key
93+
* @ignore
9394
*/
9495
filterKey: {
9596
type: String,
@@ -137,20 +138,22 @@ export default {
137138
methods: {
138139
139140
/**
140-
* Sets the order
141-
*
142-
* @public
143-
* @version 1.0.5
144-
* @since Version 1.0.1
145-
* @param {string} key Key to order
146-
* @returns {string} Test
147-
*/
141+
* Sets the order
142+
*
143+
* @public
144+
* @version 1.0.5
145+
* @since Version 1.0.1
146+
* @param {string} key Key to order
147+
* @returns {string} Test
148+
*/
148149
sortBy: function (key) {
149150
this.sortKey = key
150151
this.sortOrders[key] = this.sortOrders[key] * -1
151152
},
152153
153-
hiddenMethod: function(){}
154+
hiddenMethod: function(){
155+
156+
}
154157
}
155158
}
156159
</script>
@@ -170,7 +173,7 @@ we are getting this output:
170173
"methods": [
171174
{
172175
"name": "sortBy",
173-
"comment": "/**\n\t * Sets the order\n\t *\n\t * @public\n\t * @version 1.0.5\n\t * @since Version 1.0.1\n\t * @param {string} key Key to order\n\t * @returns {string} Test\n\t */",
176+
"comment": "/**\n * Sets the order\n *\n * @public\n * @version 1.0.5\n * @since Version 1.0.1\n * @param {string} key Key to order\n * @returns {string} Test\n */",
174177
"modifiers": [],
175178
"params": [
176179
{
@@ -195,24 +198,6 @@ we are getting this output:
195198
"description": "public"
196199
}
197200
],
198-
"description": [
199-
{
200-
"title": "description",
201-
"description": "Sets the order"
202-
}
203-
],
204-
"kind": [
205-
{
206-
"title": "kind",
207-
"description": "function"
208-
}
209-
],
210-
"name": [
211-
{
212-
"title": "name",
213-
"description": "sortBy"
214-
}
215-
],
216201
"params": [
217202
{
218203
"title": "param",
@@ -251,37 +236,55 @@ we are getting this output:
251236
],
252237
"displayName": "Grid",
253238
"props": {
254-
"filterKey": {
239+
"msg": {
255240
"type": {
256-
"name": "string"
241+
"name": "string|number"
257242
},
258243
"required": "",
259244
"defaultValue": {
260-
"value": "\"example\"",
245+
"value": "\"Ejemplo\"",
261246
"computed": false
262247
},
263248
"tags": {
264-
"description": [
249+
"see": [
265250
{
266-
"title": "description",
267-
"description": "filter key"
251+
"title": "see",
252+
"description": "See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names"
268253
}
269254
],
270-
"kind": [
255+
"since": [
271256
{
272-
"title": "kind",
273-
"description": "member"
257+
"title": "since",
258+
"description": "Version 1.0.1"
274259
}
275260
],
276-
"name": [
261+
"version": [
277262
{
278-
"title": "name",
279-
"description": "filterKey"
263+
"title": "version",
264+
"description": "1.0.5"
265+
}
266+
],
267+
"link": [
268+
{
269+
"title": "link",
270+
"description": "See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names"
280271
}
281272
]
282273
},
283-
"comment": "/**\n * filter key\n */",
284-
"description": "filter key"
274+
"comment": "/**\n * object/array defaults should be returned from a factory function\n * @version 1.0.5\n * @since Version 1.0.1\n * @see See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names\n * @link See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names\n */",
275+
"description": "object/array defaults should be returned from a factory function"
276+
},
277+
"data": {
278+
"type": {
279+
"name": "array"
280+
},
281+
"description": "describe data"
282+
},
283+
"columns": {
284+
"type": {
285+
"name": "array"
286+
},
287+
"description": "get columns list"
285288
}
286289
},
287290
"comment": "/**\n * This is an example of creating a reusable grid component and using it with external data.\n * @version 1.0.5\n * @author [Rafael](https://github.com/rafaesc92)\n * @since Version 1.0.1\n */",
@@ -292,18 +295,6 @@ we are getting this output:
292295
"description": "[Rafael](https://github.com/rafaesc92)"
293296
}
294297
],
295-
"description": [
296-
{
297-
"title": "description",
298-
"description": "This is an example of creating a reusable grid component and using it with external data."
299-
}
300-
],
301-
"kind": [
302-
{
303-
"title": "kind",
304-
"description": "member"
305-
}
306-
],
307298
"since": [
308299
{
309300
"title": "since",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-docgen-api",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.",
55
"bugs": {
66
"url": "https://github.com/vue-styleguidist/vue-docgen-api/issues"

src/utils/blockTags.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default [
1111
'copyright',
1212
'default',
1313
'deprecated',
14-
'description',
1514
'event',
1615
'example',
1716
'examples',
@@ -25,12 +24,10 @@ export default [
2524
'inner',
2625
'instance',
2726
'interface',
28-
'kind',
2927
'lends',
3028
'license',
3129
'member',
3230
'module',
33-
'name',
3431
'param',
3532
'params',
3633
'private',

src/utils/getTag.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { EMPTY } from './variables';
22

33
function isExistInTagList(docPart, tagName) {
4-
return docPart['tags'].some( tagObj => {
5-
return tagObj['title'] === tagName;
6-
})
4+
return docPart['tags'].some(tagObj => {
5+
return tagObj['title'] === tagName
6+
});
77
}
88

99
function generateTag(title, description, type) {
@@ -62,15 +62,15 @@ export default function getTag(tagName, docPart) {
6262
return generateTag(tagName, description)
6363
})
6464
}
65-
} else if (docPart['tags'] &&
66-
isExistInTagList(tagName, docPart)) {
67-
return docPart['tags'].filter(tagObj => {
65+
}
66+
return false;
67+
} else if (docPart['tags'] &&
68+
isExistInTagList(docPart, tagName)) {
69+
return docPart['tags'].filter(tagObj => {
6870
return tagObj['title'] === tagName;
6971
}).map(tagObj =>{
7072
return generateTag(tagName, tagObj['text'])
7173
})
72-
}
73-
} else {
74-
return false;
7574
}
75+
return false;
7676
}

src/utils/getVueDoc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function getVueDoc(docFile, component) {
3434
})[0];
3535
const description = getDescription(docComponent);
3636
const comment = getComment(docComponent);
37-
const tags = processTags(docComponent, ['name', ...IGNORE_DEFAULT]);
37+
const tags = processTags(docComponent, IGNORE_DEFAULT);
3838
const props = processProps(docFile, component);
3939
const methods = processMethods(docFile, component);
4040

src/utils/processProps.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ export default function processProps(docFile, component) {
1414
return comment.longname.indexOf('props.' + propName) > -1
1515
})[0];
1616
const prop = component.props[propName];
17-
const listTag = getProp(prop, docPart);
18-
if ( listTag['tags'] && !listTag['tags']['ignore'] ) {
19-
listProps[propName] = listTag;
17+
const docProp = getProp(prop, docPart);
18+
const listTags = docProp['tags']
19+
if ( listTags ) {
20+
if ( !listTags['ignore'] ) {
21+
listProps[propName] = docProp;
22+
}
23+
} else {
24+
listProps[propName] = docProp;
2025
}
2126
})
2227
}

tests/components/grid/Grid.vue

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ export default {
3737
/**
3838
* object/array defaults should be returned from a factory function
3939
* @version 1.0.5
40-
* @ignore
4140
* @since Version 1.0.1
4241
* @see See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names
4342
* @link See [Wikipedia](https://en.wikipedia.org/wiki/Web_colors#HTML_color_names) for a list of color names
4443
*/
4544
msg: {
46-
type: [String, Number],
47-
default: 'Ejemplo'
45+
type: [String, Number],
46+
default: 'Ejemplo'
4847
},
4948
/**
5049
* describe data
50+
* @version 1.0.5
5151
*/
5252
data: [Array],
5353
/**
@@ -56,6 +56,7 @@ export default {
5656
columns: [Array],
5757
/**
5858
* filter key
59+
* @ignore
5960
*/
6061
filterKey: {
6162
type: String,
@@ -103,22 +104,22 @@ export default {
103104
methods: {
104105
105106
/**
106-
* Sets the order
107-
*
108-
* @public
109-
* @version 1.0.5
110-
* @since Version 1.0.1
111-
* @param {string} key Key to order
112-
* @returns {string} Test
113-
*/
107+
* Sets the order
108+
*
109+
* @public
110+
* @version 1.0.5
111+
* @since Version 1.0.1
112+
* @param {string} key Key to order
113+
* @returns {string} Test
114+
*/
114115
sortBy: function (key) {
115116
this.sortKey = key
116117
this.sortOrders[key] = this.sortOrders[key] * -1
117118
},
118119
119-
hiddenMethod: function(){
120+
hiddenMethod: function(){
120121
121-
}
122+
}
122123
}
123124
}
124125
</script>

tests/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,15 @@ describe('tests', () => {
3939
expect(typeof docJson['props'] !== 'undefined').to.be.true
4040
})
4141

42-
it('should the component have kind', () => {
43-
expect(typeof docJson['tags']['kind'] !== 'undefined').to.be.true
44-
})
45-
4642
it('should the component have version', () => {
4743
expect(typeof docJson['tags']['version'] !== 'undefined').to.be.true
4844
})
4945

50-
it('should the component have one prop', () => {
51-
expect(Object.keys(docJson['props']).length === 1).to.be.true
46+
it('should the component have three prop', () => {
47+
expect(Object.keys(docJson['props']).length === 3).to.be.true
5248
})
5349

54-
it('should the prop filter key have three tags', () => {
55-
expect(Object.keys(docJson['props']['filterKey']['tags']).length === 3).to.be.true
50+
it('should the prop msg have four tags', () => {
51+
expect(Object.keys(docJson['props']['msg']['tags']).length === 4).to.be.true
5652
})
5753
})

0 commit comments

Comments
 (0)