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
#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
---
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
+
defrun(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.
0 commit comments