Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @vue-slot #442

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Update your .vue files with one of the following tags:
- `@vue-data`
- `@vue-computed`
- `@vue-event`
- `@vue-slot`

All of those tags work the same way than [`@param` tag](http://usejsdoc.org/tags-param.html).

Expand All @@ -67,6 +68,7 @@ All of those tags work the same way than [`@param` tag](http://usejsdoc.org/tags
* @vue-computed {String} message
* @vue-event {Number} increment - Emit counter's value after increment
* @vue-event {Number} decrement - Emit counter's value after decrement
* @vue-slot #myslot - This is my slot description
*/
export default {
props: {
Expand Down
2 changes: 2 additions & 0 deletions example/src/js/CounterJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { mapState } from 'vuex';

/**
* @module CounterJS
* @vue-prop {Number} superLongPropNameToCheckWidthStyle
* @vue-prop {Number} initialCounter
* @vue-prop {Number} [step=1] Step
* @vue-data {Number} counter - Current counter's value
* @vue-computed {Array.<String>} fooList - A list of foo
* @vue-computed {Array.<String>} barList - A list of bar
* @vue-computed {String} message A message
* @vue-slot #header This is a header slot
*/
export default {
name: 'CounterJS',
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const vueDataTag = require('./lib/tags/vue-data');
const vuePropTag = require('./lib/tags/vue-prop');
const vueComputedTag = require('./lib/tags/vue-computed');
const vueEventTag = require('./lib/tags/vue-event');
const vueSlotTag = require('./lib/tags/vue-slot');

// Used to compute good line number for Vue methods
const exportDefaultLines = {};
Expand Down Expand Up @@ -54,6 +55,7 @@ exports.handlers = {
data: e.doclet._vueData || [],
computed: e.doclet._vueComputed || [],
event: e.doclet._vueEvent || [],
slots: e.doclet._vueSlots || []
};

render(template, data, (err, str) => {
Expand Down Expand Up @@ -86,4 +88,5 @@ exports.defineTags = function defineTags(dictionary) {
dictionary.defineTag(vuePropTag.name, vuePropTag.options);
dictionary.defineTag(vueComputedTag.name, vueComputedTag.options);
dictionary.defineTag(vueEventTag.name, vueEventTag.options);
dictionary.defineTag(vueSlotTag.name,vueSlotTag.options);
};
3 changes: 2 additions & 1 deletion lib/core/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const ejs = require('ejs');
const renderType = require('../templates/utils/renderType');

module.exports = function render(template, {
props, data, computed, event,
props, data, computed, event, slots,
}, cb) {
ejs.renderFile(
template,
Expand All @@ -12,6 +12,7 @@ module.exports = function render(template, {
data,
computed,
event,
slots
},
cb,
);
Expand Down
10 changes: 10 additions & 0 deletions lib/tags/vue-slot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.name = 'vue-slot';

exports.options = {
canHaveName: true,
onTagged(doclet, tag) {
doclet._isVueDoc = true;
doclet._vueSlots = doclet._vueSlots || [];
doclet._vueSlots.push(tag.value || {});
},
};
17 changes: 17 additions & 0 deletions lib/templates/default.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,21 @@
</table>
<% } %>

<% if(slots.length > 0) { %>
<h3 class="subsection-title" style="margin-top: 1em" data-jsdoc-vuejs="section-event">Slots</h3>
<table data-jsdoc-vuejs="table-event">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody><% slots.forEach(function(c) { %><tr>
<td><code><%- c.name %></code></td>
<td><%- typeof c.description === 'undefined' ? '-' : c.description %></td>
</tr><% }) %></tbody>
</table>
<% } %>


<div class="container-overview"><div><p> <%# Re-open JSDoc template tags %>
16 changes: 16 additions & 0 deletions lib/templates/docstrap.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,20 @@
</table>
<% } %>

<% if(slots.length > 0) { %>
<h3 class="subsection-title" style="margin-top: 1em" data-jsdoc-vuejs="section-event">Slots</h3>
<table data-jsdoc-vuejs="table-event" class="table table-responsive table-hover table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody><% slots.forEach(function(c) { %><tr>
<td><code><%- c.name %></code></td>
<td><%- typeof c.description === 'undefined' ? '-' : c.description %></td>
</tr><% }) %></tbody>
</table>
<% } %>

<div class="container-overview"><div><p> <%# Re-open JSDoc template tags %>
16 changes: 16 additions & 0 deletions lib/templates/minami.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,20 @@
</table>
<% } %>

<% if(slots.length > 0) { %>
<h3 class="subsection-title" style="margin-top: 1em" data-jsdoc-vuejs="section-event">Slots</h3>
<table class="params" data-jsdoc-vuejs="table-event">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody><% slots.forEach(function(c) { %><tr>
<td><code><%- c.name %></code></td>
<td><%- typeof c.description === 'undefined' ? '-' : c.description %></td>
</tr><% }) %></tbody>
</table>
<% } %>

<div class="container-overview"><div><p> <%# Re-open JSDoc template tags %>
18 changes: 18 additions & 0 deletions lib/templates/tui.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,22 @@
</div>
<% } %>

<% if(slots.length > 0) { %>
<h3 class="subsection-title" style="margin-top: 1em" data-jsdoc-vuejs="section-event">Slots</h3>
<div class="container-params">
<table class="params" data-jsdoc-vuejs="table-event">
<thead>
<tr>
<th>Name</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody><% slots.forEach(function(c) { %><tr>
<td class="name"><code><%- c.name %></code></td>
<td class="description last"><%- typeof c.description === 'undefined' ? '-' : c.description %></td>
</tr><% }) %></tbody>
</table>
</div>
<% } %>

<div class="container-overview"><div><p> <%# Re-open JSDoc template tags %>