Skip to content

Commit 3af39c8

Browse files
committed
chore: don't list lifecycle hooks (#58)
refactor: remove hooks from listing chore: update README.md chore: update CHANGELOG.md
1 parent 7bc5f51 commit 3af39c8

File tree

6 files changed

+14
-24
lines changed

6 files changed

+14
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
- Removed `followImports` config (#53)
88
- Removed configuration system (#53)
99
- Removed source transformation (Babel) (#55)
10-
- Removed (#57)
10+
- Removed Vue component script evaluation (#57)
11+
- Removed hooks listing (#59)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ JSDoc for VueJS
55
[![Build Status](https://travis-ci.org/Kocal/jsdoc-vuejs.svg?branch=master)](https://travis-ci.org/Kocal/jsdoc-vuejs)
66
[![Coverage Status](https://coveralls.io/repos/github/Kocal/jsdoc-vuejs/badge.svg?branch=master)](https://coveralls.io/github/Kocal/jsdoc-vuejs?branch=master)
77

8-
> A wobbly JSDoc plugin for listing props, data, computed data, hooks and methods from *.vue files.
8+
> A wobbly JSDoc plugin for listing props, data, computed data, and methods from *.vue files.
99
1010
> WARNING: Actually, it's only working with the default JSDoc template.
1111

__tests__/__snapshots__/docletHandlers.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ exports[`docletHandlers BetterCounter handleComputed should properly handle even
44
55
exports[`docletHandlers BetterCounter handleData should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>message</td></tr></tbody></table><h3 class=\\"subsection-title\\">Data</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>counter</td></tr></tbody></table>"`;
66
7-
exports[`docletHandlers BetterCounter handleMethodsAndHooks should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>message</td></tr></tbody></table><h3 class=\\"subsection-title\\">Data</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>counter</td></tr></tbody></table>"`;
7+
exports[`docletHandlers BetterCounter handleMethods should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>message</td></tr></tbody></table><h3 class=\\"subsection-title\\">Data</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>counter</td></tr></tbody></table>"`;
88
99
exports[`docletHandlers BetterCounter handleProps should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>message</td></tr></tbody></table><h3 class=\\"subsection-title\\">Data</h3><table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>counter</td></tr></tbody></table><h3 class=\\"subsection-title\\">Props</h3><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Default value</th></tr></thead><tbody><tr><td>initialCounter</td><td>Number</td><td><b>true</b></td><td></td></tr><tr><td>step</td><td>Number</td><td>false</td><td>1</td></tr></tbody></table>"`;
1010
1111
exports[`docletHandlers EmptyComponent handleComputed should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><p>No computed data to display.</p>"`;
1212
1313
exports[`docletHandlers EmptyComponent handleData should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><p>No computed data to display.</p><h3 class=\\"subsection-title\\">Data</h3><p>No data to display.</p>"`;
1414
15-
exports[`docletHandlers EmptyComponent handleMethodsAndHooks should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><p>No computed data to display.</p><h3 class=\\"subsection-title\\">Data</h3><p>No data to display.</p>"`;
15+
exports[`docletHandlers EmptyComponent handleMethods should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><p>No computed data to display.</p><h3 class=\\"subsection-title\\">Data</h3><p>No data to display.</p>"`;
1616
1717
exports[`docletHandlers EmptyComponent handleProps should properly handle event's doclet 1`] = `"<h3 class=\\"subsection-title\\">Computed</h3><p>No computed data to display.</p><h3 class=\\"subsection-title\\">Data</h3><p>No data to display.</p><h3 class=\\"subsection-title\\">Props</h3><p>No props to display.</p>"`;

__tests__/docletHandlers.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ describe('docletHandlers', () => {
4343
})
4444
})
4545

46-
describe('handleMethodsAndHooks', () => {
46+
describe('handleMethods', () => {
4747
it('should properly handle event\'s doclet', () => {
48-
docletHandlers.handleMethodsAndHooks(JSDocEvent)
48+
docletHandlers.handleMethods(JSDocEvent)
4949

5050
expect(JSDocEvent.doclet.description).toMatchSnapshot()
5151
})
@@ -81,9 +81,9 @@ describe('docletHandlers', () => {
8181
})
8282
})
8383

84-
describe('handleMethodsAndHooks', () => {
84+
describe('handleMethods', () => {
8585
it('should properly handle event\'s doclet', () => {
86-
docletHandlers.handleMethodsAndHooks(JSDocEvent)
86+
docletHandlers.handleMethods(JSDocEvent)
8787

8888
expect(JSDocEvent.doclet.description).toMatchSnapshot()
8989
})
@@ -105,23 +105,23 @@ describe('docletHandlers', () => {
105105
const finalEvent = createJSDocEventForMethod('foo.bar')
106106

107107
expect(event).toEqual(finalEvent)
108-
docletHandlers.handleMethodsAndHooks(finalEvent)
108+
docletHandlers.handleMethods(finalEvent)
109109
expect(event).toEqual(finalEvent)
110110
})
111111

112112
it('should modify name when it\'s a hook', () => {
113113
const event = createJSDocEventForMethod('foo.vue')
114114

115115
event.doclet.name = 'created'
116-
docletHandlers.handleMethodsAndHooks(event)
116+
docletHandlers.handleMethods(event)
117117
expect(event.doclet.name).toEqual('[Hook] created')
118118
})
119119

120120
it('should not modify name when it\'s not a hook', () => {
121121
const event = createJSDocEventForMethod('foo.vue')
122122

123123
event.doclet.name = 'not_a_hook'
124-
docletHandlers.handleMethodsAndHooks(event)
124+
docletHandlers.handleMethods(event)
125125
expect(event.doclet.name).toEqual('not_a_hook')
126126
})
127127
})

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports.handlers = {
3232
e.doclet.description += `<div class="container-overview"><div><p>`
3333
}
3434

35-
docletHandlers.handleMethodsAndHooks(e)
35+
docletHandlers.handleMethods(e)
3636
}
3737
}
3838

lib/docletHandlers.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
const buildTable = require('./tableBuilder')
22
const extractors = require('./extractors')
33

4-
const vueHooks = [
5-
'beforeCreate', 'created',
6-
'beforeMount', 'mounted',
7-
'beforeUpdate', 'updated',
8-
'beforeDestroy', 'destroyed'
9-
]
10-
114
/**
125
* @param {Object} e
136
* @param {Object} vueComponentPrototype
@@ -33,18 +26,14 @@ module.exports.handleData = function (e, vueComponentPrototype) {
3326
/**
3427
* @param {Object} e
3528
*/
36-
module.exports.handleMethodsAndHooks = function (e) {
29+
module.exports.handleMethods = function (e) {
3730
// handle functions in .vue
3831
if (e.doclet.meta.filename.endsWith('.vue') && e.doclet.kind === 'function') {
3932
e.doclet.scope = 'instance'
4033

4134
if ((e.doclet.memberof || '').endsWith('.methods')) { // is a method
4235
e.doclet.memberof = e.doclet.memberof.split('.')[0]
4336
}
44-
45-
if (vueHooks.includes(e.doclet.name)) {
46-
e.doclet.name = `[Hook] ${e.doclet.name}`
47-
}
4837
}
4938
}
5039

0 commit comments

Comments
 (0)