Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixin with a .vue file is not displayed in the doc #158

Closed
vdcrea opened this issue Jul 12, 2018 · 13 comments · Fixed by vue-styleguidist/vue-docgen-api#94
Closed

Mixin with a .vue file is not displayed in the doc #158

vdcrea opened this issue Jul 12, 2018 · 13 comments · Fixed by vue-styleguidist/vue-docgen-api#94
Assignees
Labels
bug Something isn't working

Comments

@vdcrea
Copy link

vdcrea commented Jul 12, 2018

Hi, and thanks to contributors for this great lib.

import a .vue file (not .js) as a mixin (even with relative path) hide it from the doc. Do you have any workaround for that ?

@elevatebart
Copy link
Member

elevatebart commented Oct 20, 2018

Hello @vdcrea,
I apologize for not anwering sooner, I hope to be able to look into this issue.

I do not know how to create a mixin in a vue file.
Would you have a repository where I could reproduce your issue?

@vdcrea
Copy link
Author

vdcrea commented Oct 22, 2018

Hi @elevatebart,

No worries, I documented using the md

Here is a vue component used as a mixin: https://gitlab.com/vdcrea/vue-leaflet/blob/master/src/mixins/LeafletLayer.vue

Imported in this component for exemple: https://gitlab.com/vdcrea/vue-leaflet/blob/master/src/components/core/LMap.vue#L13

In styleguidist https://vdcrea.gitlab.io/vue-leaflet/#lmap documentation from this .vue mixin is not injected. 'id', 'options', 'tooltip' and 'popup' props are not visible in the doc.

Basically, a .vue file is a .js when imported, so it can be a mixin as a js file can (the styles are ignored, and the template tag is converted to a template prop at build... I presume)

By the way, for this particular exemple, as the file has no style and only 1 line of template, I should probably convert it to js using the template property of the component, instead of the template tag.

@elevatebart
Copy link
Member

@vdcrea
We just released 3.0 and it should be way better now. Can you tell me if you still do not see your mixin?

@elevatebart elevatebart added the bug Something isn't working label Jan 21, 2019
@elevatebart elevatebart self-assigned this Jan 21, 2019
@angelowolf
Copy link

Hello in the release 3.0.9, this dosent work yet.

@elevatebart
Copy link
Member

Hello @angelowolf,

Would you please tell me what error you are getting?
Maybe the shape of your component.

@angelowolf
Copy link

Hello we have a base component, wich is used as a mixins in many other components. The template is only in the mixins. The mixins looks like this:

<template>
  <button v-tooltip.hover="tooltip" @click.prevent="$emit('click')" :class="`btn btn-${type} ${(size && ' btn-'+size)} ${clase}`" type="button">{{label}}</button>
</template>
<script>
  /**
  * Estructura base para todos los botones.
  * @mixin
  */
  export default {
    props: {
      /**
      * Clase que se le agrega al botón.
      */
      clase: {
        default: '',
        type: String
      },
      /**
      * El tipo de botón.
      * `primary, primary2, info, default, default2, danger, danger2, warning, warning2, success`
      */
      type: {
        default: 'primary',
        type: String
      },
      /**
      * El tamaño del botón.
      * `xs, sm, md, lg`
      */
      size: {
        default: 'sm',
        type: String
      },
      /**
      * Label a mostrar en el botón.
      */
      label: {
        default: '',
        type: String
      },
      /**
      * El texto a mostrar en el tooltip del botón.
      */
      tooltip: {
        default: '',
        type: String
      }
    }
  }
</script>

And this is an example of a componente that uses it:

<script>
import TrxButtonBase from './TrxButtonBase'

export default {
  mixins: [TrxButtonBase],
  props: {
    /**
    * Label a mostrar en el botón.
    */
    label: {
      default: 'Volver',
      type: String
    },
    /**
    * El tipo de botón.
    * `primary, primary2, info, default, default2, danger, danger2, warning, warning2, success`
    */
    type: {
      default: 'info',
      type: String
    },
    /**
    * El texto a mostrar en el tooltip del botón.
    */
    tooltip: {
      default: 'Volver',
      type: String
    }
  }
}
</script
``

The library only generates the docs for the mixin component.

@elevatebart
Copy link
Member

elevatebart commented Feb 3, 2019 via email

@elevatebart
Copy link
Member

elevatebart commented Feb 3, 2019 via email

@angelowolf
Copy link

Hello this is the repository

The TrxButtonBase is the mixins component, and the others TrxButtonXXX are components that use the mixin.

In the picture you can only see the documentation of the mixin and not the other components.

example_mixins

Thanks!

@vdcrea
Copy link
Author

vdcrea commented Feb 3, 2019

@angelowolf as a workaround and as the template is not so long, did you try to change the .vue mixin to a .js mixin with your template in a render function (ex https://sebastiandedeyne.com/vue-templates-in-jsx/ )?

@angelowolf
Copy link

@vdcrea
I can refactor this component to render functions, but I also have other componemts with mixins where the template is very big (200+ lines), it will be a cumbersome process.
That's why I think it would be nice if the mixins are supported, so that this plugin can be used in projects without having to refactor the code.

@elevatebart
Copy link
Member

I am working on it. I just needed a concrete example. It will not take long. It was an issue of file resolution.

NodeJs require.resolve never looks at .vue files by default. One has to tell it to do so.

@elevatebart
Copy link
Member

I am done, I'll deliver tomorow morning with a fresher mind ;)
Thank you for the help.

elevatebart added a commit to vue-styleguidist/vue-docgen-api that referenced this issue Feb 4, 2019
)

* add e2e test for #92

* add tests and create the immediately export lib

* need better name for New file + tests

* add resolution of vue files for dependencies

* fix naming a little

* fix unit tests

* first unit test

* fix tests

* fix compile

* fix case issue in e2e

* better arch for resolvePath

* better tests for file resolution

closes #92 and vue-styleguidist/vue-styleguidist#158
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants