Skip to content

Commit d410d35

Browse files
author
Mateusz Daniluk
committed
fix(annotation): fix default annotation in prop and param
now default can include brackets inside. For example CSS attribute selector [[attribute]] or string ["[attribute]"]
1 parent b3495a3 commit d410d35

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/annotation/annotations/parameter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const typeRegEx = /^\s*(?:\{(.*)\})?\s*(?:\$?([^\s^\]\[]+))?\s*(?:\[([^\]]*)\])?\s*(?:-?\s*([\s\S]*))?/
1+
const typeRegEx = /^\s*(?:\{(.*)\})?\s*(?:\$?([^\s^\]\[]+))?\s*(?:\[(.*)]\s)?\s*(?:-?\s*([\s\S]*))?/
22

33
export default function parameter (env) {
44
return {

src/annotation/annotations/property.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const reqRegEx = /\s*(?:{(.*)})?\s*(?:(\$?\S+))?\s*(?:\[([^\]]*)])?\s*-?\s*([\S\s]*)\s*$/
1+
const reqRegEx = /\s*(?:{(.*)})?\s*(?:(\$?\S+))?\s*(?:\[(.*)]\s)?\s*-?\s*([\S\s]*)\s*$/
22

33
export default function property () {
44
return {

test/annotations/parameter.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('#parameter', function () {
99
it('should return an object', function () {
1010
assert.deepEqual(param.parse('{type} $hyphenated-name [default] - description'), { type: 'type', name: 'hyphenated-name', default: 'default', description: 'description' })
1111
assert.deepEqual(param.parse('{type} $name [default] - description [with brackets]'), { type: 'type', name: 'name', default: 'default', description: 'description [with brackets]' })
12+
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]' })
1213
assert.deepEqual(param.parse('{List} $list - list to check'), { type: 'List', name: 'list', description: 'list to check' })
1314
})
1415

test/annotations/property.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ describe('#property', function () {
3636
default: 'default',
3737
description: 'description [with brackets]'
3838
})
39+
40+
assert.deepEqual(prop.parse('{Function} base.default ["[default]"] default with inside brackets, description [with brackets]'), {
41+
type: 'Function',
42+
name: 'base.default',
43+
default: '"[default]"',
44+
description: 'default with inside brackets, description [with brackets]'
45+
})
3946
})
4047

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

0 commit comments

Comments
 (0)