Skip to content

Commit 847b451

Browse files
Trotttargos
authored andcommitted
doc: update markdown files in src for upcoming linting/formatting
PR-URL: #40159 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Harshitha K P <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent cea7395 commit 847b451

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/README.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ A number of concepts are involved in putting together Node.js on top of V8 and
6868
libuv. This section aims to explain some of them and how they work together.
6969

7070
<a id="isolate"></a>
71+
7172
### `Isolate`
7273

7374
The `v8::Isolate` class represents a single JavaScript engine instance, in
@@ -102,6 +103,7 @@ subclasses such as `v8::Number` (which in turn has subclasses like `v8::Int32`),
102103
of `v8::Object`, e.g. `v8::Uint8Array` or `v8::Date`.
103104

104105
<a id="internal-fields"></a>
106+
105107
### Internal fields
106108

107109
V8 provides the ability to store data in so-called “internal fields” inside
@@ -128,12 +130,14 @@ Typical ways of working with internal fields are:
128130
[`Context`][]s provide the same feature under the name “embedder data”.
129131

130132
<a id="js-handles"></a>
133+
131134
### JavaScript value handles
132135

133136
All JavaScript values are accessed through the V8 API through so-called handles,
134137
of which there are two types: [`Local`][]s and [`Global`][]s.
135138

136139
<a id="local-handles"></a>
140+
137141
#### `Local` handles
138142

139143
A `v8::Local` handle is a temporary pointer to a JavaScript object, where
@@ -210,6 +214,7 @@ any functions that are called from the event loop and want to run or access
210214
JavaScript code to create `HandleScope`s.
211215

212216
<a id="global-handles"></a>
217+
213218
#### `Global` handles
214219

