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 a bug with "@" doesn't escapable in example #318

Merged
merged 1 commit into from
Feb 21, 2015
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
16 changes: 15 additions & 1 deletion lib/docparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ YUI.add('docparser', function (Y) {
"writeonce" // YUI attribute config
],

/**
* A list of ignored tags. These tags should be ignored because there is
* likely to be used for purposes other than JSDoc tags in JavaScript comments.
* @property IGNORE_TAGLIST
* @type Array
* @final
* @for DocParser
*/
IGNORE_TAGLIST = [
"media"
],

/**
* Common errors will get scrubbed instead of being ignored.
* @property CORRECTIONS
Expand Down Expand Up @@ -1128,6 +1140,7 @@ YUI.add('docparser', function (Y) {
var lines = comment.split(REGEX_LINES),
len = lines.length,
i,
regex,
parts, part, peek, skip,
tag, value,
results = [{
Expand All @@ -1150,7 +1163,8 @@ YUI.add('docparser', function (Y) {

// reconsitute and tokenize the comment block
comment = this.unindent(lines.join('\n'));
parts = comment.split(/(?:^|\n)\s*(@\w*)/);
regex = new RegExp('(?:^|\\n)\\s*((?!@' + IGNORE_TAGLIST.join(')(?!@') + ')@\\w*)');
parts = comment.split(regex);
len = parts.length;
for (i = 0; i < len; i++) {
value = '';
Expand Down
7 changes: 7 additions & 0 deletions tests/input/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ This is the description

**/

/**
@method foo2
@example
@media screen and (max-width: 767px) {
}
*/

/**
Other Class
@class OtherClass
Expand Down
4 changes: 4 additions & 0 deletions tests/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ suite.add(new YUITest.TestCase({
Assert.areSame(item.params[0].props[0].name, 'name');
Assert.isTrue(item.params[0].props[0].optional);

},
'test: markdown example': function () {
var item = this.findByName('foo2', 'myclass');
Assert.areSame(item.example[0], '\n @media screen and (max-width: 767px) {\n }');
}
}));

Expand Down