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

Cleanup documentation #335

Closed
wants to merge 9 commits into from
Closed

Cleanup documentation #335

wants to merge 9 commits into from

Conversation

NickNaso
Copy link
Member

@NickNaso NickNaso commented Sep 11, 2018

Start cleaning up documentation like reported here : nodejs/abi-stable-node#280 (comment)
I need to do another pass to complete the work, but if anyone want start the review it could be great.

Remove comments about things under development
Include Napi namespace consistently
@NickNaso
Copy link
Member Author

Hi everyone I ended to clean up the documentation removing the unnecessary working progress comments and adding the Napi namespace. Please review this work so we can complete the steps to release the first complete version of documentation for node-addon-api.

Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

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

There are some more places where we should be namespacing. Maybe this needs a systematic search for "&$96;" with a handy "Napi::" in the clipboard. That way, only the class names need to be typed in by hand.

@@ -81,13 +81,13 @@ This method is used to execute some tasks out of the **event loop** on a libuv
worker thread. Subclasses must implement this method and the method is run on
a thread other than that running the main event loop. As the method is not
running on the main event loop, it must avoid calling any methods from node-addon-api
or running any code that might invoke JavaScript. Instead once this method is
or running any code that might invoke JavaScript. Instead once this method is
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: comma between "Instead" and "once"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

doc/async_worker.md Show resolved Hide resolved
@@ -140,16 +140,15 @@ operations ends. The given function is called from the main event loop thread.
identifier for the kind of resource that is being provided for diagnostic
information exposed by the async_hooks API.

Returns an AsyncWork instance which can later be queued for execution by calling
Returns a `Napi::AsyncWork` instance which can later be queued for execution by calling
`Queue`.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: `Queue` should be fully namespaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -160,31 +159,30 @@ information exposed by the async_hooks API.
- `[in] resource`: Object associated with the asynchronous operation that
will be passed to possible async_hooks.

Returns an AsyncWork instance which can later be queued for execution by calling
Returns a `Napi::AsyncWork` instance which can later be queued for execution by calling
`Queue`.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: `Queue` should be fully namespaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

