Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit bcec278

Browse files
committed
finish stdlib documentation
1 parent bc2abc3 commit bcec278

15 files changed

Lines changed: 283 additions & 15 deletions

.golangci.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
# Copyright 2020 The Kubermatic Kubernetes Platform contributors.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
# SPDX-FileCopyrightText: 2023 Christoph Mewes
2+
# SPDX-License-Identifier: MIT
143

154
run:
165
modules-download-mode: readonly

.typos.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# configuration for https://github.com/crate-ci/typos
2+
3+
[default.extend-words]
4+
fo = "fo"

docs/coalescing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ Let's look closer at each type's conversion logic:
129129
* **string**: works as expected; floats have their trailing zeros trimmed (`3.12000` becomes
130130
`"3.12"`). `true` becomes `"true"` and `false` becomes `"false"`. `null` becomes an empty string.
131131
* **vector**: `null` turns into an empty vector and objects can only be converted to an empty vector
132-
if they are empty, otherwise an error is retuned.
132+
if they are empty, otherwise an error is returned.
133133
* **object**: `null` turns into an empty object and vectors can only be converted to an empty object
134-
if they are empty, otherwise an error is retuned.
134+
if they are empty, otherwise an error is returned.
135135

136136
## Conversion Functions
137137

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# has-prefix?
2+
3+
`has-prefix?` checks whether a given string begins with another string.
4+
5+
## Examples
6+
7+
* `(has-prefix? "hello" "hell")` -> `true`
8+
* `(has-prefix? "hallo" "halloween")` -> `false`
9+
* `(has-prefix? "foo" "bar")` -> `false`
10+
11+
## Forms
12+
13+
### `(has-prefix? base prefix)`
14+
15+
* `base` is an arbitrary expression.
16+
* `prefix` is an arbitrary expression.
17+
18+
`has-prefix?` evaluates the first argument and coalesces it into a string. If
19+
successful, it evalates the prefix the same way. If both values are strings,
20+
the function returns true if `base` begins with `prefix`.
21+
22+
## Context
23+
24+
`has-prefix?` executes all expressions in their own contexts, so nothing is
25+
shared.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# has-suffix?
2+
3+
`has-suffix?` checks whether a given string ends with another string.
4+
5+
## Examples
6+
7+
* `(has-suffix? "foobar" "bar")` -> `true`
8+
* `(has-suffix? "foobar" "f")` -> `false`
9+
10+
## Forms
11+
12+
### `(has-suffix? base suffix)`
13+
14+
* `base` is an arbitrary expression.
15+
* `suffix` is an arbitrary expression.
16+
17+
`has-suffix?` evaluates the first argument and coalesces it into a string. If
18+
successful, it evalates the suffix the same way. If both values are strings,
19+
the function returns true if `base` ends with `suffix`.
20+
21+
## Context
22+
23+
`has-suffix?` executes all expressions in their own contexts, so nothing is
24+
shared.

docs/functions/strings-to-lower.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# to-lower
2+
3+
`to-lower` removes a copy of a string with all uppercase characters replaced
4+
with their lowercase equivalent. This function uses Go's regular strings
5+
package and so this function should not be used where Unicode characters are
6+
involved, unexpected results might happen.
7+
8+
See also [`to-upper`](strings-to-upper.md).
9+
10+
## Examples
11+
12+
* `(to-lower "FOO")` -> `"foo"`
13+
14+
## Forms
15+
16+
### `(to-lower string)`
17+
18+
* `string` is an arbitrary expression.
19+
20+
`to-lower` evaluates the first argument and coalesces the result into a string.
21+
When successful, the lowercased version of the string is returned.

docs/functions/strings-to-upper.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# to-upper
2+
3+
`to-upper` removes a copy of a string with all lowercase characters replaced
4+
with their uppercase equivalent. This function uses Go's regular strings
5+
package and so this function should not be used where Unicode characters are
6+
involved, unexpected results might happen.
7+
8+
See also [`to-lower`](strings-to-lower.md).
9+
10+
## Examples
11+
12+
* `(to-upper "foo")` -> `"FOO"`
13+
14+
## Forms
15+
16+
### `(to-upper string)`
17+
18+
* `string` is an arbitrary expression.
19+
20+
`to-upper` evaluates the first argument and coalesces the result into a string.
21+
When successful, the uppercased version of the string is returned.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# trim-prefix?
2+
3+
`trim-prefix?` checks whether a given string begins with another string and if
4+
it does, returns a copy of the string with the prefix removed. Note that this
5+
removal is done once, so removing the prefix `"o"` from `"oof"` will yield
6+
`"of"`.
7+
8+
## Examples
9+
10+
* `(trim-prefix? "11234" "1")` -> `"1234"`
11+
* `(trim-prefix? "11234" "x")` -> `"11234"`
12+
13+
## Forms
14+
15+
### `(trim-prefix? base prefix)`
16+
17+
* `base` is an arbitrary expression.
18+
* `prefix` is an arbitrary expression.
19+
20+
`trim-prefix?` evaluates the first argument and coalesces it into a string. If
21+
successful, it evalates the prefix the same way. If both values are strings,
22+
the function checks if the base string has the prefix, and if so removes it once
23+
and returns the resulting string.
24+
25+
## Context
26+
27+
`trim-prefix?` executes all expressions in their own contexts, so nothing is
28+
shared.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# trim-suffix?
2+
3+
`trim-suffix?` checks whether a given string ends with another string and if
4+
it does, returns a copy of the string with the suffix removed. Note that this
5+
removal is done once, so removing the suffix `"o"` from `"foo"` will yield
6+
`"fo"`.
7+
8+
## Examples
9+
10+
* `(trim-suffix? "12344" "4")` -> `"1234"`
11+
* `(trim-suffix? "12344" "x")` -> `"12344"`
12+
13+
## Forms
14+
15+
### `(trim-suffix? base suffix)`
16+
17+
* `base` is an arbitrary expression.
18+
* `suffix` is an arbitrary expression.
19+
20+
`trim-suffix?` evaluates the first argument and coalesces it into a string. If
21+
successful, it evalates the suffix the same way. If both values are strings,
22+
the function checks if the base string has the suffix, and if so removes it once
23+
and returns the resulting string.
24+
25+
## Context
26+
27+
`trim-suffix?` executes all expressions in their own contexts, so nothing is
28+
shared.

docs/functions/strings-trim.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# trim
2+
3+
`trim` removes all whitepace from the beginning and end of a string. This
4+
includes linebreaks.
5+
6+
## Examples
7+
8+
* `(trim " hello\nworld ")` -> `"hello\nworld"`
9+
* `(trim "\n")` -> `""`
10+
11+
## Forms
12+
13+
### `(trim string)`
14+
15+
* `string` is an arbitrary expression.
16+
17+
`trim` evaluates the first argument and coalesces the result into a string. When
18+
successful, leading and trailing whitespace is removed from the string and then
19+
the resulting string is returned.

0 commit comments

Comments
 (0)