215220
A `v8::Global` handle (sometimes also referred to by the name of its parent
@@ -246,6 +251,7 @@ the `v8::Eternal` itself is destroyed at some point. This type of handle
246251
is rarely used.
247252
248253
<a id="context"></a>
254+
249255
### `Context`
250256
251257
JavaScript allows multiple global objects and sets of built-in JavaScript
@@ -270,6 +276,7 @@ Typical ways of accessing the current `Context` in the Node.js code are:
270276
main context.
271277
272278
<a id="event-loop"></a>
279+
273280
### Event loop
274281
275282
The main abstraction for an event loop inside Node.js is the `uv_loop_t` struct.
@@ -284,6 +291,7 @@ could restructure Node.js to provide e.g. the ability to run parts of Node.js
284291
inside an event loop separate from the active thread’s event loop.
285292
286293
<a id="environment"></a>
294+
287295
### `Environment`
288296
289297
Node.js instances are represented by the `Environment` class.
@@ -315,6 +323,7 @@ Typical ways of accessing the current `Environment` in the Node.js code are:
315323
up the current [`Context`][] and then uses that.
316324
317325
<a id="isolate-data"></a>
326+
318327
### `IsolateData`
319328
320329
Every Node.js instance ([`Environment`][]) is associated with one `IsolateData`
@@ -346,6 +355,7 @@ The platform can be accessed through `isolate_data->platform()` given an
346355
and who passed this to Node.js.
347356
348357
<a id="binding-functions"></a>
358+
349359
### Binding functions
350360
351361
C++ functions exposed to JS follow a specific signature. The following example
@@ -463,6 +473,7 @@ Which explains that the unregistered external reference is
463473
`node::util::GetHiddenValue` defined in `node_util.cc`.
464474

465475
<a id="per-binding-state"></a>
476+
466477
#### Per-binding state
467478

468479
Some internal bindings, such as the HTTP parser, maintain internal state that
@@ -519,6 +530,7 @@ of `SnapshotableObject` on how to implement its serialization and
519530
deserialization.
520531
521532
<a id="exception-handling"></a>
533+
522534
### Exception handling
523535
524536
The V8 engine provides multiple features to work with JavaScript exceptions,
@@ -554,7 +566,7 @@ The most common reasons for this are:
554566
* Calls to functions like `object->Get(...)` or `object->Set(...)` may fail on
555567
most objects, if the `Object.prototype` object has been modified from userland
556568
code that added getters or setters.
557-
* Calls that invoke *any* JavaScript code, including JavaScript code that is
569+
* Calls that invoke _any_ JavaScript code, including JavaScript code that is
558570
provided from Node.js internals or V8 internals, will fail when JavaScript
559571
execution is being terminated. This typically happens inside Workers when
560572
`worker.terminate()` is called, but it can also affect the main thread when
@@ -661,6 +673,7 @@ and the exception object will not be a meaningful JavaScript value.
661673
`try_catch.ReThrow()` should not be used in this case.
662674

663675
<a id="libuv-handles-and-requests"></a>
676+
664677
### libuv handles and requests
665678

666679
Two central concepts when working with libuv are handles and requests.
@@ -682,6 +695,7 @@ When a Node.js [`Environment`][] is destroyed, it generally needs to clean up
682695
any resources owned by it, e.g. memory or libuv requests/handles.
683696

684697
<a id="cleanup-hooks"></a>
698+
685699
#### Cleanup hooks
686700

687701
Cleanup hooks are provided that run before the [`Environment`][]
@@ -690,7 +704,7 @@ is destroyed. They can be added and removed through by using
690704
`env->RemoveCleanupHook(callback, hint);`, where callback takes a `void* hint`
691705
argument.
692706

693-
Inside these cleanup hooks, new asynchronous operations *may* be started on the
707+
Inside these cleanup hooks, new asynchronous operations _may_ be started on the
694708
event loop, although ideally that is avoided as much as possible.
695709

696710
Every [`BaseObject`][] has its own cleanup hook that deletes it. For
@@ -742,6 +756,7 @@ This can be useful for debugging memory leaks.
742756
The [`memory_tracker.h`][] header file explains how to use this class.
743757

744758
<a id="baseobject"></a>
759+
745760
### `BaseObject`
746761

747762
A frequently recurring situation is that a JavaScript object and a C++ object
@@ -819,6 +834,7 @@ called. This can be useful when one `BaseObject` fully owns another
819834
`BaseObject`.
820835
821836
<a id="asyncwrap"></a>
837+
822838
### `AsyncWrap`
823839
824840
`AsyncWrap` is a subclass of `BaseObject` that additionally provides tracking
@@ -837,6 +853,7 @@ See the [`async_hooks` module][] documentation for more information about how
837853
this information is provided to async tracking tools.
838854
839855
<a id="makecallback"></a>
856+
840857
#### `MakeCallback`
841858
842859
The `AsyncWrap` class has a set of methods called `MakeCallback()`, with the
@@ -876,6 +893,7 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
876893
See [Callback scopes][] for more information.
877894

878895
<a id="handlewrap"></a>
896+
879897
### `HandleWrap`
880898

881899
`HandleWrap` is a subclass of `AsyncWrap` specifically designed to make working
@@ -890,6 +908,7 @@ current Node.js [`Environment`][] is destroyed, e.g. when a Worker thread stops.
890908
overview over libuv handles managed by Node.js.
891909

892910
<a id="reqwrap"></a>
911+
893912
### `ReqWrap`
894913

895914
`ReqWrap` is a subclass of `AsyncWrap` specifically designed to make working
@@ -902,6 +921,7 @@ track of the current count of active libuv requests.
902921
overview over libuv handles managed by Node.js.
903922

904923
<a id="callback-scopes"></a>
924+
905925
### Callback scopes
906926

907927
The public `CallbackScope` and the internally used `InternalCallbackScope`

src/crypto/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ throughout the rest of the code.
3131
The rest of the files are structured by their function, as detailed in the
3232
following table:
3333

34-
| File (*.h/*.cc) | Description |
34+
| File (\*.h/\*.cc) | Description |
3535
| -------------------- | ----------- |
3636
| `crypto_aes` | AES Cipher support. |
3737
| `crypto_cipher` | General Encryption/Decryption utilities. |
@@ -98,7 +98,7 @@ Examples of these being used are pervasive through the `src/crypto` code.
9898

9999
### `ByteSource`
100100

101-
The `ByteSource` class is a helper utility representing a *read-only* byte
101+
The `ByteSource` class is a helper utility representing a _read-only_ byte
102102
array. Instances can either wrap external ("foreign") data sources, such as
103103
an `ArrayBuffer` (`v8::BackingStore`) or allocated data. If allocated data
104104
is used, then the allocation is freed automatically when the `ByteSource` is
@@ -119,9 +119,9 @@ specific to `src/crypto`. It is used extensively within `src/crypto` to hold
119119
allocated data that is intended to be output in response to various
120120
crypto functions (generated hash values, or ciphertext, for instance).
121121

122-
*Currently, we are working to transition away from using `AllocatedBuffer`
122+
_Currently, we are working to transition away from using `AllocatedBuffer`
123123
to directly using the `v8::BackingStore` API. This will take some time.
124-
New uses of `AllocatedBuffer` should be avoided if possible.*
124+
New uses of `AllocatedBuffer` should be avoided if possible._
125125

126126
### Key objects
127127

0 commit comments

Comments
 (0)