question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vue-docgen-api doesn't support mixins which are result of function execution

See original GitHub issue

Hi, I’m trying to use vue-styleguidist in a project which uses next pattern for mixins

// mixin.js
const factory = () => Vue.extend({});
export default factory();

// component.vue
<script>
import Vue from 'vue';
import mixin from './mixin';

export default Vue.extend({
  name: 'example',
  mixins: [
    mixin
  ]
});
</script>

All these components will be ignored by vue-docgen-api The same issues happens for nested extend like

// component.vue
<script>
import Vue from 'vue';

export default Vue.extend().extend({
  name: 'example2',
});
</script>

Do you think these cases should be covered as well? And do you have plans to implement this functionality?

Thanks, Sergey

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kyleoliveirocommented, Mar 12, 2020

Thanks for reopening the issue. I’ll describe my use case below.

I have a mixin named CustomTagProvider which I use to provide a tag prop to components so users can choose to render their root elements using a custom html tag. I want the default value of tag to be able to be varied based on which component this mixin is applied on.

mixins/CustomTagProvider.js

export default ({ value = 'div' } = {}) => ({
  props: {
    tag: {
      type: String,
      default: value,
    },
  },
});
0reactions
elevatebartcommented, Aug 4, 2020

Hello @kyleoliveiro, Hello @steplov,

vue-docgen-api, since version 4.27.0 can extract some information from mixins factories (functions returning a mixin).

  • The info extracted has to be static and contained in the return statement of the function.
  • It also works if it is an arrow function and the object returned is a valid component.

Hope this works for you, if not, please feel free to re-open this issue 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-docgen-api - Vue Styleguidist
Every parser in docgen-api returns an instance of ComponentDoc or a ComponentDoc[] . interface ComponentDoc { /** * Usual name of the component:...
Read more >
Specific vue mixin function doesn't get executed - Stack Overflow
I am using Vue.js with global functions which I have definied under Vue mixin . In my component I call different functions from...
Read more >
vue-docgen-api - npm
vue -docgen-api is a toolbox to help extracting information from Vue components, and generate documentation from it.
Read more >
list of all node.js modules created on June 24, 2013
=joostdevries 2012-11-25 13:26 0.2.1 async-memo Call a function at most once and remember the result. Args are not supported =eldar 2013-06-08 14:52 0.0.1 ......
Read more >
The Future of Continuing Education - Masterplan.com
@babel/helper-member-expression-to-functions plus ... @babel/plugin-proposal-do-expressions plus ... vue-docgen-api plus. vue-docgen-loader plus.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found