Skip to content

Commit 01b6703

Browse files
authored
Merge pull request #5396 from c-herrewijn/fix-link-and-space-displaying
Fix link and space displaying
2 parents 297df84 + 712c220 commit 01b6703

File tree

3 files changed

+31
-40
lines changed

3 files changed

+31
-40
lines changed

docs/preview/sql/functions/blob.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This section describes functions and operators for examining and manipulating [`
1212

1313
| Name | Description |
1414
|:--|:-------|
15-
| [`arg1 || arg2`](#arg1--arg2) | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
15+
| [`arg1 || arg2`](#arg1--arg2) | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue-) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
1616
| [`base64(blob)`](#base64blob) | Converts a `blob` to a base64 encoded string. |
1717
| [`concat(value, ...)`](#concatvalue-) | Concatenates multiple strings, lists, or blobs. `NULL` inputs are skipped. See also [operator `||`](#arg1--arg2). |
1818
| [`decode(blob)`](#decodeblob) | Converts `blob` to `VARCHAR`. Fails if `blob` is not valid UTF-8. |
@@ -39,7 +39,7 @@ This section describes functions and operators for examining and manipulating [`
3939

4040
<div class="nostroke_table"></div>
4141

42-
| **Description** | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
42+
| **Description** | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue-) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
4343
| **Example 1** | `'Duck' || 'DB'` |
4444
| **Result** | `DuckDB` |
4545
| **Example 2** | `[1, 2, 3] || [4, 5, 6]` |

