vue-docgen-api
Advanced tools
Comparing version 4.64.0 to 4.64.1
@@ -187,3 +187,3 @@ "use strict"; | ||
typeAnnotation.types.every(t => bt.isTSLiteralType(t))) { | ||
typeValues = typeAnnotation.types.map((t) => bt.isUnaryExpression(t.literal) ? t.literal.argument.toString() : t.literal.value.toString()); | ||
typeValues = typeAnnotation.types.map((t) => 'literal' in t ? (bt.isUnaryExpression(t.literal) ? t.literal.argument.toString() : t.literal.value.toString()) : t.type.toString()); | ||
} | ||
@@ -198,3 +198,5 @@ return false; | ||
propDescriptor.type = typeDesc; | ||
return getTypeFromTypePath(typeArray[0].get('value')).name; | ||
if (typeArray.length) { | ||
return getTypeFromTypePath(typeArray[0].get('value')).name; | ||
} | ||
} | ||
@@ -201,0 +203,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
describe('propHandler', () => { | ||
(0, vitest_1.describe)('propHandler', () => { | ||
let documentation; | ||
@@ -38,6 +38,6 @@ let mockPropDescriptor; | ||
const options = { filePath: '', validExtends: () => true }; | ||
beforeAll(() => { | ||
(0, vitest_1.beforeAll)(() => { | ||
defaultAST = (0, babel_parser_1.default)({ plugins: ['typescript'] }).parse('const a = 1'); | ||
}); | ||
beforeEach(() => { | ||
(0, vitest_1.beforeEach)(() => { | ||
mockPropDescriptor = { | ||
@@ -49,3 +49,3 @@ description: '', | ||
documentation = new Documentation_1.default('test/path'); | ||
const mockGetPropDescriptor = vi.spyOn(documentation, 'getPropDescriptor'); | ||
const mockGetPropDescriptor = vitest_1.vi.spyOn(documentation, 'getPropDescriptor'); | ||
mockGetPropDescriptor.mockReturnValue(mockPropDescriptor); | ||
@@ -62,4 +62,4 @@ }); | ||
} | ||
describe('base', () => { | ||
it('should accept an array of string as props', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('base', () => { | ||
(0, vitest_1.it)('should accept an array of string as props', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -77,4 +77,4 @@ export default { | ||
}); | ||
describe('type', () => { | ||
it('should return the right props type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('type', () => { | ||
(0, vitest_1.it)('should return the right props type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -97,3 +97,3 @@ export default { | ||
})); | ||
it('should return the right props type for lit Array', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should return the right props type for lit Array', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -110,3 +110,3 @@ export default { | ||
})); | ||
it('should return the right props composite type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should return the right props composite type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -125,3 +125,3 @@ export default { | ||
})); | ||
it('should return the right props type for Array', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should return the right props type for Array', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -138,3 +138,3 @@ export default { | ||
})); | ||
it('should not return required if prop only Type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should not return required if prop only Type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -153,3 +153,3 @@ export default { | ||
})); | ||
it('should return the right props type string', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should return the right props type string', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -166,3 +166,3 @@ export default { | ||
})); | ||
it('should return the right props composite string|number', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should return the right props composite string|number', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -179,3 +179,3 @@ export default { | ||
})); | ||
it('should deduce the prop type from the default value', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should deduce the prop type from the default value', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -194,3 +194,3 @@ export default { | ||
})); | ||
it('should still return props with vue-types', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should still return props with vue-types', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -212,3 +212,3 @@ export default { | ||
})); | ||
it('should still return props with prop-types', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should still return props with prop-types', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -226,3 +226,3 @@ export default { | ||
})); | ||
it('should still return props with delegated types', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should still return props with delegated types', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = ['export default {', ' props: {', ' toto', ' }', '}'].join('\n'); | ||
@@ -234,4 +234,4 @@ (0, vitest_1.expect)(yield parserTest(src)).toMatchObject({ | ||
}); | ||
describe('required', () => { | ||
it('should return the right required props', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('required', () => { | ||
(0, vitest_1.it)('should return the right required props', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -255,8 +255,8 @@ export default { | ||
}); | ||
describe('defaultValue', () => { | ||
it('should be ok with just the default', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('defaultValue', () => { | ||
(0, vitest_1.it)('should be ok with just the default', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
export default { | ||
props: { | ||
test: { | ||
testDefault: { | ||
default: 'normal' | ||
@@ -270,4 +270,5 @@ } | ||
}); | ||
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testDefault'); | ||
})); | ||
it('should be ok with the default as a method', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should be ok with the default as a method', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -293,3 +294,3 @@ export default { | ||
})); | ||
it('should deal properly with multiple returns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should deal properly with multiple returns', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -318,3 +319,3 @@ export default { | ||
})); | ||
it('should deal properly with multiple returns in arrow functions', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should deal properly with multiple returns in arrow functions', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -343,3 +344,3 @@ export default { | ||
})); | ||
it('should not have parenthesis', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should not have parenthesis', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -402,4 +403,4 @@ export default { | ||
}); | ||
describe('description', () => { | ||
it('should return the right description', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('description', () => { | ||
(0, vitest_1.it)('should return the right description', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -422,4 +423,4 @@ export default { | ||
}); | ||
describe('v-model', () => { | ||
it('should set the @model property as v-model instead of test', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('v-model', () => { | ||
(0, vitest_1.it)('should set the @model property as v-model instead of test', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -442,3 +443,3 @@ export default { | ||
})); | ||
it('should set the @model property as v-model instead of value even with a type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should set the @model property as v-model instead of value even with a type', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -464,3 +465,3 @@ export default { | ||
})); | ||
it('should set the v-model instead of value with model property', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should set the v-model instead of value with model property', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -488,3 +489,3 @@ export default { | ||
})); | ||
it('should not set the v-model instead of value if model property has only event', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should not set the v-model instead of value if model property has only event', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -512,3 +513,3 @@ export default { | ||
})); | ||
it('should not set and crash if model is not literal object', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should not set and crash if model is not literal object', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -539,4 +540,4 @@ const getModel = () => ({ | ||
}); | ||
describe('@values tag parsing', () => { | ||
it('should parse the @values tag as its own', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('@values tag parsing', () => { | ||
(0, vitest_1.it)('should parse the @values tag as its own', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -571,3 +572,3 @@ export default { | ||
})); | ||
it('should check the validator method for super standard values', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should check the validator method for super standard values', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -587,3 +588,3 @@ export default { | ||
})); | ||
it('should check the validator method for super standard values with the diff signs', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should check the validator method for super standard values with the diff signs', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -603,3 +604,3 @@ export default { | ||
})); | ||
it('should check the validator function for super standard values with the diff signs', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should check the validator function for super standard values with the diff signs', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -619,3 +620,3 @@ export default { | ||
})); | ||
it('should check the validator arrow function for inline values', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should check the validator arrow function for inline values', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -634,3 +635,3 @@ export default { | ||
})); | ||
it('should check the validator method for identifiers', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should check the validator method for identifiers', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -657,4 +658,4 @@ const array = ['dark', 'light', 'red', 'blue'] | ||
}); | ||
describe('typescript Vue.extends', () => { | ||
it('should be ok with Prop', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('typescript Vue.extends', () => { | ||
(0, vitest_1.it)('should be ok with Prop', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -677,3 +678,3 @@ export default Vue.extend({ | ||
})); | ||
it('should parse values in TypeScript typings', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should parse values in TypeScript typings', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -693,3 +694,3 @@ export default Vue.extend({ | ||
})); | ||
it('should parse values in TypeScript typings with complete object', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should parse values in TypeScript typings with complete object', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -713,3 +714,3 @@ export default Vue.extend({ | ||
})); | ||
it('should understand As annotations at the end of a prop definition', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should understand As annotations at the end of a prop definition', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -734,3 +735,3 @@ export default Vue.extend({ | ||
})); | ||
it('should understand "as const" in prop default values', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should understand "as const" in prop default values', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -752,4 +753,4 @@ export default Vue.extend({ | ||
}); | ||
describe('@type', () => { | ||
it('should use @type typings', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.describe)('@type', () => { | ||
(0, vitest_1.it)('should use @type typings', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -773,3 +774,3 @@ export default { | ||
})); | ||
it('should extract values from @type typings', () => __awaiter(void 0, void 0, void 0, function* () { | ||
(0, vitest_1.it)('should extract values from @type typings', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const src = (0, dedent_1.default) ` | ||
@@ -776,0 +777,0 @@ export default { |
import * as bt from '@babel/types'; | ||
import { NodePath } from 'ast-types/lib/node-path'; | ||
export default function getMemberFilter(propName: string): (propPath: NodePath<bt.ObjectProperty>) => boolean; | ||
export default function getMemberFilter(propName: string): (propPath: NodePath<bt.ObjectProperty | bt.ObjectMethod>) => boolean; |
{ | ||
"name": "vue-docgen-api", | ||
"version": "4.64.0", | ||
"version": "4.64.1", | ||
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.", | ||
@@ -38,3 +38,3 @@ "homepage": "https://vue-styleguidist.github.io", | ||
"ts-map": "^1.0.3", | ||
"vue-inbrowser-compiler-independent-utils": "^4.64.0" | ||
"vue-inbrowser-compiler-independent-utils": "^4.64.1" | ||
}, | ||
@@ -41,0 +41,0 @@ "devDependencies": { |
498183
11687