From 45b51632d5d1d79379100c742df36f82c6a35a1a Mon Sep 17 00:00:00 2001 From: Mahdi Bahrami Date: Thu, 18 Jul 2024 17:30:37 +0330 Subject: [PATCH 1/2] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 5a1295c..4869c0f 100644 --- a/README.md +++ b/README.md @@ -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(""" @@ -248,6 +251,9 @@ enum TestEnum { ### Create Functions For Each Case +
+ Click to expand + ```swift @Enumerator(""" {{#cases}} @@ -296,6 +302,8 @@ enum TestEnum { } ``` +
+ ### Using Comments For Code Generation > [!TIP] From ec5199599ce9d021f387c92a7ca0621c9c3b9e17 Mon Sep 17 00:00:00 2001 From: Mahdi Bahrami Date: Thu, 18 Jul 2024 18:33:36 +0330 Subject: [PATCH 2/2] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4869c0f..bdf385c 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,8 @@ enum TestEnum { > [!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(""" @@ -341,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 { @@ -463,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.