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: jsdoc promise returns #4539

Merged
merged 1 commit into from Aug 13, 2018
Merged

Conversation

spencern
Copy link
Contributor

Resolves: issue where master CI builds are failing due to docs existing with non-zero code
Impact: major
Type: docs

Issue

The issue is that in some places in our codebase, we had jsdoc that looked like this:

@returns {<Promise>Type} ...

The jsdoc parser cannot handle the { curly brace followed by < angle bracket and fails to process that line which causes a non-zero exit code. This results in the badge showing a failed CI on our master branch README which is highly undesirable and the reason for this ticket to be marked as impact major

Solution

The solution appears to be using the angle brackets around the type that the Promise resolves to.

@returns {Promise<Type>} Returns a promise that resolves to Type

This solution was arrived at by consulting the docs http://usejsdoc.org/tags-returns.html and this jsdoc issue comment jsdoc/jsdoc#1197 (comment)

According to this StackOverflow answer, we could potentially go further and define reject types like {Promise<Object|Error>}, but I can't find specific documentation supporting that behavior yet.
https://stackoverflow.com/questions/13104411/how-to-specify-resolution-and-rejection-type-of-the-promise-in-jsdoc

Testing

  1. Run our jsdoc command from the root of the project, verify that this PR resolves the error.
jsdoc . --verbose --configure .reaction/jsdoc/jsdoc.json --readme .reaction/jsdoc/templates/static/README.md

Resolves an issue in jsdocs for the addressBookContainer that was causing
our jsdoc generator to fail with a non-zero exit code.
When returning a Promise, we should document it with a
```
@returns {Promise<Type>} Description
```
Generally we've been doing this or just `@returns {Promise} description`
If the return block of the jsdoc has the following format it causes
errors.
```
@returns {<Promise>Type} Description
```
@spencern spencern added this to the Kit Carson milestone Aug 13, 2018
@spencern spencern changed the base branch from master to release-1.14.1 August 13, 2018 21:42
Copy link
Contributor

@machikoyasuda machikoyasuda left a comment

Choose a reason for hiding this comment

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

screen shot 2018-08-13 at 3 23 31 pm

JSDoc runs & outputs correctly ✔️

@spencern spencern merged commit cfd755a into release-1.14.1 Aug 13, 2018
@spencern spencern deleted the fix-spencer-jsdoc-promise-return branch August 13, 2018 22:56
@spencern spencern mentioned this pull request Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants