doc: Add initial documentation for N-API#12549
doc: Add initial documentation for N-API#12549mhdawson wants to merge 22 commits intonodejs:masterfrom
Conversation
doc/api/_toc.md
Outdated
There was a problem hiding this comment.
Should this be titled something like "C/C++ Addons (N-API)", so that it is adjacent to the other "C/C++ Addons" topic?
There was a problem hiding this comment.
makes sense to me, will update once we have more comments.
doc/api/addons.md
Outdated
cjihrig
left a comment
There was a problem hiding this comment.
Didn't make it through the entire PR, but it looks pretty good. Can you make an effort to remove language like "your". 👍
doc/api/addons.md
Outdated
There was a problem hiding this comment.
I would drop newer here. Otherwise, it will probably claim to be new for years to come.
doc/api/addons.md
Outdated
There was a problem hiding this comment.
I don't know if we standardized anywhere, but you have two spaces after some sentences, and one period after others.
There was a problem hiding this comment.
We should standardise, probably on 1.
doc/api/addons.md
Outdated
There was a problem hiding this comment.
Add a space after "document"
doc/api/addons.md
Outdated
There was a problem hiding this comment.
This sentence begins and ends with "instead." I think the second one can be dropped.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Same comments in these first two paragraphs apply.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Maybe start a new sentence at "and the"
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
This could probably be combined with the last sentence of the previous paragraph.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Does catch need to be in single quotes?
There was a problem hiding this comment.
does flow better without, removed.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Is this guaranteed to be an Error object, or can it be whatever was thrown by JS?
There was a problem hiding this comment.
That is a good point, it will be whatever was thrown.
doc/api/n-api.md
Outdated
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
the second -> in the section?
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
missing backticks above
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
missing backticks above
doc/api/n-api.md
Outdated
doc/api/n-api.md
Outdated
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
data' -> data`
It seems this is a bug in GitHub: this comment is for line 2873, but it is misplaced here due to possibly long diff (+ diff is truncated here). Beware other comments for the distant lines may be misplaced too.
|
Till #12554 fixed, maybe it is reasonable to split very big docs into several parts for review time. |
|
Did a pass
|
|
@cjihrig @vsemozhetbyt pushed commits to address all comments so far. |
|
I'm happy to split up into separate PRs or review in this single PR. I'll leave it up to the reviewers to comment on which they think in best. |
|
Added a |
|
Can we get rid of the Consider this comparison: napi_close_handle_scopeSignatureNODE_EXTERN napi_status napi_close_handle_scope(napi_env e,
napi_handle_scope scope);Parameters
Return value
DescriptionThis API closes the scope passed in. Scopes must be closed in the vs napi_close_handle_scopeNODE_EXTERN napi_status napi_close_handle_scope(napi_env e,
napi_handle_scope scope);
Returns This API closes the scope passed in. Scopes must be closed in the |
|
Also, can we add |
doc/api/n-api.md
Outdated
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
This paragraph seems to be talking about C++ wrappers around N-API, so I would strike faster here – they would be easier but they would inherently be limited to being as fast as N-API at best
There was a problem hiding this comment.
meant faster in terms of development not speed, but remove to avoid confusion
doc/api/n-api.md
Outdated
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Notes should be on separate paragraphs and not be all uppercase, followed by a capitalized sentence, i.e. *Note:* You should …
There was a problem hiding this comment.
Done, and fixed other instances as well.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
This is not the actual signature, though?
There was a problem hiding this comment.
No, to keep thing shorter and because we have the full signature/details in the later sections moved it from these earlier references.
There was a problem hiding this comment.
Maybe adding ... for the parameters would help ?
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
typo: Tthe and double space after it
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
If you’re talking about the data pointer possibly being moved: That does not happen. :)
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
typo: returns, also s/C++/C/ again
There was a problem hiding this comment.
fixed, and also went through and looked for other cases as well.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
s/C++/C/ (going to stop commenting that now 😄)
doc/api/n-api.md
Outdated
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
These should probably mention what happens when the value does not fit into the corresponding range?
doc/api/addons.md
Outdated
There was a problem hiding this comment.
Should include the Experimental stability index flag here.
There was a problem hiding this comment.
ok, we have that in the actual section on n-api but I can add here as well
There was a problem hiding this comment.
Having it in both places is good.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Please avoid the use of you in the docs... here and throughout.
There was a problem hiding this comment.
Did a pass removing all of the 'you's.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Here and throughout, can we make sure that the signature has the same names as the listed parameters?
e.g. e should be env to match.
There was a problem hiding this comment.
fixed all of the env instances.
|
@addaleax @jasnell @Fishrock123 pushed commits to address all of the comments so far. Note that the short links render ok when you do make doc and view as html as opposed to what you see when you look at the rendered markdown link you posted. |
|
This does not pass new doc linting: Lines like this also may need to be addressed for consistency: // var obj = {}Testing Linter CI: https://ci.nodejs.org/job/node-test-linter/8536/ Strange. Why Linting passes on CI? Testing if full CI also passes with linting: https://ci.nodejs.org/job/node-test-pull-request/7659/ (passes, 1 Windows fail seems unrelated). |
Fishrock123
left a comment
There was a problem hiding this comment.
Looking good! Couple more comments.
Also, according to the github diff renderer formatting breaks halfway through... It is possible that is just because the diff it too large but we should check for markdown errors in case.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Should this be an enum def?
There was a problem hiding this comment.
change to be enum definition
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Can we apply the same hear rules to e.g. here?
There was a problem hiding this comment.
Not sure what you mean here.
There was a problem hiding this comment.
If you meant removing the headers (Definition and Members) I went ahead and did that. Seems better to me.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
- `member`: Regular grammar rules.
Ditto for the parameters section of most APIs. I think this is the style we use elsewhere.
There was a problem hiding this comment.
Not sure what you mean here either.
There was a problem hiding this comment.
I think the point is:
error_code -> `error_code`
There was a problem hiding this comment.
Ok guessing that it meant the parameter sections use use regular grammar including capital at the start and period at the end. Went through and fixed all that up.
There was a problem hiding this comment.
Ok, fixed error_code -> error_code as well. It was pretty much ok except for the instance identified.
There was a problem hiding this comment.
Yeah, that's what I meant. Code blocks and grammar. Sorry.
doc/api/n-api.md
Outdated
There was a problem hiding this comment.
Can we use 1 space between [in/out] and name? Here and throughout. They don't render with more than 1 space it seems anyways?
(Unless make doc does, but I doubt it?)
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com>
|
@Fishrock123 github/large file may not be helping us here as I'm not 100% sure what's left with respect to https://github.com/nodejs/node/pull/12549/files#r112795649. I already added the stability index as James requested and I think that's the comment that that one shows me. |
|
@Fishrock123 I don't have any great ideas on the headings right now, so I'd prefer to land this and then I can spend a bit more time and maybe come up with something in a later PR. |
Fishrock123
left a comment
There was a problem hiding this comment.
@mhdawson Oh whoops, didn't see it on the line below. LGTM to me on doc style. (I didn't review the APIs in detail.)
|
@addaleax I think I've addressed your issues so I plan to land soon. If not just let me know. CI run: https://ci.nodejs.org/job/node-test-pull-request/7734/ |
|
@mhdawson Yeah, sorry, didn’t have the time to give it a full review. So please don’t let me hold up anything! :) |
|
@addaleax thanks. Of course if you spot anything later on just let me know and I'll cover it in a later PR. |
|
Ok CI good, landing. |
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com> PR-URL: #12549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
|
landed as deb9622 |
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com> PR-URL: #12549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com> PR-URL: #12549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com> PR-URL: #12549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
|
NM |
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com> PR-URL: nodejs#12549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add the initial documentation for the N-API This PR is a result of work in the abi-stable-node repo: https://github.com/nodejs/abi-stable-node/tree/doc, with this PR being the cumulative work on the documentation sections in that repo with the following contributors in alphabetical order: Author: Arunesh Chandra <arunesh.chandra@microsoft.com> Author: Gabriel Schulhof <gabriel.schulhof@intel.com> Author: Hitesh Kanwathirtha <hiteshk@microsoft.com> Author: Jason Ginchereau <jasongin@microsoft.com> Author: Michael Dawson <michael_dawson@ca.ibm.com> Author: Sampson Gao <sampsong@ca.ibm.com> Author: Taylor Woll <taylor.woll@microsoft.com> Backport-PR-URL: #19447 PR-URL: #12549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Add the initial documentation for the N-API
Rendered
This PR is a result of work in the abi-stable-node repo:
https://github.com/nodejs/abi-stable-node/tree/doc,
with this PR being the cumulative work on the documentation
sections in that repo with the following contributors
in alphabetical order:
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
doc, n-api