diff --git a/README.md b/README.md index 61363646..e7b4da65 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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: { diff --git a/example/src/js/CounterJS.js b/example/src/js/CounterJS.js index f2b1546d..f3713254 100644 --- a/example/src/js/CounterJS.js +++ b/example/src/js/CounterJS.js @@ -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.} fooList - A list of foo * @vue-computed {Array.} barList - A list of bar * @vue-computed {String} message A message + * @vue-slot #header This is a header slot */ export default { name: 'CounterJS', diff --git a/index.js b/index.js index 2205f33b..ab0f7128 100644 --- a/index.js +++ b/index.js @@ -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 = {}; @@ -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) => { @@ -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); }; diff --git a/lib/core/renderer.js b/lib/core/renderer.js index c679023e..9a71af9c 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -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, @@ -12,6 +12,7 @@ module.exports = function render(template, { data, computed, event, + slots }, cb, ); diff --git a/lib/tags/vue-slot.js b/lib/tags/vue-slot.js new file mode 100644 index 00000000..cafe13e1 --- /dev/null +++ b/lib/tags/vue-slot.js @@ -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 || {}); + }, +}; diff --git a/lib/templates/default.ejs b/lib/templates/default.ejs index 86d7be5b..e90e092f 100644 --- a/lib/templates/default.ejs +++ b/lib/templates/default.ejs @@ -79,4 +79,21 @@ <% } %> +<% if(slots.length > 0) { %> +

Slots

+ + + + + + + + <% slots.forEach(function(c) { %> + + + <% }) %> +
NameDescription
<%- c.name %><%- typeof c.description === 'undefined' ? '-' : c.description %>
+<% } %> + +

<%# Re-open JSDoc template tags %> diff --git a/lib/templates/docstrap.ejs b/lib/templates/docstrap.ejs index edb8ddf7..2e9faa55 100644 --- a/lib/templates/docstrap.ejs +++ b/lib/templates/docstrap.ejs @@ -78,4 +78,20 @@ <% } %> +<% if(slots.length > 0) { %> +

Slots

+ + + + + + + + <% slots.forEach(function(c) { %> + + + <% }) %> +
NameDescription
<%- c.name %><%- typeof c.description === 'undefined' ? '-' : c.description %>
+<% } %> +

<%# Re-open JSDoc template tags %> diff --git a/lib/templates/minami.ejs b/lib/templates/minami.ejs index 3a7bd9f1..3b66a7cf 100644 --- a/lib/templates/minami.ejs +++ b/lib/templates/minami.ejs @@ -78,4 +78,20 @@ <% } %> +<% if(slots.length > 0) { %> +

Slots

+ + + + + + + + <% slots.forEach(function(c) { %> + + + <% }) %> +
NameDescription
<%- c.name %><%- typeof c.description === 'undefined' ? '-' : c.description %>
+<% } %> +

<%# Re-open JSDoc template tags %> diff --git a/lib/templates/tui.ejs b/lib/templates/tui.ejs index fa999bc5..4cddc04b 100644 --- a/lib/templates/tui.ejs +++ b/lib/templates/tui.ejs @@ -99,4 +99,22 @@

<% } %> +<% if(slots.length > 0) { %> +

Slots

+
+ + + + + + + + <% slots.forEach(function(c) { %> + + + <% }) %> +
NameDescription
<%- c.name %><%- typeof c.description === 'undefined' ? '-' : c.description %>
+
+<% } %> +

<%# Re-open JSDoc template tags %>