Skip to content

Commit

Permalink
docs: getValue() replaced with node (#16224)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssssota committed Apr 30, 2024
1 parent 9026b1c commit 923eec3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/plugins.md
Expand Up @@ -202,7 +202,7 @@ function print(

The `print` function is passed the following parameters:

- **`path`**: An object, which can be used to access nodes in the AST. It’s a stack-like data structure that maintains the current state of the recursion. It is called “path” because it represents the path to the current node from the root of the AST. The current node is returned by `path.getValue()`.
- **`path`**: An object, which can be used to access nodes in the AST. It’s a stack-like data structure that maintains the current state of the recursion. It is called “path” because it represents the path to the current node from the root of the AST. The current node is returned by `path.node`.
- **`options`**: A persistent object, which contains global options and which a plugin may mutate to store contextual data.
- **`print`**: A callback for printing sub-nodes. This function contains the core printing logic that consists of steps whose implementation is provided by plugins. In particular, it calls the printer’s `print` function and passes itself to it. Thus, the two `print` functions – the one from the core and the one from the plugin – call each other while descending down the AST recursively.

Expand All @@ -214,7 +214,7 @@ import { doc } from "prettier";
const { group, indent, join, line, softline } = doc.builders;

function print(path, options, print) {
const node = path.getValue();
const node = path.node;

switch (node.type) {
case "list":
Expand Down Expand Up @@ -281,7 +281,7 @@ For example, a plugin that has nodes with embedded JavaScript might have the fol

```js
function embed(path, options) {
const node = path.getValue();
const node = path.node;
if (node.type === "javascript") {
return async (textToDoc) => {
return [
Expand Down

0 comments on commit 923eec3

Please sign in to comment.