Skip to content

Commit 8c6226e

Browse files
authored
fix: don't overwrite doclet description if already present (@desc tag) (#141)
Fix #140
1 parent 4100673 commit 8c6226e

File tree

6 files changed

+38
-13
lines changed

6 files changed

+38
-13
lines changed

cypress/integration/templates/default.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ describe('Template: default', () => {
1616
.contains('better-components/BetterCounter');
1717
});
1818

19+
it('should renders @desc properly', () => {
20+
cy
21+
.get('.container-overview')
22+
.contains('BetterCounter component, like Counter component but better');
23+
});
24+
1925
it('should renders props correctly', () => {
2026
const props = [
2127
{
@@ -145,21 +151,21 @@ describe('Template: default', () => {
145151
.contains('decrement()')
146152
.next('.description')
147153
.next('.details')
148-
.contains('a[href="better-components_BetterCounter.vue.html#line52"]', 'line 52');
154+
.contains('a[href="better-components_BetterCounter.vue.html#line53"]', 'line 53');
149155

150156
cy.get('#increment')
151157
.contains('increment()')
152158
.next('.description')
153159
.next('.details')
154-
.contains('a[href="better-components_BetterCounter.vue.html#line45"]', 'line 45');
160+
.contains('a[href="better-components_BetterCounter.vue.html#line46"]', 'line 46');
155161

156162
cy.get('#showDialog')
157163
.contains('showDialog(counter)')
158164
.next('.description')
159165
.next('h5')
160166
.next('.params')
161167
.next('.details')
162-
.contains('a[href="better-components_BetterCounter.vue.html#line60"]', 'line 60');
168+
.contains('a[href="better-components_BetterCounter.vue.html#line61"]', 'line 61');
163169

164170
cy.contains('created()').should('not.exist');
165171
});

cypress/integration/templates/docstrap.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ describe('Template: docstrap', () => {
1616
.contains('better-components/BetterCounter');
1717
});
1818

19+
it('should renders @desc properly', () => {
20+
cy
21+
.get('.container-overview')
22+
.contains('BetterCounter component, like Counter component but better');
23+
});
24+
1925
it('should renders props correctly', () => {
2026
const props = [
2127
{
@@ -145,21 +151,21 @@ describe('Template: docstrap', () => {
145151
.parent()
146152
.next('dd')
147153
.find('.details')
148-
.contains('a[href="better-components_BetterCounter.vue.html#sunlight-1-line-52"]', 'line 52');
154+
.contains('a[href="better-components_BetterCounter.vue.html#sunlight-1-line-53"]', 'line 53');
149155

150156
cy.get('#increment')
151157
.contains('increment()')
152158
.parent()
153159
.next('dd')
154160
.find('.details')
155-
.contains('a[href="better-components_BetterCounter.vue.html#sunlight-1-line-45"]', 'line 45');
161+
.contains('a[href="better-components_BetterCounter.vue.html#sunlight-1-line-46"]', 'line 46');
156162

157163
cy.get('#showDialog')
158164
.contains('showDialog(counter)')
159165
.parent()
160166
.next('dd')
161167
.find('.details')
162-
.contains('a[href="better-components_BetterCounter.vue.html#sunlight-1-line-60"]', 'line 60');
168+
.contains('a[href="better-components_BetterCounter.vue.html#sunlight-1-line-61"]', 'line 61');
163169

164170
cy.contains('created()').should('not.exist');
165171
});

cypress/integration/templates/minami.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ describe('Template: minami', () => {
1616
.contains('better-components/BetterCounter');
1717
});
1818

19+
it('should renders @desc properly', () => {
20+
cy
21+
.get('.container-overview')
22+
.contains('BetterCounter component, like Counter component but better');
23+
});
24+
1925
it('should renders props correctly', () => {
2026
const props = [
2127
{
@@ -146,19 +152,19 @@ describe('Template: minami', () => {
146152
.contains('decrement()')
147153
.next('.description')
148154
.next('.details')
149-
.contains('a[href="better-components_BetterCounter.vue.html#line52"]', 'line 52');
155+
.contains('a[href="better-components_BetterCounter.vue.html#line53"]', 'line 53');
150156

151157
cy.get('#increment')
152158
.contains('increment()')
153159
.next('.description')
154160
.next('.details')
155-
.contains('a[href="better-components_BetterCounter.vue.html#line45"]', 'line 45');
161+
.contains('a[href="better-components_BetterCounter.vue.html#line46"]', 'line 46');
156162

157163
cy.get('#showDialog')
158164
.contains('showDialog(counter)')
159165
.next('.description')
160166
.next('.details')
161-
.contains('a[href="better-components_BetterCounter.vue.html#line60"]', 'line 60');
167+
.contains('a[href="better-components_BetterCounter.vue.html#line61"]', 'line 61');
162168

163169
cy.contains('created()').should('not.exist');
164170
});

cypress/integration/templates/tui.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ describe('Template: tui', () => {
2020
.contains('better-components/BetterCounter');
2121
});
2222

23+
it('should renders @desc properly', () => {
24+
cy
25+
.get('.container-overview')
26+
.contains('BetterCounter component, like Counter component but better');
27+
});
28+
2329
it('should renders props correctly', () => {
2430
const props = [
2531
{
@@ -146,15 +152,15 @@ describe('Template: tui', () => {
146152
cy.contains('h3', 'Methods').should('have.attr', 'class', 'subsection-title');
147153
cy.get('#decrement')
148154
.contains('decrement()')
149-
.contains('a[href="better-components_BetterCounter.vue.html#line52"]', 'line 52');
155+
.contains('a[href="better-components_BetterCounter.vue.html#line53"]', 'line 53');
150156

151157
cy.get('#increment')
152158
.contains('increment()')
153-
.contains('a[href="better-components_BetterCounter.vue.html#line45"]', 'line 45');
159+
.contains('a[href="better-components_BetterCounter.vue.html#line46"]', 'line 46');
154160

155161
cy.get('#showDialog')
156162
.contains('showDialog(counter)')
157-
.contains('a[href="better-components_BetterCounter.vue.html#line60"]', 'line 60');
163+
.contains('a[href="better-components_BetterCounter.vue.html#line61"]', 'line 61');
158164

159165
cy.contains('created()').should('not.exist');
160166
});

example/src/better-components/BetterCounter.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
/**
1414
* @module better-components/BetterCounter
15+
* @desc BetterCounter component, like Counter component but better
1516
* @vue-prop {Number} initialCounter
1617
* @vue-prop {Number} [step=1] Step
1718
* @vue-data {Number} counter - Current counter's value

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exports.handlers = {
5858
render(template, data, (err, str) => {
5959
if (err) throw err;
6060

61-
e.doclet.description = str;
61+
e.doclet.description = (e.doclet.description || '') + str;
6262
});
6363

6464
// Remove meta for not rendering source for this doclet

0 commit comments

Comments
 (0)