Skip to content

Feature/add promise doc - #2040

Merged
jannyHou merged 1 commit into
masterfrom
feature/add-promise-doc
Apr 4, 2016
Merged

jannyHou merged 1 commit into
masterfrom
feature/add-promise-doc

Conversation

@jannyHou

@jannyHou jannyHou commented Feb 4, 2016

Copy link
Copy Markdown
Contributor

Connect to #1998

@jannyHou jannyHou self-assigned this Feb 5, 2016
@jannyHou

jannyHou commented Feb 9, 2016

Copy link
Copy Markdown
Contributor Author

hey @bajtos take your time to review it :)
I add @promise doc for each function in #1998

Some questions:

  1. If a method only has error message in callback, sdocs --preview will give warning like

Resolve object not found in User.confirm()

But doc page looks fine:
Handler | Argument | Description
resolve | undefined | The resolve handler does not receive any arguments.

  1. promise annotation cannot read Array with datatype like Change [] from callback, so in PersistedModel.replicate
    I am thinking of overwriting the description derived from callback, eg:
@promise {Conflict[]} conflicts A list of changes that could not be replicated due to conflicts.
{Object] checkpoints The new checkpoints to use as the "since" argument for the next replication.

@jannyHou jannyHou assigned bajtos and unassigned jannyHou Feb 9, 2016
@bajtos

bajtos commented Feb 9, 2016

Copy link
Copy Markdown
Member
  1. If a method only has error message in callback, sdocs --preview will give warning like

Resolve object not found in User.confirm()

But doc page looks fine:
Handler | Argument | Description
resolve | undefined | The resolve handler does not receive any arguments.

@hacksparrow could you PTAL?

@bajtos

bajtos commented Feb 9, 2016

Copy link
Copy Markdown
Member
  1. promise annotation cannot read Array with datatype like Change [] from callback, so in PersistedModel.replicate
    I am thinking of overwriting the description derived from callback, eg:
@promise {Conflict[]} conflicts A list of changes that could not be replicated due to conflicts.
{Object] checkpoints The new checkpoints to use as the "since" argument for the next replication.

According to jsdoc, {Conflict[]} is a valid syntax.

OTOH, Google Closure Compiler uses {Array<Conflict>} to describe typed array.

@hacksparrow do you happen to know why "promise annotation cannot read Array with datatype like Change[] from callback"? Is this something that can be fixed in strong-docs?

* @param {Object} options Other options
* @param {Function} callback Callback function
* @callback {Function} callback Callback function
* @param {Error} err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hacksparrow Is it necessary to add @param {Error} err to callbacks that have at most one argument? I.e. cb(err) on error, cb() on success.

I would prefer if strong-docs was able to add this automatically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bajtos In my opinion, we should make it explicit. Reasons:

  1. Helps to give more details about the error, if required.
  2. When a human being looks at the source code, if the error param is missing, it will be interpreted as the callback returns nothing. Only sdocs will be able to add the missing info. We should avoid magic.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair enough.

@bajtos

bajtos commented Feb 9, 2016

Copy link
Copy Markdown
Member

@jannyHou the changes look good to me so far. Please let me know when this is no longer "work in progress".

@bajtos bajtos assigned jannyHou and unassigned bajtos Feb 9, 2016
@jannyHou

Copy link
Copy Markdown
Contributor Author

@bajtos Thanks for reviewing so quickly, and sorry I put work in progress when I created it but forgot to delete them :) it's done now excepts the problem I mentioned above.
I will wait for Yaapa's reply, I guess he's also quite busy these days.

@bajtos

bajtos commented Apr 4, 2016

Copy link
Copy Markdown
Member

@jannyHou LGTM. Please rebase on top of the current master and squash the commits before landing.

@jannyHou
jannyHou force-pushed the feature/add-promise-doc branch from 361da1f to e529dd2 Compare April 4, 2016 15:32
Add promise jsdoc in loopback
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.

3 participants