From 2a80f8b8634a78202c60783d5c2c293adcbce7c5 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 29 Apr 2018 01:26:30 +0300 Subject: [PATCH] doc: add missing backticks in n-api.md Codify types, variable names, and code fragments checking patterns I've managed to think of. Some nits were also fixed in passing (add missing periods, remove extra line breaks etc). --- doc/api/n-api.md | 415 +++++++++++++++++++++++------------------------ 1 file changed, 204 insertions(+), 211 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 26b5e87463948e..adb8647b399ecd 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -185,7 +185,6 @@ typedef void (*napi_finalize)(napi_env env, void* finalize_hint); ``` - #### napi_async_execute_callback Function pointer used with functions that support asynchronous operations. Callback functions must statisfy the following signature: @@ -223,7 +222,7 @@ In cases where a return value other than `napi_ok` or must be called to check if an exception is pending. See the section on exceptions for more details. -The full set of possible napi_status values is defined +The full set of possible `napi_status` values is defined in `napi_api_types.h`. The `napi_status` return value provides a VM-independent representation of @@ -282,7 +281,6 @@ logging purposes. This API can be called even if there is a pending JavaScript exception. - ### Exceptions Any N-API function call may result in a pending JavaScript exception. This is obviously the case for any function that may cause the execution of @@ -312,10 +310,10 @@ and then continue. This is only recommended in specific cases where it is known that the exception can be safely handled. In these cases [`napi_get_and_clear_last_exception`][] can be used to get and clear the exception. On success, result will contain the handle to -the last JavaScript Object thrown. If it is determined, after +the last JavaScript `Object` thrown. If it is determined, after retrieving the exception, the exception cannot be handled after all it can be re-thrown it with [`napi_throw`][] where error is the -JavaScript Error object to be thrown. +JavaScript `Error` object to be thrown. The following utility functions are also available in case native code needs to throw an exception or determine if a `napi_value` is an instance @@ -324,10 +322,10 @@ of a JavaScript `Error` object: [`napi_throw_error`][], [`napi_is_error`][]. The following utility functions are also available in case native -code needs to create an Error object: [`napi_create_error`][], -[`napi_create_type_error`][], and [`napi_create_range_error`][]. -where result is the napi_value that refers to the newly created -JavaScript Error object. +code needs to create an `Error` object: [`napi_create_error`][], +[`napi_create_type_error`][], and [`napi_create_range_error`][], +where result is the `napi_value` that refers to the newly created +JavaScript `Error` object. The Node.js project is adding error codes to all of the errors generated internally. The goal is for applications to use these @@ -346,9 +344,9 @@ the name associated with the error is also updated to be: originalName [code] ``` -where originalName is the original name associated with the error -and code is the code that was provided. For example if the code -is 'ERR_ERROR_1' and a TypeError is being created the name will be: +where `originalName` is the original name associated with the error +and `code` is the code that was provided. For example if the code +is `'ERR_ERROR_1'` and a `TypeError` is being created the name will be: ```text TypeError [ERR_ERROR_1] @@ -362,12 +360,11 @@ added: v8.0.0 NODE_EXTERN napi_status napi_throw(napi_env env, napi_value error); ``` - `[in] env`: The environment that the API is invoked under. -- `[in] error`: The `napi_value` for the Error to be thrown. +- `[in] error`: The `napi_value` for the `Error` to be thrown. Returns `napi_ok` if the API succeeded. -This API throws the JavaScript Error provided. - +This API throws the JavaScript `Error` provided. #### napi_throw_error