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

Allow @param and @return descriptions to be preceded by a newline. #227

Merged
merged 1 commit into from
Apr 22, 2014
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
4 changes: 2 additions & 2 deletions lib/docparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ YUI.add('docparser', function (Y) {
// extract the first word, this is the param name
match = REGEX_FIRSTWORD.exec(desc);
if (match) {
name = trim(match[1]);
name = trim(explodeString(match[1]));
desc = trim(match[2]);
}

Expand Down Expand Up @@ -383,7 +383,7 @@ YUI.add('docparser', function (Y) {
}

result = {
description: explodeString(desc)
description: Y.unindent(explodeString(desc))
};

if (type) {
Expand Down
29 changes: 24 additions & 5 deletions tests/input/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,33 @@
* @returns something without a type
*/

/**
Test newlines before descriptions.

@method testNewlineBeforeDescription

@param {String} foo
This parameter is foo.

@param {String} bar
This parameter is bar.

It does useful things.

@return {Boolean}
Sometimes true, sometimes false.

Nobody knows!
**/

/**
* Testing really long param description paring
* @method reallyLongParamDesc
* @param {Object} config Object with configuration property name/value pairs. The object can be
* @param {Object} config Object with configuration property name/value pairs. The object can be
* used to provide default values for the objects published attributes.
*
* <p>
* The config object can also contain the following non-attribute properties, providing a convenient
* The config object can also contain the following non-attribute properties, providing a convenient
* way to configure events listeners and plugins for the instance, as part of the constructor call:
* </p>
*
Expand Down Expand Up @@ -187,17 +206,17 @@ This method has attr {{#crossLink "OtherClass2/optionalAttr:attr"}}{{/crossLink}
*/

/**
Test `\{{foobar\}}` `\{{barfoo\}}`
Test `\{{foobar\}}` `\{{barfoo\}}`
@method hbHelper1
*/

/**
Test `\{{foobar2\}}` `\{{barfoo2\}}`
Test `\{{foobar2\}}` `\{{barfoo2\}}`
@method hbHelper2
*/

/**
Test `\{{foobar3\}}` `\{{barfoo3\}}`
Test `\{{foobar3\}}` `\{{barfoo3\}}`
@method hbHelper3
*/

27 changes: 27 additions & 0 deletions tests/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,33 @@ suite.add(new YUITest.TestCase({
Assert.isTrue(item2.params[0].multiple, 'Multiple not set');
Assert.isUndefined(item2["return"].type, 'Type should be missing');

item = this.findByName('testNewlineBeforeDescription', 'myclass');
Assert.isArray(item.params, 'Params should be an array.');
Assert.areSame(2, item.params.length, 'Should parse two params.');
Assert.areSame('foo', item.params[0].name, 'Param 0 should have the correct name.');
Assert.areSame('bar', item.params[1].name, 'Param 1 should have the correct name.');

Assert.areSame(
'This parameter is foo.',
item.params[0].description,
'Param 0 should have the correct description.'
);

Assert.areSame(
'This parameter is bar.\n\n It does useful things.',
item.params[1].description,
'Param 1 should have the correct description.'
);
},
'test: indented return description': function () {
var item = this.findByName('testNewlineBeforeDescription', 'myclass');

Assert.areSame('Boolean', item.return.type, 'Type should be correct.');
Assert.areSame(
'Sometimes true, sometimes false.\nNobody knows!',
item.return.description,
'Description indentation should be normalized to the first line.'
);
},
'test: object parameters': function () {
var item, props;
Expand Down