From 7c9747351bdbcb511dc326e590fcc7bca9fb62bb Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 15:41:10 +0200 Subject: [PATCH] update docs --- docs/liquid-filters.md | 35 +++++++++++++++++++++++++++++++++++ template/liquid_docs.go | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index bfa194d..f3d154b 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -336,12 +336,19 @@ _Example_: `$ca := buildCustomCert "base64-encoded-ca-crt" "base64-encoded-ca-ke _Implementation_: `github.com/Masterminds/sprig/v3.buildCustomCertificate` ## `camelcase` +Converts a string from snake_case to camelCase. +_Parameters_: + +- String to convert +_Example_: `camelcase "http_server"` returns `HttpServer`. + + _Implementation_: `github.com/huandu/xstrings.ToPascalCase` @@ -1133,11 +1140,18 @@ _Implementation_: `path.IsAbs` _Implementation_: `github.com/Masterminds/sprig/v3.join` ## `kebabcase` +Converts a string from camelCase to kebab-case. + +_Parameters_: + +- String to convert +_Example_: `kebabcase "FirstName"` returns `first-name`. + _Implementation_: `github.com/huandu/xstrings.ToKebabCase` @@ -2208,10 +2222,17 @@ _Example_: `sha512sum "Hello world!"`. _Implementation_: `github.com/Masterminds/sprig/v3.sha512sum` ## `shuffle` +Shuffles a string. + + +_Parameters_: + +- String to shuffle +_Example_: `shuffle "hello"`. @@ -2228,10 +2249,17 @@ _Implementation_: `github.com/huandu/xstrings.Shuffle` _Implementation_: `github.com/Masterminds/sprig/v3.slice` ## `snakecase` +Converts a string from camelCase to snake_case. + + +_Parameters_: + +- String to convert +_Example_: `camelcase "FirstName"` returns `first_name`. @@ -2318,10 +2346,17 @@ _Implementation_: `github.com/Masterminds/sprig/v3.init.func23` _Implementation_: `github.com/Masterminds/sprig/v3.substring` ## `swapcase` +Swaps the case of a string using a word based algorithm. + + +_Parameters_: + +- String to convert +_Example_: `swapcase "This Is A.Test"` returns `tHIS iS a.tEST`. diff --git a/template/liquid_docs.go b/template/liquid_docs.go index e58c8c1..91d4b20 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -89,8 +89,12 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"Base64 encoded PEM format certificate", "Base64 encoded PEM format private key"}, Example: "`$ca := buildCustomCert \"base64-encoded-ca-crt\" \"base64-encoded-ca-key\"`", }, - "camelcase": {}, - "cat": {}, + "camelcase": { + Description: "Converts a string from snake_case to camelCase.", + Parameters: []string{"String to convert"}, + Example: "`camelcase \"http_server\"` returns `HttpServer`.", + }, + "cat": {}, "ceil": { Description: "Returns greatest float value greater than or equal to input value.", Parameters: []string{"Input value"}, @@ -269,8 +273,12 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Description: "Checks whether a path is absolute.", Parameters: []string{"File path"}, }, - "join": {}, - "kebabcase": {}, + "join": {}, + "kebabcase": { + Description: "Converts a string from camelCase to kebab-case.", + Parameters: []string{"String to convert"}, + Example: "`kebabcase \"FirstName\"` returns `first-name`.", + }, "keys": { Description: "Returns list of all keys from a map.", Parameters: []string{"Map"}, @@ -471,9 +479,17 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"Input value"}, Example: "`sha512sum \"Hello world!\"`.", }, - "shuffle": {}, - "slice": {}, - "snakecase": {}, + "shuffle": { + Description: "Shuffles a string.", + Parameters: []string{"String to shuffle"}, + Example: "`shuffle \"hello\"`.", + }, + "slice": {}, + "snakecase": { + Description: "Converts a string from camelCase to snake_case.", + Parameters: []string{"String to convert"}, + Example: "`camelcase \"FirstName\"` returns `first_name`.", + }, "sortAlpha": {}, "split": {}, "splitList": {}, @@ -482,7 +498,11 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "sub": {}, "subf": {}, "substr": {}, - "swapcase": {}, + "swapcase": { + Description: "Swaps the case of a string using a word based algorithm.", + Parameters: []string{"String to convert"}, + Example: "`swapcase \"This Is A.Test\"` returns `tHIS iS a.tEST`.", + }, "ternary": { Description: "Takes two values and a test value. If the test value is true, the first value will be returned. If the test value is false, the second value will be returned. This is similar to the C ternary operator.", Parameters: []string{"First value", "Second value", "Test value"},