docs/preview/sql/functions/text.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This section describes functions and operators for examining and manipulating [`
2222
| [`string LIKE target`](#string-like-target) | Returns `true` if the `string` matches the like specifier (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})). |
2323
| [`string SIMILAR TO regex`](#string-similar-to-regex) | Returns `true` if the `string` matches the `regex` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})). |
2424
| [`string ^@ search_string`](#string--search_string) | Returns `true` if `string` begins with `search_string`. |
25-
| [`arg1 || arg2`](#arg1--arg2) | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
25+
| [`arg1 || arg2`](#arg1--arg2) | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue-) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
2626
| [`array_extract(string, index)`](#array_extractstring-index) | Extracts a single character from a `string` using a (1-based) `index`. |
2727
| [`array_slice(list, begin, end)`](#array_slicelist-begin-end) | Extracts a sublist or substring using [slice conventions]({% link docs/preview/sql/functions/list.md %}#slicing). Negative values are accepted. |
2828
| [`ascii(string)`](#asciistring) | Returns an integer that represents the Unicode code point of the first character of the `string`. |
@@ -38,7 +38,7 @@ This section describes functions and operators for examining and manipulating [`
3838
| [`contains(string, search_string)`](#containsstring-search_string) | Returns `true` if `search_string` is found within `string`. |
3939
| [`ends_with(string, search_string)`](#ends_withstring-search_string) | Returns `true` if `string` ends with `search_string`. |
4040
| [`format(format, ...)`](#formatformat-) | Formats a string using the [fmt syntax](#fmt-syntax). |
41-
| [`formatReadableDecimalSize(integer)`](#formatreadabledecimalsizeinteger) | Converts `integer` to a human-readable representation (e.g. 16000 -> 16.0 KB). |
41+
| [`formatReadableDecimalSize(integer)`](#formatreadabledecimalsizeinteger) | Converts `integer` to a human-readable representation using units based on powers of 10 (KB, MB, GB, etc.). |
4242
| [`formatReadableSize(integer)`](#formatreadablesizeinteger) | Converts `integer` to a human-readable representation using units based on powers of 2 (KiB, MiB, GiB, etc.). |
4343
| [`format_bytes(integer)`](#format_bytesinteger) | Converts `integer` to a human-readable representation using units based on powers of 2 (KiB, MiB, GiB, etc.). |
4444
| [`from_base64(string)`](#from_base64string) | Converts a base64 encoded `string` to a character string (`BLOB`). |
@@ -59,11 +59,11 @@ This section describes functions and operators for examining and manipulating [`
5959
| [`like_escape(string, like_specifier, escape_character)`](#like_escapestring-like_specifier-escape_character) | Returns `true` if the `string` matches the `like_specifier` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})) using case-sensitive matching. `escape_character` is used to search for wildcard characters in the `string`. |
6060
| [`lower(string)`](#lowerstring) | Converts `string` to lower case. |
6161
| [`lpad(string, count, character)`](#lpadstring-count-character) | Pads the `string` with the `character` on the left until it has `count` characters. Truncates the `string` on the right if it has more than `count` characters. |
62-
| [`ltrim(string[, characters])`](#ltrimstring-characters) | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
62+
| [`ltrim(string[, characters])`](#ltrimstring-characters) | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. |
6363
| [`md5(string)`](#md5string) | Returns the MD5 hash of the `string` as a `VARCHAR`. |
6464
| [`md5_number(string)`](#md5_numberstring) | Returns the MD5 hash of the `string` as a `HUGEINT`. |
65-
| [`md5_number_lower(string)`](#md5_number_lowerstring) | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
66-
| [`md5_number_upper(string)`](#md5_number_upperstring) | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
65+
| [`md5_number_lower(string)`](#md5_number_lowerstring) | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
66+
| [`md5_number_upper(string)`](#md5_number_upperstring) | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
6767
| [`nfc_normalize(string)`](#nfc_normalizestring) | Converts `string` to Unicode NFC normalized string. Useful for comparisons and ordering if text data is mixed between NFC normalized and not. |
6868
| [`not_ilike_escape(string, like_specifier, escape_character)`](#not_ilike_escapestring-like_specifier-escape_character) | Returns `false` if the `string` matches the `like_specifier` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})) using case-insensitive matching. `escape_character` is used to search for wildcard characters in the `string`. |
6969
| [`not_like_escape(string, like_specifier, escape_character)`](#not_like_escapestring-like_specifier-escape_character) | Returns `false` if the `string` matches the `like_specifier` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})) using case-sensitive matching. `escape_character` is used to search for wildcard characters in the `string`. |
@@ -91,7 +91,7 @@ This section describes functions and operators for examining and manipulating [`
9191
| [`right(string, count)`](#rightstring-count) | Extract the right-most `count` characters. |
9292
| [`right_grapheme(string, count)`](#right_graphemestring-count) | Extracts the right-most `count` grapheme clusters. |
9393
| [`rpad(string, count, character)`](#rpadstring-count-character) | Pads the `string` with the `character` on the right until it has `count` characters. Truncates the `string` on the right if it has more than `count` characters. |
94-
| [`rtrim(string[, characters])`](#rtrimstring-characters) | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
94+
| [`rtrim(string[, characters])`](#rtrimstring-characters) | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. |
9595
| [`sha1(value)`](#sha1value) | Returns a `VARCHAR` with the SHA-1 hash of the `value`. |
9696
| [`sha256(value)`](#sha256value) | Returns a `VARCHAR` with the SHA-256 hash of the `value` |
9797
| [`split(string, separator)`](#splitstring-separator) | Splits the `string` along the `separator`. |
@@ -109,12 +109,12 @@ This section describes functions and operators for examining and manipulating [`
109109
| [`substring(string, start[, length])`](#substringstring-start-length) | Extracts substring starting from character `start` up to the end of the string. If optional argument `length` is set, extracts a substring of `length` characters instead. Note that a `start` value of `1` refers to the first character of the `string`. |
110110
| [`substring_grapheme(string, start[, length])`](#substring_graphemestring-start-length) | Extracts substring starting from grapheme clusters `start` up to the end of the string. If optional argument `length` is set, extracts a substring of `length` grapheme clusters instead. Note that a `start` value of `1` refers to the `first` character of the `string`. |
111111
| [`suffix(string, search_string)`](#suffixstring-search_string) | Returns `true` if `string` ends with `search_string`. |
112-
| [`to_base(number, raxid[, min_length])`](#to_basenumber-raxid-min_length) | Converts `number` to a string in the given base `radix`, optionally padding with leading zeros to `min_length`. |
112+
| [`to_base(number, radix[, min_length])`](#to_basenumber-radix-min_length) | Converts `number` to a string in the given base `radix`, optionally padding with leading zeros to `min_length`. |
113113
| [`to_base64(blob)`](#to_base64blob) | Converts a `blob` to a base64 encoded string. |
114114
| [`to_binary(string)`](#to_binarystring) | Converts the `string` to binary representation. |
115115
| [`to_hex(string)`](#to_hexstring) | Converts the `string` to hexadecimal representation. |
116116
| [`translate(string, from, to)`](#translatestring-from-to) | Replaces each character in `string` that matches a character in the `from` set with the corresponding character in the `to` set. If `from` is longer than `to`, occurrences of the extra characters in `from` are deleted. |
117-
| [`trim(string[, characters])`](#trimstring-characters) | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
117+
| [`trim(string[, characters])`](#trimstring-characters) | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. |
118118
| [`ucase(string)`](#ucasestring) | Converts `string` to upper case. |
119119
| [`unbin(value)`](#unbinvalue) | Converts a `value` from binary representation to a blob. |
120120
| [`unhex(value)`](#unhexvalue) | Converts a `value` from hexadecimal representation to a blob. |
@@ -173,7 +173,7 @@ This section describes functions and operators for examining and manipulating [`
173173

174174
<div class="nostroke_table"></div>
175175

176-
| **Description** | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
176+
| **Description** | Concatenates two strings, lists, or blobs. Any `NULL` input results in `NULL`. See also [`concat(arg1, arg2, ...)`](#concatvalue-) and [`list_concat(list1, list2)`]({% link docs/preview/sql/functions/list.md %}#list_concatlist1-list2). |
177177
| **Example 1** | `'Duck' || 'DB'` |
178178
| **Result** | `DuckDB` |
179179
| **Example 2** | `[1, 2, 3] || [4, 5, 6]` |
@@ -216,7 +216,7 @@ This section describes functions and operators for examining and manipulating [`
216216

217217
| **Description** | Draws a band whose width is proportional to (`x - min`) and equal to `width` characters when `x` = `max`. `width` defaults to 80. |
218218
| **Example** | `bar(5, 0, 20, 10)` |
219-
| **Result** | `██▌␣␣␣␣␣␣␣` |
219+
| **Result** | `██▌ ` |
220220

221221
#### `base64(blob)`
222222

@@ -315,16 +315,16 @@ This section describes functions and operators for examining and manipulating [`
315315

316316
<div class="nostroke_table"></div>
317317

318-
| **Description** | Converts `integer` to a human-readable representation (e.g. 16000 -> 16.0 KB). |
319-
| **Example** | `formatReadableDecimalSize(1000 * 16)` |
318+
| **Description** | Converts `integer` to a human-readable representation using units based on powers of 10 (KB, MB, GB, etc.). |
319+
| **Example** | `formatReadableDecimalSize(16_000)` |
320320
| **Result** | `16.0 kB` |
321321

322322
#### `formatReadableSize(integer)`
323323

324324
<div class="nostroke_table"></div>
325325

326326
| **Description** | Converts `integer` to a human-readable representation using units based on powers of 2 (KiB, MiB, GiB, etc.). |
327-
| **Example** | `formatReadableSize(1000 * 16)` |
327+
| **Example** | `formatReadableSize(16_000)` |
328328
| **Result** | `15.6 KiB` |
329329
| **Alias** | `format_bytes` |
330330

@@ -333,7 +333,7 @@ This section describes functions and operators for examining and manipulating [`
333333
<div class="nostroke_table"></div>
334334

335335
| **Description** | Converts `integer` to a human-readable representation using units based on powers of 2 (KiB, MiB, GiB, etc.). |
336-
| **Example** | `format_bytes(1000 * 16)` |
336+
| **Example** | `format_bytes(16_000)` |
337337
| **Result** | `15.6 KiB` |
338338
| **Alias** | `formatReadableSize` |
339339

@@ -497,9 +497,9 @@ This section describes functions and operators for examining and manipulating [`
497497

498498
<div class="nostroke_table"></div>
499499

500-
| **Description** | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
501-
| **Example 1** | `ltrim('␣␣␣␣test␣␣')` |
502-
| **Result** | `test␣␣` |
500+
| **Description** | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. |
501+
| **Example 1** | `ltrim(' test ')` |
502+
| **Result** | `test ` |
503503
| **Example 2** | `ltrim('>>>>test<<', '><')` |
504504
| **Result** | `test<<` |
505505

@@ -523,15 +523,15 @@ This section describes functions and operators for examining and manipulating [`
523523

524524
<div class="nostroke_table"></div>
525525

526-
| **Description** | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
526+
| **Description** | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
527527
| **Example** | `md5_number_lower('abc')` |
528528
| **Result** | `8250560606382298838` |
529529

530530
#### `md5_number_upper(string)`
531531

532532
<div class="nostroke_table"></div>
533533

534-
| **Description** | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
534+
| **Description** | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
535535
| **Example** | `md5_number_upper('abc')` |
536536
| **Result** | `12704604231530709392` |
537537

@@ -758,9 +758,9 @@ This section describes functions and operators for examining and manipulating [`
758758

759759
<div class="nostroke_table"></div>
760760

761-
| **Description** | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
762-
| **Example 1** | `rtrim('␣␣␣␣test␣␣')` |
763-
| **Result** | `␣␣␣␣test` |
761+
| **Description** | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. |
762+
| **Example 1** | `rtrim(' test ')` |
763+
| **Result** | ` test` |
764764
| **Example 2** | `rtrim('>>>>test<<', '><')` |
765765
| **Result** | `>>>>test` |
766766

@@ -917,7 +917,9 @@ This section describes functions and operators for examining and manipulating [`
917917
| **Result** | `true` |
918918
| **Alias** | `ends_with` |
919919

920-
#### `to_base(number, raxid[, min_length])`
920+
#### `to_base(number, radix[, min_length])`
921+
922+
<div class="nostroke_table"></div>
921923

922924
| **Description** | Converts `number` to a string in the given base `radix`, optionally padding with leading zeros to `min_length`. |
923925
| **Example** | `to_base(42, 16, 5)` |
@@ -962,8 +964,8 @@ This section describes functions and operators for examining and manipulating [`
962964

963965
<div class="nostroke_table"></div>
964966

965-
| **Description** | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
966-
| **Example 1** | `trim('␣␣␣␣test␣␣')` |
967+
| **Description** | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. |
968+
| **Example 1** | `trim(' test ')` |
967969
| **Result** | `test` |
968970
| **Example 2** | `trim('>>>>test<<', '><')` |
969971
| **Result** | `test` |

scripts/generate_sql_function_docs.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class DocFunction:
133133

134134
PAGE_LINKS = {
135135
# intra-page links:
136-
'`concat(arg1, arg2, ...)`': "#concatvalue",
136+
'`concat(arg1, arg2, ...)`': "#concatvalue-",
137137
'operator `||`': "#arg1--arg2",
138138
'fmt syntax': "#fmt-syntax",
139139
'printf syntax': '#printf-syntax',
@@ -383,8 +383,7 @@ def generate_example_rows(func: DocFunction):
383383
try:
384384
if func.name in BINARY_OPERATORS:
385385
example = f"({example})"
386-
run_example = re.sub(r'␣', ' ', example)
387-
query_result = duckdb.sql(rf"select {run_example}::VARCHAR").fetchall()
386+
query_result = duckdb.sql(rf"select {example}::VARCHAR").fetchall()
388387
if len(query_result) != 1:
389388
example_result = 'Multiple rows: ' + ', '.join(
390389
(
@@ -398,16 +397,6 @@ def generate_example_rows(func: DocFunction):
398397
example_result = (
399398
f"{query_result[0][0]}" if query_result[0][0] else "NULL"
400399
)
401-
# replace leading and trailing spaces by '␣'
402-
nr_leading_spaces = 0
403-
nr_trailing_spaces = 0
404-
while example_result and example_result[0] == ' ':
405-
example_result = example_result[1:]
406-
nr_leading_spaces += 1
407-
while example_result and example_result[-1] == ' ':
408-
example_result = example_result[:-1]
409-
nr_trailing_spaces += 1
410-
example_result = f"{nr_leading_spaces * '␣'}{example_result}{nr_trailing_spaces * '␣'}"
411400
except duckdb.ParserException as e:
412401
print(
413402
f"Error for function '{func.name}', could not calculate example: '{example}'. Consider adding it via OVERRIDES'. {e}"

0 commit comments

Comments
 (0)