How to use @vuese/parser - 4 common examples

To help you get started, we’ve selected a few @vuese/parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shuidi-fed / vuese / packages / cli / lib / genMarkdown.ts View on Github external
return files.map(async (p: string) => {
    const abs = path.resolve(p)
    const source = await fs.readFile(abs, 'utf-8')
    try {
      const parserRes = parser(source, {
        babelParserPlugins,
        basedir: path.dirname(abs)
      })
      const r = new Render(parserRes)
      let markdownRes = r.renderMarkdown()

      if (!markdownRes) return

      let str = markdownRes.content
      let compName = markdownRes.componentName
        ? markdownRes.componentName
        : path.basename(abs, '.vue')
      const groupName = markdownRes.groupName

      str = str.replace(/\[name\]/g, compName)
      let targetDir = ''
github SAP / fundamental-vue / src / tools / index.js View on Github external
const parseFileAtPath = path => {
  const source = fs.readFileSync(path, "utf-8");
  try {
    return fixedParserResult(parser(source));
  } catch (e) {
    return {};
  }
};
github SAP / fundamental-vue / src / tools / parse-result-from-sfc.js View on Github external
const parseResultFromSfc = code => {
  try {
    const result = parser(code)
    const { name = '' } = result
    const slots = []
    for (const slotToAdd of result.slots || []) {
      const index = slots.findIndex(slot => slot.name === slotToAdd.name)
      if (index < 0) {
        slots.push(slotToAdd)
      } else {
        const existingSlot = slots[index]
        if (existingSlot.target === 'template') {
          continue
        }
        slots.splice(index, 1, slotToAdd)
      }
    }
    return {
      ...result,
github BuptStEve / markdown-it-vuese / src / index.js View on Github external
function getMdFromSfc (filePath) {
        if (!fs.existsSync(filePath)) return `Not found: ${filePath}`

        try {
            const content = fs.readFileSync(filePath, 'utf-8')
            const parserRes = vueseParser(content, parserOptions)

            if (isFn(useParser)) return useParser(parserRes)

            const vueseRender = new VueseRender(parserRes, renderOptions)

            if (isFn(useRender)) return useRender(vueseRender)

            const renderRes = vueseRender.render()
            const markdownRes = vueseRender.renderMarkdown()

            return isFn(useAll)
                ? useAll({ content, parserRes, renderRes, markdownRes })
                : markdownRes.content
        } catch (e) {
            return e.message
        }

@vuese/parser

Vue file parser for automatic document generation

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular @vuese/parser functions