Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Allow multiple types to be specified in JSDoc tags #418

Merged
merged 3 commits into from
Aug 24, 2016
Merged

Allow multiple types to be specified in JSDoc tags #418

merged 3 commits into from
Aug 24, 2016

Conversation

Alhadis
Copy link
Contributor

@Alhadis Alhadis commented Aug 23, 2016

JSDoc allows more than one type to be specified in a @type tag or whatever:

Figure 1

This PR fixes that.

@winstliu
Copy link
Contributor

The documentation also says that the types have to be surrounded by parentheses:
{(number|boolean)}

@Alhadis
Copy link
Contributor Author

Alhadis commented Aug 23, 2016

I'll add support for the bracket-notation, but I should mention the notation doesn't appear to be mandatory. Running jsdoc on this produces the same output:

/**
 * Insert snarky name here.
 *
 * Add dry-witted description here.
 *
 * @param {Number|Function} callable - Something to return
 * @return {String|Object} Something
 */
function test(callable){
    return "ffs";
}

Result:

See?

Also, there's a lot of code in the wild that omits the brackets. E.g., this.

@Zirro
Copy link
Contributor

Zirro commented Aug 23, 2016

There was a brief discussion about this here: jsdoc/jsdoc#1104

The TL;DR-version is that both ways are accepted.

@Alhadis
Copy link
Contributor Author

Alhadis commented Aug 23, 2016

Okay, fixed.

@@ -1701,7 +1701,7 @@
'match': '''(?x)
(?:(?<=@returns)|(?<=@return))
\\s+
({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)})
({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about parentheses here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@winstliu winstliu merged commit e7b00e4 into atom:master Aug 24, 2016
@Alhadis Alhadis deleted the jsdoc-types branch August 25, 2016 03:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants