flozero / vuepress-plugin-docgen

auto docs generation for your components
https://f3ltron.github.io/vuepress-plugin-docgen/
MIT License
28 stars 3 forks source link

Multiple Component Directories #29

Closed travispamaral closed 5 years ago

travispamaral commented 5 years ago

Hi @f3ltron! 👋🏼

Quick question, our components live in a monorepo and are each in their own subdirectory. Is there a way to get all *.vue file in a directory instead of pointing to a single directory like the example?

packages
├── Alert
│   └── Alert.vue
│   └── Alert.spec.js
├── Button
│   └── Button.vue
│   └── Button.spec.js
├── Card
│   └── Card.vue
│   └── Card.spec.js

We're interested in trying out this plugin we just have a very specific codebase structure.

Thanks!

flozero commented 5 years ago

Hello ! Thank's for your issue and you interest !.

Just to be sure i understand.

Actually in docs

https://f3ltron.github.io/vuepress-plugin-docgen/guide/configuration.html#componentsdir

The logic behind is when you a folder after that i am using a regex that you can easy override in the configuration. By default it is */.vue.

After that the plugin create a tree of sub directories with 1 depth path.

packages
├── Alert
│   └── Alert.vue
│   └── Alert.spec.js
├── Button
│   └── Button.vue
│   └── Button.spec.js
├── Card
│   └── Card.vue
│   └── Card.spec.js

In your examples if you give

plugins: [
  // as we respect the naming convention vuepress-plugin-docgen you can juste docgen as name
  [ 'docgen',
    {
      componentsDir: path.join(__dirname, './packages'),
      regex: "**/*.vue" // this is the default config you can override here the regex
    }
  ]
]

In the doc generation you will now have something like:

Alert
│   └── Alert.vue
│   └── Alert.spec.js
├── Button
│   └── Button.vue
│   └── Button.spec.js
├── Card
│   └── Card.vue
│   └── Card.spec.js

Do I answer to your question ? If not tell me and try to explain a bit more or give me your repo i will have a look

flozero commented 5 years ago

@travispamaral

you can have a look in the example folder https://f3ltron.github.io/vuepress-plugin-docgen/components/

and here to check the implementation of the doc https://github.com/f3ltron/vuepress-plugin-docgen/tree/master/packages/examples

travispamaral commented 5 years ago

That does make sense! Is anything else needed to get docs generated? Will it automagically create them on docs:dev?

flozero commented 5 years ago

yes to make it work componentsDir is enough. in docs:dev you will have access to components.

if you want to navigate to it, add to the nav config the path /components or manually navigate to it

If you want an example check the exanple in my last comment and check the config.

Actually I just see something missing if you are using locales but it is not your use case apparently. But i will work on it. I created the issue and the explanation

flozero commented 5 years ago

@travispamaral tell me if all is good for you to close the issue :)

travispamaral commented 5 years ago

Yes I think so, I haven't had a chance to try it out but hopefully I can soon! Thanks again!

flozero commented 5 years ago

Cool thank's for using the plugin tell me if you any probleme huge features will come soon :)