vue-docgen-cli
Advanced tools
Comparing version 4.33.9 to 4.34.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [4.34.0](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.33.10...v4.34.0) (2020-11-25) | ||
### Features | ||
* **cli:** render props and bindings properly ([5e4c027](https://github.com/vue-styleguidist/vue-styleguidist/commit/5e4c0272e1f5b12a7223ad52055f68871525e27f)), closes [#1013](https://github.com/vue-styleguidist/vue-styleguidist/issues/1013) | ||
## [4.33.9](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.33.8...v4.33.9) (2020-11-16) | ||
@@ -8,0 +19,0 @@ |
@@ -15,2 +15,16 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
function formatProperties(properties) { | ||
if (!properties) { | ||
return ''; | ||
} | ||
return properties | ||
.map(function (property) { | ||
var name = property.name, description = property.description, type = property.type; | ||
if (!type) { | ||
return ''; | ||
} | ||
return "**" + name + "** `" + (type.names.length ? type.names.join(', ') : '') + "` - " + description; | ||
}) | ||
.join('\n'); | ||
} | ||
var tmpl = function (events) { | ||
@@ -20,4 +34,4 @@ var ret = ''; | ||
var _a = evt.description, description = _a === void 0 ? '' : _a, e = __rest(evt, ["description"]); | ||
var t = e.type && e.type.names ? e.type.names.join(' ') : ''; | ||
ret += "| " + utils_1.mdclean(e.name) + " | " + utils_1.mdclean(t) + " | " + utils_1.mdclean(description) + "\n"; | ||
var readableProperties = e.properties ? "" + formatProperties(e.properties) : ''; | ||
ret += "| " + utils_1.mdclean(e.name) + " | " + utils_1.mdclean(readableProperties) + " | " + utils_1.mdclean(description) + "\n"; | ||
}); | ||
@@ -28,4 +42,4 @@ return ret; | ||
if (opt === void 0) { opt = {}; } | ||
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Events\n\n | Event name | Type | Description |\n | ------------- |------------- | -------------|\n " + tmpl(events) + "\n "; | ||
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Events\n\n | Event name | Properties | Description |\n | -------------- |--------------- | -------------|\n " + tmpl(events) + "\n "; | ||
}); | ||
//# sourceMappingURL=events.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("./utils"); | ||
var formatBindings = function (bindings) { | ||
if (!bindings) { | ||
return ''; | ||
} | ||
return bindings | ||
.map(function (binding) { | ||
var name = binding.name, description = binding.description, type = binding.type; | ||
if (!type) { | ||
return ''; | ||
} | ||
return "**" + name + "** `" + (type.name === 'union' && type.elements | ||
? type.elements.map(function (_a) { | ||
var insideName = _a.name; | ||
return insideName; | ||
}).join(', ') | ||
: type.name) + "` - " + description; | ||
}) | ||
.join('\n'); | ||
}; | ||
exports.default = (function (slots, opt) { | ||
if (opt === void 0) { opt = {}; } | ||
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Slots\n\n| Name | Description | Bindings |\n| ------------- | ------------ | -------- |\n" + slots | ||
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Slots\n\n | Name | Description | Bindings |\n | ------------- | ------------ | -------- |\n " + slots | ||
.map(function (slot) { | ||
var d = slot.description, bindings = slot.bindings, name = slot.name; | ||
var readableBindings = bindings && Object.keys(bindings).length ? JSON.stringify(bindings, null, 2) : ''; // serialize bindings to display them ina readable manner | ||
return "| " + utils_1.mdclean(name) + " | " + utils_1.mdclean(d || '') + " | " + utils_1.mdclean(readableBindings) + " |"; // remplace returns by <br> to allow them in a table cell | ||
var description = slot.description, bindings = slot.bindings, name = slot.name; | ||
var readableBindings = bindings ? "" + formatBindings(bindings) : ''; | ||
return "| " + utils_1.mdclean(name) + " | " + utils_1.mdclean(description || '') + " | " + utils_1.mdclean(readableBindings) + " |"; // replace returns by <br> to allow them in a table cell | ||
}) | ||
@@ -12,0 +31,0 @@ .join('\n') + "\n"; |
{ | ||
"name": "vue-docgen-cli", | ||
"version": "4.33.9", | ||
"version": "4.34.0", | ||
"scripts": { | ||
@@ -23,3 +23,3 @@ "compile": "tsc -p ./tsconfig.build.json", | ||
"prettier": "^1.18.2", | ||
"vue-docgen-api": "^4.33.9" | ||
"vue-docgen-api": "^4.34.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "b9e996d344d68d004bec6ab1624cdef7c0270e77" | ||
"gitHead": "419f98605802ac7603b9e5d24bb09f882c535786" | ||
} |
@@ -5,2 +5,17 @@ import { EventDescriptor } from 'vue-docgen-api' | ||
function formatProperties(properties: EventDescriptor['properties']): string { | ||
if (!properties) { | ||
return '' | ||
} | ||
return properties | ||
.map(property => { | ||
const { name, description, type } = property | ||
if (!type) { | ||
return '' | ||
} | ||
return `**${name}** \`${type.names.length ? type.names.join(', ') : ''}\` - ${description}` | ||
}) | ||
.join('\n') | ||
} | ||
const tmpl = (events: EventDescriptor[]) => { | ||
@@ -10,4 +25,4 @@ let ret = '' | ||
const { description = '', ...e } = evt | ||
const t = e.type && e.type.names ? e.type.names.join(' ') : '' | ||
ret += `| ${mdclean(e.name)} | ${mdclean(t)} | ${mdclean(description)}\n` | ||
const readableProperties = e.properties ? `${formatProperties(e.properties)}` : '' | ||
ret += `| ${mdclean(e.name)} | ${mdclean(readableProperties)} | ${mdclean(description)}\n` | ||
}) | ||
@@ -21,6 +36,6 @@ return ret | ||
| Event name | Type | Description | | ||
| ------------- |------------- | -------------| | ||
| Event name | Properties | Description | | ||
| -------------- |--------------- | -------------| | ||
${tmpl(events)} | ||
` | ||
} |
@@ -5,2 +5,21 @@ import { SlotDescriptor } from 'vue-docgen-api' | ||
const formatBindings: (slot: SlotDescriptor['bindings']) => string = bindings => { | ||
if (!bindings) { | ||
return '' | ||
} | ||
return bindings | ||
.map(binding => { | ||
const { name, description, type } = binding | ||
if (!type) { | ||
return '' | ||
} | ||
return `**${name}** \`${ | ||
type.name === 'union' && type.elements | ||
? type.elements.map(({ name: insideName }) => insideName).join(', ') | ||
: type.name | ||
}\` - ${description}` | ||
}) | ||
.join('\n') | ||
} | ||
export default (slots: SlotDescriptor[], opt: SubTemplateOptions = {}): string => { | ||
@@ -10,13 +29,13 @@ return ` | ||
| Name | Description | Bindings | | ||
| ------------- | ------------ | -------- | | ||
${slots | ||
.map(slot => { | ||
const { description: d, bindings, name } = slot | ||
const readableBindings = | ||
bindings && Object.keys(bindings).length ? JSON.stringify(bindings, null, 2) : '' // serialize bindings to display them ina readable manner | ||
return `| ${mdclean(name)} | ${mdclean(d || '')} | ${mdclean(readableBindings)} |` // remplace returns by <br> to allow them in a table cell | ||
}) | ||
.join('\n')} | ||
| Name | Description | Bindings | | ||
| ------------- | ------------ | -------- | | ||
${slots | ||
.map(slot => { | ||
const { description, bindings, name } = slot | ||
const readableBindings = bindings ? `${formatBindings(bindings)}` : '' | ||
return `| ${mdclean(name)} | ${mdclean(description || '')} | ${mdclean(readableBindings)} |` // replace returns by <br> to allow them in a table cell | ||
}) | ||
.join('\n')} | ||
` | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
185606
3004
Updatedvue-docgen-api@^4.34.0