Documentation generator doesn't like inline default props that access the vue instance.
Certain default props cause the docs generator to crash.
As far as my investigation revealed, the prop must:
- be of type
Function
- have an 'inline' default (as in
default
is a direct function, not a reference. e.g.default() { ... }
) - this inline default must attempt to access the vue instance (e.g. via
this
)
There might be more situations where the same issue occurs.
To reproduce
Ensure that a component has the aforementioned style of default prop. e.g.:
props: {
formatTooltipText: {
type: Function,
required: false,
default(...args) {
return this.defaultFormatTooltipText(...args);
}
},
},
methods: {
defaultFormatTooltipText(params) {
return this.name + params.text;
}
}
Note: This pattern normally works ok, see http://jsfiddle.net/fkL4yw6s/1/
Output
Relevant function: https://gitlab.com/gitlab-org/gitlab-ui/blob/4151e310fe17606c9c853ffc33fc2cd578368f9c/documentation/components/component_documentation_generator.vue#L20
Example stack trace:
index.js:39 TypeError: Cannot read property 'defaultFormatTooltipText' of undefined
at default (area.vue:49)
at getPropDefaultValue (component_documentation_generator.vue:26)
at component_documentation_generator.vue:149
at Array.map (<anonymous>)
at VueComponent.getPropsMap (component_documentation_generator.vue:128)
at VueComponent.componentProperties (component_documentation_generator.vue:90)
at Watcher.get (vue.esm.js:4482)
at Watcher.evaluate (vue.esm.js:4587)
at VueComponent.computedGetter [as componentProperties] (vue.esm.js:4839)
at VueComponent.displayComponentProperties (component_documentation_generator.vue:101)
Edited by Tristan Read