vue-docgen-cli
Advanced tools
Comparing version 4.34.4 to 4.35.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [4.35.0](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.34.4...v4.35.0) (2021-01-26) | ||
### Features | ||
* **cli:** render tags in a props description ([72af302](https://github.com/vue-styleguidist/vue-styleguidist/commit/72af30256b4b069c7d7d5120b6f600f970313d84)), closes [#1045](https://github.com/vue-styleguidist/vue-styleguidist/issues/1045) | ||
## [4.34.4](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.34.3...v4.34.4) (2021-01-09) | ||
@@ -8,0 +19,0 @@ |
@@ -1,4 +0,7 @@ | ||
import { PropDescriptor } from 'vue-docgen-api'; | ||
import { ParamTag, PropDescriptor, Tag } from 'vue-docgen-api'; | ||
import { SubTemplateOptions } from '../compileTemplates'; | ||
export declare const renderTags: (tags?: { | ||
[tag: string]: (ParamTag | Tag)[]; | ||
} | undefined) => string; | ||
declare const _default: (props: PropDescriptor[], opt?: SubTemplateOptions) => string; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.renderTags = void 0; | ||
var utils_1 = require("./utils"); | ||
function isTag(v) { | ||
return !!v.content; | ||
} | ||
exports.renderTags = function (tags) { | ||
if (!tags) { | ||
return ''; | ||
} | ||
return Object.entries(tags) | ||
.map(function (_a) { | ||
var tag = _a[0], values = _a[1]; | ||
return values.map(function (v) { return "<br/>`@" + tag + "` " + (isTag(v) ? v.content : v.description); }).join(''); | ||
}) | ||
.join(''); | ||
}; | ||
var tmpl = function (props) { | ||
var ret = ''; | ||
props.forEach(function (pr) { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
var p = pr.name; | ||
var n = pr.type && pr.type.name ? pr.type.name : ''; | ||
var d = pr.defaultValue && pr.defaultValue.value ? pr.defaultValue.value : ''; | ||
var v = pr.values ? pr.values.map(function (pv) { return "`" + pv + "`"; }).join(', ') : '-'; | ||
var t = pr.description ? pr.description : ''; | ||
var t = (_a = pr.description) !== null && _a !== void 0 ? _a : ''; | ||
t += exports.renderTags(pr.tags); | ||
var n = (_c = (_b = pr.type) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : ''; | ||
var v = (_e = (_d = pr.values) === null || _d === void 0 ? void 0 : _d.map(function (pv) { return "`" + pv + "`"; }).join(', ')) !== null && _e !== void 0 ? _e : '-'; | ||
var d = (_g = (_f = pr.defaultValue) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''; | ||
ret += "| " + utils_1.mdclean(p) + " | " + utils_1.mdclean(t) + " | " + utils_1.mdclean(n) + " | " + utils_1.mdclean(v) + " | " + utils_1.mdclean(d) + " |\n"; | ||
@@ -18,4 +35,4 @@ }); | ||
if (opt === void 0) { opt = {}; } | ||
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Props\n\n | Prop name | Description | Type | Values | Default |\n | ------------- |-------------| --------- | ----------- | ----------- |\n " + tmpl(props) + "\n "; | ||
return "\n" + (opt.isSubComponent || opt.hasSubComponents ? '#' : '') + "## Props\n\n | Prop name | Description | Type | Values | Default |\n | ------------- | ----------- | --------- | ----------- | ----------- |\n " + tmpl(props) + "\n "; | ||
}); | ||
//# sourceMappingURL=props.js.map |
{ | ||
"name": "vue-docgen-cli", | ||
"version": "4.34.4", | ||
"version": "4.35.0", | ||
"scripts": { | ||
@@ -23,3 +23,3 @@ "compile": "tsc -p ./tsconfig.build.json", | ||
"prettier": "^1.18.2", | ||
"vue-docgen-api": "^4.34.2" | ||
"vue-docgen-api": "^4.35.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "abca2c475e843a496ae0487beafbd8e96b6f89b9" | ||
"gitHead": "bdfa2a363cffd2ef9f9462b8b4cf0b89d8a8c6fa" | ||
} |
@@ -1,5 +0,20 @@ | ||
import { PropDescriptor } from 'vue-docgen-api' | ||
import { ParamTag, PropDescriptor, Tag } from 'vue-docgen-api' | ||
import { mdclean } from './utils' | ||
import { SubTemplateOptions } from '../compileTemplates' | ||
function isTag(v: Tag | ParamTag): v is Tag { | ||
return !!(v as any).content | ||
} | ||
export const renderTags = (tags?: { [tag: string]: (Tag | ParamTag)[] }): string => { | ||
if (!tags) { | ||
return '' | ||
} | ||
return Object.entries(tags) | ||
.map(([tag, values]) => { | ||
return values.map(v => `<br/>\`@${tag}\` ${isTag(v) ? v.content : v.description}`).join('') | ||
}) | ||
.join('') | ||
} | ||
const tmpl = (props: PropDescriptor[]): string => { | ||
@@ -10,6 +25,7 @@ let ret = '' | ||
const p = pr.name | ||
const n = pr.type && pr.type.name ? pr.type.name : '' | ||
const d = pr.defaultValue && pr.defaultValue.value ? pr.defaultValue.value : '' | ||
const v = pr.values ? pr.values.map(pv => `\`${pv}\``).join(', ') : '-' | ||
const t = pr.description ? pr.description : '' | ||
let t = pr.description ?? '' | ||
t += renderTags(pr.tags) | ||
const n = pr.type?.name ?? '' | ||
const v = pr.values?.map(pv => `\`${pv}\``).join(', ') ?? '-' | ||
const d = pr.defaultValue?.value ?? '' | ||
@@ -26,5 +42,5 @@ ret += `| ${mdclean(p)} | ${mdclean(t)} | ${mdclean(n)} | ${mdclean(v)} | ${mdclean(d)} |\n` | ||
| Prop name | Description | Type | Values | Default | | ||
| ------------- |-------------| --------- | ----------- | ----------- | | ||
| ------------- | ----------- | --------- | ----------- | ----------- | | ||
${tmpl(props)} | ||
` | ||
} |
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
189243
88
3059
Updatedvue-docgen-api@^4.35.0