```

- `[in] receiver`: The `this` object passed to the called function.
- `[in] callback`: The function which will be called when an asynchronous
operations ends. The given function is called from the main event loop thread.

Returns an AsyncWork instance which can later be queued for execution by calling
Returns a `Napi::AsyncWork` instance which can later be queued for execution by calling
`Queue`.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: `Queue` should be fully namespaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


```cpp
explicit AsyncWorker(const Object& receiver, const Function& callback,const char* resource_name);
explicit Napi::AsyncWorker(const Object& receiver, const Function& callback,const char* resource_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The types of the formal parameters should probably be fully namespaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -215,15 +212,15 @@ information exposed by the async_hooks API.
- `[in] resource`: Object associated with the asynchronous operation that
will be passed to possible async_hooks.

Returns an AsyncWork instance which can later be queued for execution by calling
Returns a `Napi::AsyncWork` instance which can later be queued for execution by calling
`Queue`.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: `Queue` should be fully namespaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


```cpp
explicit AsyncWorker(const Object& receiver, const Function& callback, const char* resource_name, const Object& resource);
explicit Napi::AsyncWorker(const Object& receiver, const Function& callback, const char* resource_name, const Object& resource);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The types of the formal arguments should probably be namespaced as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

The first step to use the `AsyncWorker` class is to create a new class that inherit
from it and implement the `Execute` abstract method. Typically input to your
The first step to use the `Napi::AsyncWorker` class is to create a new class that
inherits from it and implement the `Execute` abstract method. Typically input to your
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: full namespacing for `Execute`

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

The first step to use the `AsyncWorker` class is to create a new class that inherit
from it and implement the `Execute` abstract method. Typically input to your
The first step to use the `Napi::AsyncWorker` class is to create a new class that
inherits from it and implement the `Execute` abstract method. Typically input to your
worker will be saved within class' fields generally passed in through its
constructor.

When the `Execute` method completes without errors the `OnOK` function callback
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: full namespacing for `Execute` and `OnOK`. Same with instances below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

doc/string.md Outdated
String::New(napi_env env, const char* value);
String::New(napi_env env, const char16_t* value);
Napi::String::New(napi_env env, const std::Napi::string& value);
Napi::String::New(napi_env env, const std::u16Napi::string& value);
Copy link
Member

Choose a reason for hiding this comment

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

I think these 2 might not be right as I don't expect std::Napi

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok just fixed!

@NickNaso
Copy link
Member Author

NickNaso commented Sep 18, 2018

@mhdawson I'm working on Napi::AsyncWorker now to fix the problems reported by @gabrielschulhof.

@NickNaso
Copy link
Member Author

@mhdawson @gabrielschulhof Ended to fix reported problems

@mhdawson mhdawson mentioned this pull request Sep 18, 2018
6 tasks
Copy link

@thefourtheye thefourtheye left a comment

Choose a reason for hiding this comment

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

There were a few grammatical issues, which I ignored as I was not very sure.

`OnError` methods are complete the AsyncWorker instance is destructed.
Once created, execution is requested by calling `Napi::AsyncWorker::Queue`. When
a thread is available for execution the `Napi::AsyncWorker::Execute` method will
be invoked. Once `Napi::AsyncWorker::Execute` complets either

Choose a reason for hiding this comment

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

completes

an error message will cause the `OnError` method to be invoked instead of `OnOK`
once the `Execute` method completes.
an error message will cause the `Napi::AsyncWorker::OnError` method to be
invoked instead of `OnOK` once the `Napi::AsyncWorker::OnError::Execute` method

Choose a reason for hiding this comment

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

Napi::AsyncWorker::OnOK

Choose a reason for hiding this comment

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

Also Napi::AsyncWorker::Execute

on the `Execute` method is done the `OnOk` method is called and the results return
back to JavaScript invoking the stored callback with its associated environment.
callback that the `Napi::AsyncWorker` base class will store persistently. When
the work on the `Execute` method is done the `OnOk` method is called and the

Choose a reason for hiding this comment

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

Napi::AsyncWorker::OnOK

only create a new instance and pass to its constructor the callback you want to
execute when your asynchronous task ends and other data you need for your
computation. Once created the only other action you have to do is to call the
`Napi::AsyncWorker::Queue` method that will that will queue the created worker

Choose a reason for hiding this comment

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

redundant "that will"

your asynchronous task ends and other data you need for your computation. Once created the
only other action you have to do is to call the `Queue` method that will that will
queue the created worker for execution.
Using the implementation of a `Napi::AsyncWorker` is straight forward. You need

Choose a reason for hiding this comment

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

You only need to?

```

Returns the Napi:Env associated with the HandleScope.
Returns the `Napi:Env` associated with the `Napi::HandleScope`.

Choose a reason for hiding this comment

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

Napi::Env

doc/promises.md Outdated
# Promise

The Promise class, along with its Promise::Deferred class, implement the ability to create, resolve, and reject Promise objects.
The `Napi::Promise` class, along with its `Napi::Promise::Deferred` class, implement the ability to create, resolve, and reject `Promise` objects.

Choose a reason for hiding this comment

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

The last Promise need not be code-quoted, right?

@@ -1,6 +1,6 @@
# Property Descriptor

An [Object](object.md) can be assigned properites via its [DefineProperty](object.md#defineproperty) and [DefineProperties](object.md#defineproperties) function, which take PropertyDescrptor(s) as their parameters. The PropertyDescriptor can contain either values or functions, which are then assigned to the Object. Note that a single instance of a PropertyDescriptor class can only contain either one value, or at most two functions. PropertyDescriptors can only be created through the class methods [Accessor](#accessor), [Function](#function), or [Value](#value), each of which return a new static instance of a PropertyDescriptor.
A [`Napi::Object`](object.md) can be assigned properites via its [`DefineProperty`](object.md#defineproperty) and [`DefineProperties`](object.md#defineproperties) function, which take PropertyDescrptor(s) as their parameters. The `Napi::PropertyDescriptor` can contain either values or functions, which are then assigned to the `Napi::Object`. Note that a single instance of a `Napi::PropertyDescriptor` class can only contain either one value, or at most two functions. PropertyDescriptors can only be created through the class methods [`Accessor`](#accessor), [`Function`](#function), or [`Value`](#value), each of which return a new static instance of a `Napi::PropertyDescriptor`.

Choose a reason for hiding this comment

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

... (object.md#defineproperties) functions && which take PropertyDescriptor(s)

mhdawson pushed a commit that referenced this pull request Sep 21, 2018
* Cleaning the documentation.
* Remove comments about things under development.
* Include Napi namespace consistently.

PR-URL: #335
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
@mhdawson
Copy link
Member

Landed as fc11c94. Thanks for all of the hard work!

@mhdawson mhdawson closed this Sep 21, 2018
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
* Cleaning the documentation.
* Remove comments about things under development.
* Include Napi namespace consistently.

PR-URL: nodejs/node-addon-api#335
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
* Cleaning the documentation.
* Remove comments about things under development.
* Include Napi namespace consistently.

PR-URL: nodejs/node-addon-api#335
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
* Cleaning the documentation.
* Remove comments about things under development.
* Include Napi namespace consistently.

PR-URL: nodejs/node-addon-api#335
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
* Cleaning the documentation.
* Remove comments about things under development.
* Include Napi namespace consistently.

PR-URL: nodejs/node-addon-api#335
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
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.

4 participants