vue-docgen-api: Doesn't understand or properly parse Proxy components
See original GitHub issueCurrent behavior
Take this file for example:
Simple.vue
<template>
<div>
<slot />
<slot name="namedSlot" />
</div>
</template>
<script>
export default {
props: {
color: {
type: String,
default: '#112233',
},
disabled: {
type: Boolean,
default: false,
},
size: {
type: String,
default: 'medium',
validator: (size) => ['small', 'medium', 'large'].includes(size),
}
},
methods: {
emitEvents() {
this.$emit('eventType1');
this.$emit('eventType2', true);
this.$emit('eventType3', 'string');
},
},
};
</script>
It’s parsed as such:
Simple.parsed.json
{
"exportName": "default",
"displayName": "Simple",
"description": "",
"tags": {},
"props": [
{
"name": "color",
"type": {
"name": "string"
},
"defaultValue": {
"func": false,
"value": "'#112233'"
}
},
{
"name": "disabled",
"type": {
"name": "boolean"
},
"defaultValue": {
"func": false,
"value": "false"
}
},
{
"name": "size",
"type": {
"name": "string"
},
"defaultValue": {
"func": false,
"value": "'medium'"
},
"values": [
"small",
"medium",
"large"
]
}
],
"events": [
{
"name": "eventType1"
},
{
"name": "eventType2",
"type": {
"names": [
"undefined"
]
}
},
{
"name": "eventType3",
"type": {
"names": [
"undefined"
]
}
}
],
"slots": [
{
"name": "default"
},
{
"name": "namedSlot"
}
]
}
However if we have a component that does nothing other than proxying its attributes, props, and listeners to a child component:
SimpleProxy.vue
<template>
<simple v-bind="$attrs" v-on="$listeners">
<template
v-for="(_, slot) of $slots"
#[slot]
>
<slot :name="slot" />
</template>
</simple>
</template>
<script>
import Simple from 'Simple.vue';
export default {
inheritAttrs: false,
components: {
Simple,
},
};
</script>
Then it’s parsed as such:
SimpleProxy.parsed.json
{
"exportName": "default",
"displayName": "SimpleProxy",
"description": "",
"tags": {},
"slots": [
{
"name": "default",
"scoped": true,
"bindings": [
{
"name": "name",
"title": "binding"
}
]
}
]
}
I would expect Simple.vue and SimpleProxy.vue to have the exact same parsed output, at least in terms of documenting the valid attributes, props, and events.
To reproduce
Reproduction Repo: vue-docgen-bugs
Expected behavior
I would expect Simple.vue and SimpleProxy.vue to have the exact same parsed output, at least in terms of documenting the valid attributes, props, and events.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
vue-docgen-api - Vue Styleguidist
Parses the file at filePath. Returns and objects containing all documented and undocumented properties of the component. import { parse } from ...
Read more >vue-styleguidist - Bountysource
When adding a code example using class style components, I get a rendering error. There is no documentation on how to write code...
Read more >How to resolve "Cannot use import statement outside a ...
Also using Babel, Typescript and Jest. Had the same failure, driving me crazy for hours. Ended up creating a new babel.config.js file ...
Read more >list of all node.js modules created on June 24, 2013
=velrok 2012-08-30 07:39 1.0.4 http accept-language parser nodejs acceptance Validate ... =philjackson 2013-06-23 13:28 1.9.29 apiaxle proxy api rest soap ...
Read more >pytest Documentation - Read the Docs
evaluating the parsed examples as part of your normal test run. ... pytest doesn't know where c should go in the case, so...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I just updated my original comment to include proxying slots, so it would be a little bit more complicated than this, but the remaining steps sound fine.
I currently have a workaround in my codebase, I explicitly annotate which child components get proxied in the JSDoc of the parent component, e.g.
I use the annotations to grab, parse, and merge the results of the child component with the parent component. Since my workaround currently suits my needs I don’t have extra time to implement this feature directly into vue-docgen-api, but it would still be nice if it existed by default in the library.
Hey @elevatebart,
I’m quite short on time aswell at the moment, so probably not anytime soon I’m afraid… Don’t feel pressured though. I think it’s good this issue is open again, so maybe other people become aware of it 😃