Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: getValue() replaced with node #16224

Merged
merged 1 commit into from Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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