diff --git a/README.md b/README.md index a6a8604..53467c1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,26 @@ This is a component of the [Amplication](https://github.com/amplication/amplicat - Common interfaces and types across language implementations - Extensible architecture for adding new language support +## Scope and Purpose + +The AST libraries are not intended to cover all language functionality. Instead, they focus on the elements needed to create the foundation and boilerplate code with Amplication plugins. These libraries provide the essential building blocks for generating well-structured code across different languages. + +When more specialized or custom code is needed, the `CodeBlock` can be used as a generic node that can include any code as a string. This flexibility allows you to generate both structured AST-based code and custom code blocks when necessary. + +```typescript +import { CodeBlock } from '@amplication/java-ast'; // or '@amplication/csharp-ast' + +// Create a custom code block when needed +const customLogic = new CodeBlock(` + // Custom implementation that may not be supported by the AST library directly + if (condition) { + specialFunction(); + return customResult; + } +`); + +``` + ### Libraries #### ast-types diff --git a/libs/csharp-ast/README.md b/libs/csharp-ast/README.md index 2544cf8..b4506b3 100644 --- a/libs/csharp-ast/README.md +++ b/libs/csharp-ast/README.md @@ -1,5 +1,28 @@ # csharp-ast + +## Scope and Purpose + +The C# AST library is not intended to cover all C# language functionality. Instead, it focuses on the elements needed to create foundation and boilerplate code with Amplication plugins. The library provides building blocks for generating well-structured C# code for common patterns and use cases. + +When more specialized or custom code is needed, the `CodeBlock` class can be used as a generic node that can include any code as a string: + +```typescript +import { CodeBlock } from '@amplication/csharp-ast'; + +// Create a custom code block for specialized logic +const customLogic = new CodeBlock(` + // Custom C# implementation + using (var client = new HttpClient()) + { + var response = await client.GetAsync(endpoint); + return await response.Content.ReadAsStringAsync(); + } +`); + +// Add to your class or method +``` + This library was generated with [Nx](https://nx.dev). ## Building diff --git a/libs/java-ast/README.md b/libs/java-ast/README.md index 6b4ad26..7c24727 100644 --- a/libs/java-ast/README.md +++ b/libs/java-ast/README.md @@ -2,6 +2,32 @@ A library for generating Java code through an abstract syntax tree (AST) approach. This library allows you to programmatically generate Java code in a type-safe manner. + +## Scope and Purpose + +The Java AST library is not intended to cover all Java language functionality. Instead, it focuses on the elements needed to create foundation and boilerplate code with Amplication plugins. The library provides building blocks for generating well-structured Java code for common patterns and use cases. + +When more specialized or custom code is needed, the `CodeBlock` class can be used as a generic node that can include any code as a string: + +```typescript +import { CodeBlock } from '@amplication/java-ast'; + +// Create a custom code block for specialized logic +const customLogic = new CodeBlock(` + // Custom Java implementation + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + while ((line = reader.readLine()) != null) { + processLine(line); + } + } catch (IOException e) { + logger.error("Error reading file", e); + } +`); + +// Add to your class or method +``` + ## Installation ```sh diff --git a/typedoc.json b/typedoc.json index 1616af9..b04bf50 100644 --- a/typedoc.json +++ b/typedoc.json @@ -7,6 +7,11 @@ "cleanOutputDir": true, "disableGit": true, "includeVersion": true, + "navigationLinks": { + "GitHub": "https://github.com/amplication/ast-types", + "Amplication Docs": "https://docs.amplication.com/plugin-development/ast-libraries", + "Amplication": "https://amplication.com" + }, "exclude": [ "**/*.test.ts", "**/*.spec.ts",