diff --git a/lib/v3/parser.js b/lib/v3/parser.js
index 259d1c2..efbe8f1 100644
--- a/lib/v3/parser.js
+++ b/lib/v3/parser.js
@@ -117,7 +117,10 @@ class Parser extends EventEmitter {
emitGlobalComment(comment) {
if (comment && utils.isTopLevelComment(comment)) {
if (this.features.includes('description')) {
- this.emit(ParserEvent.DESCRIPTION, comment.description);
+ const description = comment.description ||
+ comment.keywords.find(k => k.name === 'component').description;
+
+ this.emit(ParserEvent.DESCRIPTION, description);
}
if (this.features.includes('keywords')) {
diff --git a/test/svelte3/integration/globalComment/globalComment.markup-off.svelte b/test/svelte3/integration/globalComment/globalComment.markup-off.svelte
new file mode 100644
index 0000000..616b52a
--- /dev/null
+++ b/test/svelte3/integration/globalComment/globalComment.markup-off.svelte
@@ -0,0 +1,23 @@
+
+
+
+
+
+ Hello, {name}
+
+
+
diff --git a/test/svelte3/integration/globalComment/globalComment.spec.js b/test/svelte3/integration/globalComment/globalComment.spec.js
index 9fc7457..30d708f 100644
--- a/test/svelte3/integration/globalComment/globalComment.spec.js
+++ b/test/svelte3/integration/globalComment/globalComment.spec.js
@@ -27,6 +27,24 @@ describe('SvelteDoc v3 - Global component', () => {
}).catch(done);
});
+ it('Global component data should be parsed with HTML comment (Official Example)', (done) => {
+ parser.parse({
+ version: 3,
+ filename: path.resolve(__dirname, 'globalComment.markup-off.svelte'),
+ features: ['description', 'keywords'],
+ includeSourceLocations: true,
+ ignoredVisibilities: []
+ }).then((doc) => {
+ expect(doc, 'Document should be provided').to.exist;
+ expect(doc.description, 'Document description should be parsed').to.exist;
+ expect(doc.keywords, 'Document keywords should be parsed').to.exist;
+
+ expect(doc.description, 'Document description text').to.contain("Here's some documentation for this component.");
+ expect(doc.keywords, 'Document keywords length').to.have.length(1);
+ done();
+ }).catch(done);
+ });
+
it('Global component data should be parsed with JS comment', (done) => {
parser.parse({
version: 3,