diff --git a/__tests__/__snapshots__/test.js.snap b/__tests__/__snapshots__/test.js.snap index cbfa02d94..229ac934d 100644 --- a/__tests__/__snapshots__/test.js.snap +++ b/__tests__/__snapshots__/test.js.snap @@ -558,6 +558,8 @@ Array [ ] `; +exports[`Vue file 2`] = `Array []`; + exports[`config 1`] = ` " diff --git a/__tests__/fixture/vue-no-script.input.vue b/__tests__/fixture/vue-no-script.input.vue new file mode 100644 index 000000000..8912669ca --- /dev/null +++ b/__tests__/fixture/vue-no-script.input.vue @@ -0,0 +1,7 @@ + + + diff --git a/__tests__/test.js b/__tests__/test.js index 824630635..eaf9cc01c 100644 --- a/__tests__/test.js +++ b/__tests__/test.js @@ -242,6 +242,16 @@ test('Vue file', async function() { expect(data).toMatchSnapshot(); }); +test('Vue file', async function() { + await pify(chdir)(__dirname); + const data = await documentation.build( + '__tests__/fixture/vue-no-script.input.vue', + {} + ); + normalize(data); + expect(data).toMatchSnapshot(); +}); + test('Use Source attribute only', async function() { await pify(chdir)(__dirname); const documentationSource = ` diff --git a/src/parsers/vue.js b/src/parsers/vue.js index 00e4e4e60..9a24b1c21 100644 --- a/src/parsers/vue.js +++ b/src/parsers/vue.js @@ -12,7 +12,9 @@ const vuecompiler = require('vue-template-compiler'); * @returns {Array} an array of parsed comments */ function parseVueScript(data: Object, config: DocumentationConfig) { - data.source = vuecompiler.parseComponent(data.source).script.content; + const component = vuecompiler.parseComponent(data.source); + if (!component.script) return []; + data.source = component.script.content; return parseJavaScript(data, config); }