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

Commit a6efd46

Browse files
committed
Fixed the problem of the props ignored
1 parent 59f76f8 commit a6efd46

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

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": "2.0.3",
3+
"version": "2.0.4",
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/getProp.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ function getTypeNameToFunction(object) {
1919
export default function getProp(prop, docPart){
2020
if ( prop ) {
2121
let obj = {};
22-
if ( typeof prop === 'function' || Array.isArray(prop) ) {
22+
if ( Array.isArray(prop) ) {
2323
obj['type'] = {
2424
name: getTypeName(prop),
2525
};
26+
} else if (typeof prop === 'function') {
27+
obj['type'] = {
28+
name: getTypeName(prop),
29+
};
30+
obj['tags'] = processTags(docPart, IGNORE_DEFAULT);
31+
obj['comment'] = getComment(docPart);
2632
} else {
2733
obj['type'] = {
2834
name: getTypeName(prop.type),

tests/components/button/Button.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ export default {
2828
default: 'normal'
2929
},
3030
/**
31+
* @ignore
3132
* Add custom click actions.
3233
**/
3334
onCustomClick: {
3435
default: () => () => null,
3536
},
37+
/**
38+
*@ignore
39+
*
40+
*/
41+
prop1: String
3642
},
3743
data () {
3844
return {

tests/parse.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('tests grid', () => {
5757

5858
describe('tests button', () => {
5959
docButton = api.parse(button);
60-
// console.log(JSON.stringify(docButton, null, 2));
60+
console.log(JSON.stringify(docButton, null, 2));
6161

6262
it('should return an object', () => {
6363
expect(docButton).to.be.an('object')
@@ -99,8 +99,20 @@ describe('tests button', () => {
9999
expect(typeof docButton['tags']['version'] !== 'undefined').to.be.true
100100
})
101101

102-
it('should the component have four props', () => {
103-
expect(Object.keys(docButton['props']).length).to.equal(4)
102+
it('should the component have five props', () => {
103+
expect(Object.keys(docButton['props']).length).to.equal(5)
104+
})
105+
106+
it('should prop1 to be string', () => {
107+
expect(docButton['props']['prop1']['type']['name']).to.equal('string')
108+
})
109+
110+
it('should onCustomClick to be ignored', () => {
111+
expect(docButton['props']['onCustomClick']['tags']['ignore']).to.be.an('array')
112+
})
113+
114+
it('should prop1 to be ignored', () => {
115+
expect(docButton['props']['prop1']['tags']['ignore']).to.be.an('array')
104116
})
105117
})
106118

tests/parseWebpack.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const expect = require("chai").expect;
66
let docGrid;
77
let docButton;
88

9-
describe('tests grid', () => {
9+
describe('tests parseWebpack grid', () => {
1010
docGrid = api.parseWebpack(grid);
1111

1212
it('should return an object', () => {
@@ -58,7 +58,7 @@ describe('tests grid', () => {
5858
})
5959
})
6060

61-
describe('tests button', () => {
61+
describe('tests parseWebpack button', () => {
6262
docButton = api.parseWebpack(button);
6363
console.log(JSON.stringify(docButton, null, 2));
6464

@@ -78,10 +78,6 @@ describe('tests button', () => {
7878
expect(Object.keys(docButton['tags']).length).to.equal(2)
7979
})
8080

81-
it('should the component have four props', () => {
82-
expect(Object.keys(docButton['props']).length).to.equal(4)
83-
})
84-
8581
it('should the component have size prop default equal normal', () => {
8682
expect(docButton['props']['size']['defaultValue']['value']).to.equal('"normal"')
8783
})
@@ -110,7 +106,19 @@ describe('tests button', () => {
110106
expect(typeof docButton['tags']['version'] !== 'undefined').to.be.true
111107
})
112108

113-
it('should the component have four props', () => {
114-
expect(Object.keys(docButton['props']).length).to.equal(4)
109+
it('should the component have five props', () => {
110+
expect(Object.keys(docButton['props']).length).to.equal(5)
111+
})
112+
113+
it('should prop1 to be string', () => {
114+
expect(docButton['props']['prop1']['type']['name']).to.equal('string')
115+
})
116+
117+
it('should onCustomClick to be ignored', () => {
118+
expect(docButton['props']['onCustomClick']['tags']['ignore']).to.be.an('array')
119+
})
120+
121+
it('should prop1 to be ignored', () => {
122+
expect(docButton['props']['prop1']['tags']['ignore']).to.be.an('array')
115123
})
116124
})

0 commit comments

Comments
 (0)