Skip to content

Commit

Permalink
doc: major doc cleanup
Browse files Browse the repository at this point in the history
* Cleaning the documentation.
* Remove comments about things under development.
* Include Napi namespace consistently.

PR-URL: #335
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
  • Loading branch information
NickNaso authored and mhdawson committed Sep 21, 2018
1 parent 97c4ab5 commit fc11c94
Show file tree
Hide file tree
Showing 33 changed files with 754 additions and 763 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# **node-addon-api module**
# **node-addon-api module**
This module contains **header-only C++ wrapper classes** which simplify
the use of the C based [N-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
provided by Node.js when using C++. It provides a C++ object model
and exception handling semantics with low overhead.

N-API is an ABI stable C interface provided by Node.js for building native
N-API is an ABI stable C interface provided by Node.js for building native
addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
and is maintained as part of Node.js itself. It is intended to insulate
native addons from changes in the underlying JavaScript engine and allow
modules compiled for one version to run on later versions of Node.js without
and is maintained as part of Node.js itself. It is intended to insulate
native addons from changes in the underlying JavaScript engine and allow
modules compiled for one version to run on later versions of Node.js without
recompilation.

The `node-addon-api` module, which is not part of Node.js, preserves the benefits
of the N-API as it consists only of inline code that depends only on the stable API
provided by N-API. As such, modules built against one version of Node.js
provided by N-API. As such, modules built against one version of Node.js
using node-addon-api should run without having to be rebuilt with newer versions
of Node.js.

Expand Down Expand Up @@ -63,8 +63,7 @@ to ideas specified in the **ECMA262 Language Specification**.

### **API Documentation**

The following is the documentation for node-addon-api (NOTE:
still a work in progress as its not yet complete).
The following is the documentation for node-addon-api.

- [Basic Types](doc/basic_types.md)
- [Array](doc/basic_types.md#array)
Expand Down
74 changes: 37 additions & 37 deletions doc/array_buffer.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,129 @@
# ArrayBuffer

The `ArrayBuffer` class corresponds to the
The `Napi::ArrayBuffer` class corresponds to the
[JavaScript `ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
class.

## Methods

### New

Allocates a new `ArrayBuffer` instance with a given length.
Allocates a new `Napi::ArrayBuffer` instance with a given length.

```cpp
static ArrayBuffer New(napi_env env, size_t byteLength);
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, size_t byteLength);
```
- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
- `[in] byteLength`: The length to be allocated, in bytes.
Returns a new `ArrayBuffer` instance.
Returns a new `Napi::ArrayBuffer` instance.
### New
Wraps the provided external data into a new `ArrayBuffer` instance.
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
The `ArrayBuffer` instance does not assume ownership for the data and expects it
to be valid for the lifetime of the instance. Since the `ArrayBuffer` is subject
to garbage collection this overload is only suitable for data which is static
and never needs to be freed.
The `Napi::ArrayBuffer` instance does not assume ownership for the data and
expects it to be valid for the lifetime of the instance. Since the
`Napi::ArrayBuffer` is subject to garbage collection this overload is only
suitable for data which is static and never needs to be freed.
```cpp
static ArrayBuffer New(napi_env env, void* externalData, size_t byteLength);
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, void* externalData, size_t byteLength);
```

- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
- `[in] externalData`: The pointer to the external data to wrap.
- `[in] byteLength`: The length of the `externalData`, in bytes.

Returns a new `ArrayBuffer` instance.
Returns a new `Napi::ArrayBuffer` instance.

### New

Wraps the provided external data into a new `ArrayBuffer` instance.
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.

The `ArrayBuffer` instance does not assume ownership for the data and expects it
to be valid for the lifetime of the instance. The data can only be freed once
the `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been
released.
The `Napi::ArrayBuffer` instance does not assume ownership for the data and
expects it to be valid for the lifetime of the instance. The data can only be
freed once the `finalizeCallback` is invoked to indicate that the
`Napi::ArrayBuffer` has been released.

```cpp
template <typename Finalizer>
static ArrayBuffer New(napi_env env,
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env,
void* externalData,
size_t byteLength,
Finalizer finalizeCallback);
```
- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
- `[in] externalData`: The pointer to the external data to wrap.
- `[in] byteLength`: The length of the `externalData`, in bytes.
- `[in] finalizeCallback`: A function to be called when the `ArrayBuffer` is
- `[in] finalizeCallback`: A function to be called when the `Napi::ArrayBuffer` is
destroyed. It must implement `operator()`, accept a `void*` (which is the
`externalData` pointer), and return `void`.
Returns a new `ArrayBuffer` instance.
Returns a new `Napi::ArrayBuffer` instance.
### New
Wraps the provided external data into a new `ArrayBuffer` instance.
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
The `ArrayBuffer` instance does not assume ownership for the data and expects it
The `Napi::ArrayBuffer` instance does not assume ownership for the data and expects it
to be valid for the lifetime of the instance. The data can only be freed once
the `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been
the `finalizeCallback` is invoked to indicate that the `Napi::ArrayBuffer` has been
released.
```cpp
template <typename Finalizer, typename Hint>
static ArrayBuffer New(napi_env env,
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env,
void* externalData,
size_t byteLength,
Finalizer finalizeCallback,
Hint* finalizeHint);
```

- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
- `[in] externalData`: The pointer to the external data to wrap.
- `[in] byteLength`: The length of the `externalData`, in bytes.
- `[in] finalizeCallback`: The function to be called when the `ArrayBuffer` is
- `[in] finalizeCallback`: The function to be called when the `Napi::ArrayBuffer` is
destroyed. It must implement `operator()`, accept a `void*` (which is the
`externalData` pointer) and `Hint*`, and return `void`.
- `[in] finalizeHint`: The hint to be passed as the second parameter of the
finalize callback.

Returns a new `ArrayBuffer` instance.
Returns a new `Napi::ArrayBuffer` instance.

### Constructor

Initializes an empty instance of the `ArrayBuffer` class.
Initializes an empty instance of the `Napi::ArrayBuffer` class.

```cpp
ArrayBuffer();
Napi::ArrayBuffer::ArrayBuffer();
```

### Constructor

Initializes a wrapper instance of an existing `ArrayBuffer` object.
Initializes a wrapper instance of an existing `Napi::ArrayBuffer` object.

```cpp
ArrayBuffer(napi_env env, napi_value value);
Napi::ArrayBuffer::ArrayBuffer(napi_env env, napi_value value);
```
- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
- `[in] value`: The `ArrayBuffer` reference to wrap.
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
- `[in] value`: The `Napi::ArrayBuffer` reference to wrap.
### ByteLength
```cpp
size_t ByteLength() const;
size_t Napi::ArrayBuffer::ByteLength() const;
```

Returns the length of the wrapped data, in bytes.

### Data

```cpp
T* Data() const;
T* Napi::ArrayBuffer::Data() const;
```

Returns a pointer the wrapped data.
2 changes: 1 addition & 1 deletion doc/async_operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Node Addon API provides an interface to support functions that cover
the most common asynchronous use cases. There is an abstract classes to implement
asynchronous operations:

- **[AsyncWorker](async_worker.md)**
- **[`Napi::AsyncWorker`](async_worker.md)**

These class helps manage asynchronous operations through an abstraction
of the concept of moving data between the **event loop** and **worker threads**.
Loading

0 comments on commit fc11c94

Please sign in to comment.