-
Notifications
You must be signed in to change notification settings - Fork 464
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
Basic data types documentation for nodejs/abi-stable-node#280. #165
Conversation
Initial hack at documetation for Basic Types.
doc/N-API Basic Types.md
Outdated
Value is a the base class upon which other JavaScipt values like Number, Boolean, String, and Object are based. | ||
|
||
``` | ||
Value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each of the methods I would add a heading. In this example:
Default Constructor
and we might want to add the Added in:
which is used in the standard Node doc as well.
We may want to include the Returns line, if if it is just Returns void
(or whatever we think is the best way to say returns nothing)
See https://nodejs.org/dist/latest-v8.x/docs/api/n-api.html#n_api_napi_create_reference in the N-API doc as the example I looked at to come up with these suggestions.
doc/N-API Basic Types.md
Outdated
@@ -0,0 +1,373 @@ | |||
# N-API Documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general thought is that some intro at the top that introduces the basic types and how they are used might be useful before the section with the details. We can add that later though so what you have here would be good to land without that.
Overall a good start just a few suggestions. I also think we can incrementally land changes so if you like my suggestions we could integrate those (and any others made in the mean time), land what you have so far and then continue to add content in follow on PRs. |
doc/N-API Basic Types.md
Outdated
@@ -0,0 +1,373 @@ | |||
# N-API Documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to put a big "WORK IN PROGRESS, NOT YET COMPLETE" at the top just to set peoples expectations.
…o documentation-push
Includes Callback, Env, External, and Value.
I've split the earlier single large md file into four separate files that fit into the new documentation scaffolding structure. I've implemented Michael's suggestions with the exception of the |
doc/callbackinfo.md
Outdated
size_t Length() const; | ||
``` | ||
|
||
Returns the number of arguemnts passed in the Callabckinfo object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callbackinfo -> CallbackInfo (capital I)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed arguemnts -> arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arguemnts -> arguments
doc/callbackinfo.md
Outdated
Value NewTarget() const; | ||
``` | ||
|
||
Returns the `new.target` value of the constructor call. If the CallbackInfo is not a constructor call, a call to `IsEmpty()` on the returned value returns true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads a bit strangely (to my ears). Maybe:
If the function that was invoked (and for which the CallbackInfo was passed) is not a constructor call....
There is also similar wording in a few other places.
|
||
Returns the JavaScript `this` value for the call | ||
|
||
### Data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to provide a bit more details on what/how Data is used but that can be added in a follow on PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear how Data is used. I'm assuming that it's a place the C++ programmer can store general information with the C++ object, but I'm not sure. If so, I can add that to the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add the info as a follow on PR we just need to record somewhere that we should come back and do that. We should generate a test that uses it which would provide an example to base the doc on.
doc/env.md
Outdated
|
||
The opaque data structure containing the environment in which the request is being run. | ||
|
||
The Env object is usually created and passed by the calling system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to say
"is usually created and passed by the Node.js runtime or node-addon-api infrastructure"
The same comment also applies other places were we say "calling system"
doc/external.md
Outdated
```cpp | ||
template <typename T> | ||
static External New(napi_env env, | ||
T* data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters don't line up here.
doc/external.md
Outdated
```cpp | ||
template <typename T> | ||
static External New(napi_env env, | ||
T* data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters don't line up here
doc/external.md
Outdated
Returns a pointer to the arbitrary C++ data held by the External object. | ||
|
||
### Not documented here | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just because the doc will be added in future PR ? Or do you have some questions that need to be answered before you can add the doc for these ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the reviewers to know that they're not documented. I'm pretty sure there's no need to document them. If so, I'll remove the note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking best to remove. It confused me so it might confuse others as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty close, just a few comments/questions.
Michael, thank you for your comments. I've implemented your recommendations, have pushed updated files, and added a couple of comments above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more comments/typos
Thanks, Michael. I've made another push to my branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR-URL: #165 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Landed as 7ecab46 |
PR-URL: nodejs/node-addon-api#165 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: nodejs/node-addon-api#165 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: nodejs/node-addon-api#165 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: nodejs/node-addon-api#165 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This is my initial hack at documentation for Basic Types. I'm open to all suggestions and criticisms to improve this document. Please let me know how it can be improved with additional content or format changes.