Skip to content

Commit fc11c94

Browse files
NickNasomhdawson
authored andcommitted
doc: major doc cleanup
* 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]>
1 parent 97c4ab5 commit fc11c94

33 files changed

+754
-763
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# **node-addon-api module**
1+
# **node-addon-api module**
22
This module contains **header-only C++ wrapper classes** which simplify
33
the use of the C based [N-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
44
provided by Node.js when using C++. It provides a C++ object model
55
and exception handling semantics with low overhead.
66

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

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

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

6464
### **API Documentation**
6565

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

6968
- [Basic Types](doc/basic_types.md)
7069
- [Array](doc/basic_types.md#array)

doc/array_buffer.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,129 @@
11
# ArrayBuffer
22

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

77
## Methods
88

99
### New
1010

11-
Allocates a new `ArrayBuffer` instance with a given length.
11+
Allocates a new `Napi::ArrayBuffer` instance with a given length.
1212

1313
```cpp
14-
static ArrayBuffer New(napi_env env, size_t byteLength);
14+
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, size_t byteLength);
1515
```
1616
17-
- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
17+
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
1818
- `[in] byteLength`: The length to be allocated, in bytes.
1919
20-
Returns a new `ArrayBuffer` instance.
20+
Returns a new `Napi::ArrayBuffer` instance.
2121
2222
### New
2323
24-
Wraps the provided external data into a new `ArrayBuffer` instance.
24+
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
2525
26-
The `ArrayBuffer` instance does not assume ownership for the data and expects it
27-
to be valid for the lifetime of the instance. Since the `ArrayBuffer` is subject
28-
to garbage collection this overload is only suitable for data which is static
29-
and never needs to be freed.
26+
The `Napi::ArrayBuffer` instance does not assume ownership for the data and
27+
expects it to be valid for the lifetime of the instance. Since the
28+
`Napi::ArrayBuffer` is subject to garbage collection this overload is only
29+
suitable for data which is static and never needs to be freed.
3030
3131
```cpp
32-
static ArrayBuffer New(napi_env env, void* externalData, size_t byteLength);
32+
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, void* externalData, size_t byteLength);
3333
```
3434

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

39-
Returns a new `ArrayBuffer` instance.
39+
Returns a new `Napi::ArrayBuffer` instance.
4040

4141
### New
4242

43-
Wraps the provided external data into a new `ArrayBuffer` instance.
43+
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
4444

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

5050
```cpp
5151
template <typename Finalizer>
52-
static ArrayBuffer New(napi_env env,
52+
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env,
5353
void* externalData,
5454
size_t byteLength,
5555
Finalizer finalizeCallback);
5656
```
5757
58-
- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
58+
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
5959
- `[in] externalData`: The pointer to the external data to wrap.
6060
- `[in] byteLength`: The length of the `externalData`, in bytes.
61-
- `[in] finalizeCallback`: A function to be called when the `ArrayBuffer` is
61+
- `[in] finalizeCallback`: A function to be called when the `Napi::ArrayBuffer` is
6262
destroyed. It must implement `operator()`, accept a `void*` (which is the
6363
`externalData` pointer), and return `void`.
6464
65-
Returns a new `ArrayBuffer` instance.
65+
Returns a new `Napi::ArrayBuffer` instance.
6666
6767
### New
6868
69-
Wraps the provided external data into a new `ArrayBuffer` instance.
69+
Wraps the provided external data into a new `Napi::ArrayBuffer` instance.
7070
71-
The `ArrayBuffer` instance does not assume ownership for the data and expects it
71+
The `Napi::ArrayBuffer` instance does not assume ownership for the data and expects it
7272
to be valid for the lifetime of the instance. The data can only be freed once
73-
the `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been
73+
the `finalizeCallback` is invoked to indicate that the `Napi::ArrayBuffer` has been
7474
released.
7575
7676
```cpp
7777
template <typename Finalizer, typename Hint>
78-
static ArrayBuffer New(napi_env env,
78+
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env,
7979
void* externalData,
8080
size_t byteLength,
8181
Finalizer finalizeCallback,
8282
Hint* finalizeHint);
8383
```
8484

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

94-
Returns a new `ArrayBuffer` instance.
94+
Returns a new `Napi::ArrayBuffer` instance.
9595

9696
### Constructor
9797

98-
Initializes an empty instance of the `ArrayBuffer` class.
98+
Initializes an empty instance of the `Napi::ArrayBuffer` class.
9999

100100
```cpp
101-
ArrayBuffer();
101+
Napi::ArrayBuffer::ArrayBuffer();
102102
```
103103

104104
### Constructor
105105

106-
Initializes a wrapper instance of an existing `ArrayBuffer` object.
106+
Initializes a wrapper instance of an existing `Napi::ArrayBuffer` object.
107107

108108
```cpp
109-
ArrayBuffer(napi_env env, napi_value value);
109+
Napi::ArrayBuffer::ArrayBuffer(napi_env env, napi_value value);
110110
```
111111
112-
- `[in] env`: The environment in which to create the `ArrayBuffer` instance.
113-
- `[in] value`: The `ArrayBuffer` reference to wrap.
112+
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance.
113+
- `[in] value`: The `Napi::ArrayBuffer` reference to wrap.
114114
115115
### ByteLength
116116
117117
```cpp
118-
size_t ByteLength() const;
118+
size_t Napi::ArrayBuffer::ByteLength() const;
119119
```
120120

121121
Returns the length of the wrapped data, in bytes.
122122

123123
### Data
124124

125125
```cpp
126-
T* Data() const;
126+
T* Napi::ArrayBuffer::Data() const;
127127
```
128128

129129
Returns a pointer the wrapped data.

doc/async_operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Node Addon API provides an interface to support functions that cover
1717
the most common asynchronous use cases. There is an abstract classes to implement
1818
asynchronous operations:
1919

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

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

0 commit comments

Comments
 (0)