Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Uncaught TypeError #10 #11

Merged
merged 17 commits into from
Oct 22, 2017
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
12 changes: 8 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@ const parseComment = (text, defaultVisibility) => {

index = matches.index

result.keywords.push({
name: matches[1],
description: matches[4]
const name = matches[1]
let description = matches[4] || ''

if (description) {
description = description
.replace(/\s*\*\s/g, '')
.replace(/\s+/g, ' ')
.replace(/\s*\*\//g, '')
.trim()
})
}

result.keywords.push({ name, description })
}

result.description = text.substring(0, indexDescription)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuedoc/parser",
"version": "0.6.0",
"version": "0.6.1",
"description": "Generate a JSON documentation for a Vue file",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 14 additions & 0 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@ describe('libutils', () => {
assert.equal(result.description, 'The generic component Sub description')
assert.equal(result.keywords.length, 11)
})

it('should success with malformated keyword syntax', () => {
const comment = `
/**
* The generic component
* Sub description
*
* @keyword*
*/`
const result = utils.parseComment(comment)

assert.equal(result.description, 'The generic component Sub description')
assert.equal(result.keywords.length, 1)
})
})

describe('getComment(property, defaultVisibility)', () => {
Expand Down