You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-with-graph-sitter/function-decorator.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Function Decorator
3
-
sidebarTitle: "@codegen.function"
3
+
sidebarTitle: "@graph_sitter.function"
4
4
icon: "at"
5
5
iconType: "solid"
6
6
---
@@ -11,17 +11,17 @@ The `function` decorator is used to define codegen functions within your applica
11
11
12
12
## Usage
13
13
14
-
To use the `function` decorator, simply annotate your function with `@codegen.function` and provide a name as an argument.
14
+
To use the `function` decorator, simply annotate your function with `@graph_sitter.function` and provide a name as an argument.
15
15
16
16
### Example
17
17
18
18
```python
19
-
@codegen.function('my-function')
19
+
@graph_sitter.function('my-function')
20
20
defrun(codebase):
21
21
pass
22
22
```
23
23
24
-
In this example, the function `run` is decorated with `@codegen.function` and given the name `'my-function'`. This name will be used when the function is ran.
24
+
In this example, the function `run` is decorated with `@graph_sitter.function` and given the name `'my-function'`. This name will be used when the function is ran.
Copy file name to clipboardExpand all lines: docs/building-with-graph-sitter/reusable-codemods.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ icon: "arrows-rotate"
5
5
iconType: "solid"
6
6
---
7
7
8
-
Graph-sitter enables you to create reusable code transformations using Python functions decorated with `@codegen.function`. These codemods can be shared, versioned, and run by your team.
8
+
Graph-sitter enables you to create reusable code transformations using Python functions decorated with `@graph_sitter.function`. These codemods can be shared, versioned, and run by your team.
9
9
10
10
## Creating Codemods
11
11
@@ -18,10 +18,10 @@ gs create rename-function .
18
18
This creates a new codemod in your `.codegen/codemods` directory:
19
19
20
20
```python
21
-
importcodegen
21
+
importgraph_sitter
22
22
from graph_sitter import Codebase
23
23
24
-
@codegen.function("rename-function")
24
+
@graph_sitter.function("rename-function")
25
25
defrun(codebase: Codebase):
26
26
"""Add a description of what this codemod does."""
27
27
# Add your code here
@@ -64,15 +64,15 @@ The execution flow:
64
64
65
65
A codemod consists of three main parts:
66
66
67
-
1. The `@codegen.function` decorator that names your codemod
67
+
1. The `@graph_sitter.function` decorator that names your codemod
68
68
2. A `run` function that takes a `Codebase` parameter
69
69
3. Your transformation logic using the Codebase API
70
70
71
71
```python
72
-
importcodegen
72
+
importgraph_sitter
73
73
from graph_sitter import Codebase
74
74
75
-
@codegen.function("update-imports")
75
+
@graph_sitter.function("update-imports")
76
76
defrun(codebase: Codebase):
77
77
"""Update import statements to use new package names."""
0 commit comments