From a123c7612d5bc7d40bd39efeca172589923d6416 Mon Sep 17 00:00:00 2001 From: KopekC Date: Wed, 29 Jan 2025 16:21:46 -0500 Subject: [PATCH 1/2] Adds docs for @codegen.function decorator --- .../function-decorator.mdx | 63 +++++++++++++++++++ docs/mint.json | 1 + 2 files changed, 64 insertions(+) create mode 100644 docs/building-with-codegen/function-decorator.mdx diff --git a/docs/building-with-codegen/function-decorator.mdx b/docs/building-with-codegen/function-decorator.mdx new file mode 100644 index 000000000..217f8bee0 --- /dev/null +++ b/docs/building-with-codegen/function-decorator.mdx @@ -0,0 +1,63 @@ +--- +title: Function Decorator +sidebarTitle: "@codegen.function" +icon: "at" +iconType: "solid" +--- + +# Function Decorator + +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 used when it is deployed. And ran in Codegen Cloud + +## Usage + +To use the `function` decorator, simply annotate your function with `@codegen.function` and provide a name as an argument. + +### Example + +```python +@codegen.function('my-function') +def run(codebase): + pass +``` + +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 deployed. + +## Parameters + +- `name` (str): The name of the function to be used when deployed. + +## Description + +The `function` decorator is part of the codegen SDK CLI and is used to mark functions that are intended to be deployed as part of a code generation process. It ensures that the function is properly registered and can be invoked with the specified name. + + +## CLI Examples + +### Deploying a Function + +To deploy a function using the CLI, use the following command: + +```bash +codegen deploy my-function +``` + +This command deploys the function named `my-function` to the Codegen Cloud. + +### Running a Function + +To run a deployed function using the CLI, use the following command: + +```bash +codegen run my-function +``` + +This command runs the function named `my-function` that has been deployed to the Codegen Cloud. + +## See Also + +- [Webhook Decorator](./webhook-decorator.mdx): For handling webhook events with decorators. +- [Codebase Visualization](./codebase-visualization.mdx): For visualizing codebases in your application. +- [CLI Init Command](../cli/init.mdx): For initializing projects or environments related to the function decorator. +- [CLI Create Command](../cli/create.mdx): For creating new functions or projects using the CLI. +- [CLI Run Command](../cli/run.mdx): For running code or scripts using the CLI. diff --git a/docs/mint.json b/docs/mint.json index 8bed0b914..bc66b0d48 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -97,6 +97,7 @@ "building-with-codegen/parsing-codebases", "building-with-codegen/reusable-codemods", "building-with-codegen/dot-codegen", + "building-with-codegen/function-decorator", "building-with-codegen/language-support", "building-with-codegen/commit-and-reset", "building-with-codegen/git-operations", From 86f0acf9312519c9c9b2fda30f9d43c0c87c10e6 Mon Sep 17 00:00:00 2001 From: KopekC Date: Wed, 29 Jan 2025 16:32:35 -0500 Subject: [PATCH 2/2] fixing docs mixup --- .../function-decorator.mdx | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/docs/building-with-codegen/function-decorator.mdx b/docs/building-with-codegen/function-decorator.mdx index 217f8bee0..ef38d958e 100644 --- a/docs/building-with-codegen/function-decorator.mdx +++ b/docs/building-with-codegen/function-decorator.mdx @@ -7,7 +7,7 @@ iconType: "solid" # Function Decorator -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 used when it is deployed. And ran in Codegen Cloud +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 ## Usage @@ -21,29 +21,19 @@ def run(codebase): pass ``` -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 deployed. +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. ## Parameters -- `name` (str): The name of the function to be used when deployed. +- `name` (str): The name of the function to be used when ran. ## Description -The `function` decorator is part of the codegen SDK CLI and is used to mark functions that are intended to be deployed as part of a code generation process. It ensures that the function is properly registered and can be invoked with the specified name. +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. ## CLI Examples -### Deploying a Function - -To deploy a function using the CLI, use the following command: - -```bash -codegen deploy my-function -``` - -This command deploys the function named `my-function` to the Codegen Cloud. - ### Running a Function To run a deployed function using the CLI, use the following command: @@ -52,7 +42,7 @@ To run a deployed function using the CLI, use the following command: codegen run my-function ``` -This command runs the function named `my-function` that has been deployed to the Codegen Cloud. +This command runs the function named `my-function`. ## See Also