Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/MahdiBM/syntax-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jul 18, 2024
2 parents d86c4ad + ec51995 commit 7954863
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ It's rather simple.

## Examples

> [!NOTE]
> The below examples will get more complicated slowly but surely.
### Derive Case Names
```swift
@Enumerator("""
Expand Down Expand Up @@ -248,6 +251,9 @@ enum TestEnum {

### Create Functions For Each Case

<details>
<summary> Click to expand </summary>

```swift
@Enumerator("""
{{#cases}}
Expand Down Expand Up @@ -296,10 +302,14 @@ enum TestEnum {
}
```

</details>

### Using Comments For Code Generation

> [!TIP]
> You can use comments in front of each case, as values for `EnumeratorMacro` to process.
> Use `;` to divide the comments, and use `:` to separate the `key` and tthe possible `value`.
> Example: `myKey1; myKey2: value; myKey3`.
```swift
@Enumerator("""
Expand Down Expand Up @@ -333,7 +343,7 @@ public enum ErrorMessage {
case case3 // business_error: false
case case4 // business_error: adfasdfdsff
case somethingSomething(value: String)
case otherCase(error: Error, isViolation: Bool) // business_error
case otherCase(error: Error, isViolation: Bool) // business_error; l8n_params:

+ package var isBusinessError: Bool {
+ switch self {
Expand Down Expand Up @@ -455,7 +465,7 @@ Here's a sample context object:

Although not visible when writing templates, each underlying value that is passed to the template engine has an actual type.

In addition to [`swift-mustache`'s own "functions"/"transforms"](https://docs.hummingbird.codes/2.0/documentation/hummingbird/transforms/), `EnumeratorMacro` supports these transformations for each type:
`EnumeratorMacro` supports these transformations for each type:

* `String`:
* `capitalized() -> String`: Capitalizes the first letter.
Expand Down

0 comments on commit 7954863

Please sign in to comment.