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 cannot parse component with template functional

See original GitHub issue

Current behavior

When launch yarn styleguide command, component functional (<template functional></template>) cause error :

Warning: vue-docgen-api cannot parse src/components/Button/Button.vue: SyntaxError: Unexpected token, expected ";"

To reproduce

I have the vue-styleguidist@3.11.4

Expected behavior

I would like template functional is parse by vue-docgen-api

Thank you very much by advance

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
schjetnecommented, Jun 19, 2019

This still seems to be an issue with certain <template functional> Vue components. I’m having the same problem. Here’s the entire component that fails:

<template functional>
  <div
    :class="{
      [$style.root]: true,
      [$style.error]: props.error,
      [$style.focused]: props.focused,
      [$style.hasIcon]: props.icon,
      [$style.disabled]: props.disabled
    }"
    >
    <label
      :class="{
        [$style.label]: true,
        [$style.labelFloating]: props.focused || (typeof props.value !== 'undefined' && props.value !== ''),
        [$style.labelAlwaysFloating]: props.labelAlwaysFloating || props.prefix || props.disabled,
      }"
      :for="props.id"
      >{{ props.label }}</label>
    <div
      :class="$style.inputGroup"
      >
      <SvgIcon
        v-if="props.icon"
        :name="props.icon"
        :class="$style.icon"
        />
      <div
        v-if="props.prefix"
        :class="$style.prefix"
        >{{ props.prefix }}</div>
      <div
        :class="$style.input"
        ><slot/></div>
    </div>
    <div
      :class="$style.errorMessage"
      >{{ props.errorMessage }}</div>
  </div>
</template>

<script>
/**
 * Wrapper for input elements
 */
export default {
  name: 'InputWrapper',
  status: 'ready',
  release: '0.0.1',
  props: {
    /**
     * Should display error?
     */
    error: {
      type: Boolean,
      default: false
    },
    /**
     * True if input label should always be "up there"
     */
    labelAlwaysFloating: {
      type: Boolean,
      default: false
    },
    /**
     * String for label text
     */
    label: {
      type: String,
      required: true
    },
    /**
     * Should the input be focused?
     */
    focused: {
      type: Boolean,
      default: false
    },
    /**
     * Should the input be disabled?
     */
    disabled: {
      type: Boolean,
      default: false
    },
    /**
     * Prefix string for input field
     */
    prefix: String,
    /**
     * Prefix icon for input field
     */
    icon: {
      type: String,
      default: ''
    },
    /**
     * String with relevant error message
     */
    errorMessage: {
      type: String,
      default: ''
    },
    /**
     * Input value
     */
    value: {
      required: true
    },
    /**
     * Input ID
     */
    id: {
      type: [String, Number],
      required: true
    },
  },
}
</script>

<style lang="scss" module>
/* Removed styles as they are irrelevant */
</style>

<docs>
  `` `jsx
  <input-wrapper label="Label" value="–" id="sdf">
    …
  </input-wrapper>
  `` `
</docs>

This happens when trying to include functional components in Vue Design System.

0reactions
schjetnecommented, Jun 19, 2019

Wonderful! Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-docgen-api - Vue Styleguidist
Function - Returns if an extended component should be parsed by docgen. NOTE If docgen fails to parse the targeted component, it will...
Read more >
vue-docgen-api - npm
vue-docgen-api is a toolbox to help extracting information from Vue components, and generate documentation from it. Use @babel/parser to parse ...
Read more >
Adjacent JSX elements must be wrapped in an enclosing tag ...
I am trying to set up my React.js app so that it only renders if a variable I have set is true ....
Read more >
gulp-vue-parser - npm Package Health Analysis - Snyk
Parse .vue file to a single cmd/umd javascript file For more information about how to use this package see README. Latest version published...
Read more >
vue-styleguidist - Bountysource
The return value of parse have been changed so this part of the example code (in the ... Trying to use a project...
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