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(annotation): fix default annotation in prop and param #571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion src/annotation/annotations/parameter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const typeRegEx = /^\s*(?:\{(.*)\})?\s*(?:\$?([^\s^\]\[]+))?\s*(?:\[([^\]]*)\])?\s*(?:-?\s*([\s\S]*))?/
const typeRegEx = /^\s*(?:\{(.*)\})?\s*(?:\$?([^\s^\]\[]+))?\s*(?:\[(.*)]\s)?\s*(?:-?\s*([\s\S]*))?/

export default function parameter (env) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/annotation/annotations/property.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const reqRegEx = /\s*(?:{(.*)})?\s*(?:(\$?\S+))?\s*(?:\[([^\]]*)])?\s*-?\s*([\S\s]*)\s*$/
const reqRegEx = /\s*(?:{(.*)})?\s*(?:(\$?\S+))?\s*(?:\[(.*)]\s)?\s*-?\s*([\S\s]*)\s*$/

export default function property () {
return {
Expand Down
1 change: 1 addition & 0 deletions test/annotations/parameter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('#parameter', function () {
it('should return an object', function () {
assert.deepEqual(param.parse('{type} $hyphenated-name [default] - description'), { type: 'type', name: 'hyphenated-name', default: 'default', description: 'description' })
assert.deepEqual(param.parse('{type} $name [default] - description [with brackets]'), { type: 'type', name: 'name', default: 'default', description: 'description [with brackets]' })
assert.deepEqual(param.parse('{type} $name ["[default]"] default with inside brackets, description [with brackets]'), { type: 'type', name: 'name', default: '"[default]"', description: 'default with inside brackets, description [with brackets]' })
assert.deepEqual(param.parse('{List} $list - list to check'), { type: 'List', name: 'list', description: 'list to check' })
})

Expand Down
7 changes: 7 additions & 0 deletions test/annotations/property.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ describe('#property', function () {
default: 'default',
description: 'description [with brackets]'
})

assert.deepEqual(prop.parse('{Function} base.default ["[default]"] default with inside brackets, description [with brackets]'), {
type: 'Function',
name: 'base.default',
default: '"[default]"',
description: 'default with inside brackets, description [with brackets]'
})
})

it('should work for multiline description', function () {
Expand Down