vuese / roadmap

Vuese2.x Roadmap
5 stars 2 forks source link

JSON genType for CLI #2

Open sagalbot opened 5 years ago

sagalbot commented 5 years ago

Documenting props and events in my open source component has always been a time suck and I'm really excited at the prospect of this project, thanks for the great work so far.

I already have an existing VuePress site with extensive documentation, so the existing outputs of docute and markdown present challenges.

Have you considered a JSON output? This would allow a lot of flexibility for those that have to integrate with existing documentation site. If I had a JSON file, I could create a component that iterates the contents and have full control over the display of the information.

HcySunYang commented 5 years ago

Can @vuese/parser meet your needs? Maybe @vuese/loader can do better, but it's still under planning.

sagalbot commented 5 years ago

I believe it could, but I wasn't sure how to get it up and running. I wasn't sure what to do with the snippet:

// Import parser function
import { parser } from '@vuese/parser'

// Read vue file content
const source = fs.readFileSync('path-to-your-component.vue', 'utf-8')

// Parse and get the result using the parser function
try {
  const parserRes = parser(source)
} catch(e) {
  console.error(e)
}

Because fs is being called, I figured this must need to be executed by now, sop I threw this into generate.js and then run node generate.js, but I don't think that's the suggested approach.

HcySunYang commented 5 years ago

I just realized that you are using VuePress, and here is a community plugin: https://buptsteve.github.io/markdown-it-vuese/example/. It can be used for VuePress, what do you think?

Edit: https://buptsteve.github.io/markdown-it-vuese/example/vuepress.html