Skip to content

Commit 9b1e65c

Browse files
authored
Adds docs for @codegen.function decorator (#187)
#Motivation <!-- Why is this change necessary? --> To provide clear documentation on how to use the function decorator within the codegen SDK, including examples of deploying and running functions using the CLI. #Content <!-- Please include a summary of the change --> Added a new document function-decorator.mdx in the building-with-codegen directory. This document includes usage instructions, examples, and CLI commands for deploying and running functions. #Testing <!-- How was the change tested? --> Reviewed the documentation for accuracy and clarity. Verified that the links to related documents are correct. Please check the following before marking your PR as ready for review [x] I have added tests for my changes [x] I have updated the documentation or added new documentation as needed [x] I have read and agree to the Contributor License Agreement ---
1 parent c7aab2a commit 9b1e65c

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Function Decorator
3+
sidebarTitle: "@codegen.function"
4+
icon: "at"
5+
iconType: "solid"
6+
---
7+
8+
# Function Decorator
9+
10+
The `function` decorator is used to define codegen functions within your application. It allows you to specify a name for the function that will be ran making it easier to run specific codemods
11+
12+
## Usage
13+
14+
To use the `function` decorator, simply annotate your function with `@codegen.function` and provide a name as an argument.
15+
16+
### Example
17+
18+
```python
19+
@codegen.function('my-function')
20+
def run(codebase):
21+
pass
22+
```
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.
25+
26+
## Parameters
27+
28+
- `name` (str): The name of the function to be used when ran.
29+
30+
## Description
31+
32+
The `function` decorator is part of the codegen SDK CLI and is used to mark functions that are intended to be ran as part of a code generation process. It ensures that the function is properly registered and can be invoked with the specified name.
33+
34+
35+
## CLI Examples
36+
37+
### Running a Function
38+
39+
To run a deployed function using the CLI, use the following command:
40+
41+
```bash
42+
codegen run my-function
43+
```
44+
45+
This command runs the function named `my-function`.
46+
47+
## See Also
48+
49+
- [Webhook Decorator](./webhook-decorator.mdx): For handling webhook events with decorators.
50+
- [Codebase Visualization](./codebase-visualization.mdx): For visualizing codebases in your application.
51+
- [CLI Init Command](../cli/init.mdx): For initializing projects or environments related to the function decorator.
52+
- [CLI Create Command](../cli/create.mdx): For creating new functions or projects using the CLI.
53+
- [CLI Run Command](../cli/run.mdx): For running code or scripts using the CLI.

docs/mint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"building-with-codegen/parsing-codebases",
9898
"building-with-codegen/reusable-codemods",
9999
"building-with-codegen/dot-codegen",
100+
"building-with-codegen/function-decorator",
100101
"building-with-codegen/language-support",
101102
"building-with-codegen/commit-and-reset",
102103
"building-with-codegen/git-operations",

0 commit comments

Comments
 (0)