Skip to content

Commit

Permalink
doc: fix rendering of code blocks in list (#1401)
Browse files Browse the repository at this point in the history
Co-authored-by: Chengzhong Wu <[email protected]>
  • Loading branch information
tniessen and legendecas authored Nov 7, 2023
1 parent d605d62 commit 734e3f2
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ To use **Node-API** in a native module:

1. Add a dependency on this package to `package.json`:

```json
"dependencies": {
"node-addon-api": "*",
}
```
```json
"dependencies": {
"node-addon-api": "*",
}
```

2. Decide whether the package will enable C++ exceptions in the Node-API
wrapper, and reference this package as a dependency in `binding.gyp`.
Expand All @@ -32,51 +32,51 @@ To use **Node-API** in a native module:

To use without C++ exceptions, add the following to `binding.gyp`:

```gyp
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api",
],
```
```gyp
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api",
],
```

To enable that capability, add an alternative dependency in `binding.gyp`:

```gyp
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
```

If you decide to use node-addon-api without C++ exceptions enabled, please
consider enabling node-addon-api safe API type guards to ensure the proper
exception handling pattern:

```gyp
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_maybe",
],
```

4. If you would like your native addon to support OSX, please also add the
following settings in the `binding.gyp` file:

```gyp
'conditions': [
['OS=="mac"', {
'cflags+': ['-fvisibility=hidden'],
'xcode_settings': {
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
}
}]
]
```

5. Include `napi.h` in the native module code.
```gyp
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
```

If you decide to use node-addon-api without C++ exceptions enabled, please
consider enabling node-addon-api safe API type guards to ensure the proper
exception handling pattern:

```gyp
'dependencies': [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_maybe",
],
```

3. If you would like your native addon to support OSX, please also add the
following settings in the `binding.gyp` file:

```gyp
'conditions': [
['OS=="mac"', {
'cflags+': ['-fvisibility=hidden'],
'xcode_settings': {
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
}
}]
]
```

4. Include `napi.h` in the native module code.
To ensure only ABI-stable APIs are used, DO NOT include
`node.h`, `nan.h`, or `v8.h`.

```C++
#include "napi.h"
```
```C++
#include "napi.h"
```

At build time, the Node-API back-compat library code will be used only when the
targeted node version *does not* have Node-API built-in.
Expand Down

0 comments on commit 734e3f2

Please sign in to comment.