doc: add links for repl.ReplServer
Add links to the class definition for repl.ReplServer in places where it would be helpful. PR-URL: https://github.com/nodejs/node/pull/23005 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
b92ce5165f
commit
363570c07d
@ -14,13 +14,13 @@ const repl = require('repl');
|
|||||||
|
|
||||||
## Design and Features
|
## Design and Features
|
||||||
|
|
||||||
The `repl` module exports the `repl.REPLServer` class. While running, instances
|
The `repl` module exports the [`repl.REPLServer`][] class. While running,
|
||||||
of `repl.REPLServer` will accept individual lines of user input, evaluate those
|
instances of [`repl.REPLServer`][] will accept individual lines of user input,
|
||||||
according to a user-defined evaluation function, then output the result. Input
|
evaluate those according to a user-defined evaluation function, then output the
|
||||||
and output may be from `stdin` and `stdout`, respectively, or may be connected
|
result. Input and output may be from `stdin` and `stdout`, respectively, or may
|
||||||
to any Node.js [stream][].
|
be connected to any Node.js [stream][].
|
||||||
|
|
||||||
Instances of `repl.REPLServer` support automatic completion of inputs,
|
Instances of [`repl.REPLServer`][] support automatic completion of inputs,
|
||||||
simplistic Emacs-style line editing, multi-line inputs, ANSI-styled output,
|
simplistic Emacs-style line editing, multi-line inputs, ANSI-styled output,
|
||||||
saving and restoring current REPL session state, error recovery, and
|
saving and restoring current REPL session state, error recovery, and
|
||||||
customizable evaluation functions.
|
customizable evaluation functions.
|
||||||
@ -69,10 +69,10 @@ The following key combinations in the REPL have these special effects:
|
|||||||
|
|
||||||
### Default Evaluation
|
### Default Evaluation
|
||||||
|
|
||||||
By default, all instances of `repl.REPLServer` use an evaluation function that
|
By default, all instances of [`repl.REPLServer`][] use an evaluation function
|
||||||
evaluates JavaScript expressions and provides access to Node.js' built-in
|
that evaluates JavaScript expressions and provides access to Node.js' built-in
|
||||||
modules. This default behavior can be overridden by passing in an alternative
|
modules. This default behavior can be overridden by passing in an alternative
|
||||||
evaluation function when the `repl.REPLServer` instance is created.
|
evaluation function when the [`repl.REPLServer`][] instance is created.
|
||||||
|
|
||||||
#### JavaScript Expressions
|
#### JavaScript Expressions
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ undefined
|
|||||||
|
|
||||||
### Custom Evaluation Functions
|
### Custom Evaluation Functions
|
||||||
|
|
||||||
When a new `repl.REPLServer` is created, a custom evaluation function may be
|
When a new [`repl.REPLServer`][] is created, a custom evaluation function may be
|
||||||
provided. This can be used, for instance, to implement fully customized REPL
|
provided. This can be used, for instance, to implement fully customized REPL
|
||||||
applications.
|
applications.
|
||||||
|
|
||||||
@ -261,13 +261,13 @@ function isRecoverableError(error) {
|
|||||||
|
|
||||||
### Customizing REPL Output
|
### Customizing REPL Output
|
||||||
|
|
||||||
By default, `repl.REPLServer` instances format output using the
|
By default, [`repl.REPLServer`][] instances format output using the
|
||||||
[`util.inspect()`][] method before writing the output to the provided `Writable`
|
[`util.inspect()`][] method before writing the output to the provided `Writable`
|
||||||
stream (`process.stdout` by default). The `useColors` boolean option can be
|
stream (`process.stdout` by default). The `useColors` boolean option can be
|
||||||
specified at construction to instruct the default writer to use ANSI style
|
specified at construction to instruct the default writer to use ANSI style
|
||||||
codes to colorize the output from the `util.inspect()` method.
|
codes to colorize the output from the `util.inspect()` method.
|
||||||
|
|
||||||
It is possible to fully customize the output of a `repl.REPLServer` instance
|
It is possible to fully customize the output of a [`repl.REPLServer`][] instance
|
||||||
by passing a new function in using the `writer` option on construction. The
|
by passing a new function in using the `writer` option on construction. The
|
||||||
following example, for instance, simply converts any input text to upper case:
|
following example, for instance, simply converts any input text to upper case:
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ changes:
|
|||||||
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
|
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
|
||||||
with a custom `eval` function. **Default:** `false`.
|
with a custom `eval` function. **Default:** `false`.
|
||||||
|
|
||||||
The `repl.start()` method creates and starts a `repl.REPLServer` instance.
|
The `repl.start()` method creates and starts a [`repl.REPLServer`][] instance.
|
||||||
|
|
||||||
If `options` is a string, then it specifies the input prompt:
|
If `options` is a string, then it specifies the input prompt:
|
||||||
|
|
||||||
@ -631,6 +631,7 @@ For an example of running a REPL instance over [curl(1)][], see:
|
|||||||
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
|
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
|
||||||
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
|
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
|
||||||
[`readline.Interface`]: readline.html#readline_class_interface
|
[`readline.Interface`]: readline.html#readline_class_interface
|
||||||
|
[`repl.ReplServer`]: #repl_class_replserver
|
||||||
[`util.inspect()`]: util.html#util_util_inspect_object_options
|
[`util.inspect()`]: util.html#util_util_inspect_object_options
|
||||||
[curl(1)]: https://curl.haxx.se/docs/manpage.html
|
[curl(1)]: https://curl.haxx.se/docs/manpage.html
|
||||||
[stream]: stream.html
|
[stream]: stream.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user