Skip to content

Commit

Permalink
docs(vrl): add casing functions (vectordotdev/vrl#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
leshow committed Aug 7, 2024
1 parent aab836b commit 87bddf8
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 0 deletions.
43 changes: 43 additions & 0 deletions website/cue/reference/remap/functions/camelcase.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package metadata

remap: functions: camelcase: {
category: "String"
description: """
Takes the `value` string, and turns it into camelCase. Optionally, you can
pass in the existing case of the function, or else we will try to figure out the case automatically.
"""

arguments: [
{
name: "value"
description: "The string to convert to camelCase."
required: true
type: ["string"]
},
{
name: "original_case"
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case"
required: false
type: ["string"]
},
]
internal_failure_reasons: []
return: types: ["string"]

examples: [
{
title: "camelCase a string"
source: #"""
camelcase("input-string")
"""#
return: "inputString"
},
{
title: "camelCase a string"
source: #"""
camelcase("input-string", "kebab-case")
"""#
return: "inputString"
},
]
}
43 changes: 43 additions & 0 deletions website/cue/reference/remap/functions/kebabcase.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package metadata

Check failure on line 1 in website/cue/reference/remap/functions/kebabcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`kebabcase` is not a recognized word. (check-file-path)

remap: functions: kebabcase: {

Check failure on line 3 in website/cue/reference/remap/functions/kebabcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`kebabcase` is not a recognized word. (unrecognized-spelling)
category: "String"
description: """
Takes the `value` string, and turns it into kebab-case. Optionally, you can
pass in the existing case of the function, or else we will try to figure out the case automatically.
"""

arguments: [
{
name: "value"
description: "The string to convert to kebab-case."
required: true
type: ["string"]
},
{
name: "original_case"
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case"
required: false
type: ["string"]
},
]
internal_failure_reasons: []
return: types: ["string"]

examples: [
{
title: "kebab-case a string"
source: #"""
kebabcase("InputString")

Check failure on line 31 in website/cue/reference/remap/functions/kebabcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`kebabcase` is not a recognized word. (unrecognized-spelling)
"""#
return: "input-string"
},
{
title: "kebab-case a string"
source: #"""
kebabcase("InputString", "PascalCase")

Check failure on line 38 in website/cue/reference/remap/functions/kebabcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`kebabcase` is not a recognized word. (unrecognized-spelling)
"""#
return: "input-string"
},
]
}
43 changes: 43 additions & 0 deletions website/cue/reference/remap/functions/pascalcase.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package metadata

remap: functions: pascalcase: {

Check failure on line 3 in website/cue/reference/remap/functions/pascalcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`pascalcase` is not a recognized word. (unrecognized-spelling)
category: "String"
description: """
Takes the `value` string, and turns it into PascalCase. Optionally, you can
pass in the existing case of the function, or else we will try to figure out the case automatically.
"""

arguments: [
{
name: "value"
description: "The string to convert to PascalCase."
required: true
type: ["string"]
},
{
name: "original_case"
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case"
required: false
type: ["string"]
},
]
internal_failure_reasons: []
return: types: ["string"]

examples: [
{
title: "PascalCase a string"
source: #"""
pascalcase("input-string")

Check failure on line 31 in website/cue/reference/remap/functions/pascalcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`pascalcase` is not a recognized word. (unrecognized-spelling)
"""#
return: "InputString"
},
{
title: "PascalCase a string"
source: #"""
pascalcase("input-string", "kebab-case")

Check failure on line 38 in website/cue/reference/remap/functions/pascalcase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`pascalcase` is not a recognized word. (unrecognized-spelling)
"""#
return: "InputString"
},
]
}
43 changes: 43 additions & 0 deletions website/cue/reference/remap/functions/screamingsnakecase.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package metadata

remap: functions: screamingsnakecase: {

Check failure on line 3 in website/cue/reference/remap/functions/screamingsnakecase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`screamingsnakecase` is not a recognized word. (unrecognized-spelling)
category: "String"
description: """
Takes the `value` string, and turns it into SCREAMING_SNAKE case. Optionally, you can
pass in the existing case of the function, or else we will try to figure out the case automatically.
"""

arguments: [
{
name: "value"
description: "The string to convert to SCREAMING_SNAKE case."
required: true
type: ["string"]
},
{
name: "original_case"
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case"
required: false
type: ["string"]
},
]
internal_failure_reasons: []
return: types: ["string"]

examples: [
{
title: "SCREAMING_SNAKE a string"
source: #"""
screamingsnakecase("input-string")

Check failure on line 31 in website/cue/reference/remap/functions/screamingsnakecase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`screamingsnakecase` is not a recognized word. (unrecognized-spelling)
"""#
return: "INPUT_STRING"
},
{
title: "SCREAMING_SNAKE a string"
source: #"""
screamingsnakecase("input-string", "kebab-case")

Check failure on line 38 in website/cue/reference/remap/functions/screamingsnakecase.cue

View workflow job for this annotation

GitHub Actions / Check Spelling

`screamingsnakecase` is not a recognized word. (unrecognized-spelling)
"""#
return: "INPUT_STRING"
},
]
}
43 changes: 43 additions & 0 deletions website/cue/reference/remap/functions/snakecase.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package metadata

remap: functions: snakecase: {
category: "String"
description: """
Takes the `value` string, and turns it into snake-case. Optionally, you can
pass in the existing case of the function, or else we will try to figure out the case automatically.
"""

arguments: [
{
name: "value"
description: "The string to convert to snake-case."
required: true
type: ["string"]
},
{
name: "original_case"
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case"
required: false
type: ["string"]
},
]
internal_failure_reasons: []
return: types: ["string"]

examples: [
{
title: "snake-case a string"
source: #"""
snakecase("input-string")
"""#
return: "input_string"
},
{
title: "snake-case a string"
source: #"""
snakecase("input-string", "kebab-case")
"""#
return: "input_string"
},
]
}

0 comments on commit 87bddf8

Please sign in to comment.