Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions __tests__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ Array [
]
`;

exports[`Vue file 2`] = `Array []`;

exports[`config 1`] = `
"<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

Expand Down
7 changes: 7 additions & 0 deletions __tests__/fixture/vue-no-script.input.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<div>not relevant</div>
</template>

<style>

</style>
10 changes: 10 additions & 0 deletions __tests__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down
4 changes: 3 additions & 1 deletion src/parsers/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const vuecompiler = require('vue-template-compiler');
* @returns {Array<Object>} 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);
}

Expand Down