Skip to content

Commit 854288e

Browse files
committed
Merge branch 'main' into DOC-4928
2 parents 534bd5a + 91da5fc commit 854288e

File tree

495 files changed

+41316
-1258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

495 files changed

+41316
-1258
lines changed

.github/workflows/autocomment.yaml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
-H "X-GitHub-Api-Version: 2022-11-28" \
5050
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
5151
$FILES_URL \
52-
| jq -r --arg prefix $BRANCH_NAME/ '.[] | select(((.filename | test("content\/.+\\.md")) and .status != "removed")) | ($prefix + .filename)' \
52+
| jq -r --arg prefix $BRANCH_NAME/ '.[] | select(((.filename | test("content/(?!.*embed).*\\.md")) and .status != "removed")) | ($prefix + .filename)' \
5353
| sed -E -e 's|(^[^/]+/)([^/]+/)|\1|' -e 's|^|https://redis.io/docs/staging/|' -e 's|(_?index)?\.md||' \
5454
| sort \
5555
| uniq)
@@ -62,28 +62,51 @@ jobs:
6262
$FILES_URL \
6363
| jq -r '.[] | select(.filename | test("^static/images\/.+(.png|.svg|.gif|.)")) | .filename | sub("^static/";"")')
6464
65+
# Get all changed embeds files
66+
CHANGED_EMBED_FILES=$(curl -Ls \
67+
-H "Accept: application/vnd.github+json" \
68+
-H "X-GitHub-Api-Version: 2022-11-28" \
69+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
70+
$FILES_URL \
71+
| jq -r '.[] | select(.filename | test("^content/embeds\/.+.md")) | .filename | split("/")[-1]')
72+
6573
if [[ -n "$CHANGED_IMAGE_FILES" ]]
6674
then
6775
# For each image, work out in which README it is present
6876
MD_FILES_WITH_IMAGE=()
69-
for CHANGED_IMAGE_FILE in $CHANGED_IMAGE_FILES; do
77+
for CHANGED_IMAGE_FILE in "${CHANGED_IMAGE_FILES[@]}"; do
7078
MD_FILE_WITH_IMAGE=$(grep -ro "$CHANGED_IMAGE_FILE" content \
7179
| sed -E -e 's|:.+||' -e "s|^content/|https://redis.io/docs/staging/$BRANCH_NAME/|" -e 's|(_?index)?\.md||' \
80+
| grep -v "https://redis.io/docs/staging/$BRANCH_NAME/embeds/" \
7281
| sort \
7382
| uniq)
7483
MD_FILES_WITH_IMAGE+=($MD_FILE_WITH_IMAGE)
7584
done
7685
CHANGED_MD_FILES=$(printf "%s\n" "${CHANGED_MD_FILES}" "${MD_FILES_WITH_IMAGE[@]}" \
7786
| sort \
78-
| uniq \
79-
| xargs \
80-
| sed 's/ /<br>/g')
81-
else
82-
CHANGED_MD_FILES=$(printf "%s\n" "${CHANGED_MD_FILES}" \
83-
| xargs \
84-
| sed 's/ /<br>/g')
87+
| uniq)
8588
fi
8689
90+
if [[ -n "$CHANGED_EMBED_FILES" ]]
91+
then
92+
# For each embed, work out in which README it is present
93+
MD_FILES_WITH_EMBED=()
94+
for CHANGED_EMBED_FILE in "${CHANGED_EMBED_FILES[@]}"; do
95+
MD_FILE_WITH_EMBED=$(grep -ro "< embed-md \"${CHANGED_EMBED_FILE}\" >" content \
96+
| sed -E -e 's|:.+||' -e "s|^content/|https://redis.io/docs/staging/$BRANCH_NAME/|" -e 's|(_?index)?\.md||' \
97+
| sort \
98+
| uniq)
99+
MD_FILES_WITH_EMBED+=($MD_FILE_WITH_EMBED)
100+
done
101+
CHANGED_MD_FILES=$(printf "%s\n" "${CHANGED_MD_FILES}" "${MD_FILES_WITH_EMBED[@]}" \
102+
| sort \
103+
| uniq)
104+
fi
105+
106+
CHANGED_MD_FILES=$(printf "%s\n" "${CHANGED_MD_FILES}" \
107+
| xargs \
108+
| sed 's/ /<br>/g')
109+
87110
if [[ -z "$CHANGED_MD_FILES" ]]
88111
then
89112
if [[ -z "$EXISTING_COMMENT_ID" ]]

build/image_report.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Image report
2+
"""
3+
4+
from pylibs.hugotools import ShortcodeIterator
5+
6+
import argparse
7+
import os
8+
9+
10+
def scan_file(path: str) -> int:
11+
"""Scans a file for all `image` shortcodes.
12+
13+
Args:
14+
path (str): Path to file.
15+
16+
Returns:
17+
(int) Number of shortcodes found.
18+
"""
19+
20+
img_list = []
21+
22+
with open(path, encoding="utf_8") as md_file:
23+
text = md_file.read()
24+
25+
for img, pos_info in ShortcodeIterator(
26+
text, lambda t: t.tag == "image"
27+
):
28+
img_list.append((img, pos_info))
29+
30+
if len(img_list) > 0:
31+
print(f"File '{path}':")
32+
33+
for img in img_list:
34+
print(
35+
f" Line {img[1].line}: '{img[0].named_params['filename']}'"
36+
)
37+
38+
return len(img_list)
39+
40+
41+
parser = argparse.ArgumentParser(
42+
"Image report",
43+
"Scans a folder and report all Hugo image shortcodes found"
44+
)
45+
46+
parser.add_argument("pathname", help="Path of the folder to scan")
47+
48+
args = parser.parse_args()
49+
50+
print(f"Scanning '{args.pathname}'")
51+
52+
num_found = 0
53+
54+
for root, dirs, files in os.walk(args.pathname):
55+
for file in files:
56+
if file.endswith(".md"):
57+
fullpath = os.path.join(root, file)
58+
num_found += scan_file(fullpath)
59+
60+
if num_found == 0:
61+
print(f"No image shortcodes found in '{args.pathname}'")
62+
else:
63+
print(f"Found {num_found} image shortcodes.")

build/pylibs/hugotools.py

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
from enum import Enum
2+
from typing import Iterator, Match, Callable
3+
4+
import re
5+
6+
7+
class TextPosInfo:
8+
line: int
9+
start: int
10+
end: int
11+
12+
def __init__(self, line, start, end):
13+
self.line = line
14+
self.start = start
15+
self.end = end
16+
17+
18+
shortcode_re_pattern_start = r"(\n)|\{\{[<%]\s*"
19+
shortcode_re_body = r"(/)?([\w\-]+)\s*(.+?)?"
20+
shortcode_re_pattern_end = r"\s*[>%]\}\}"
21+
22+
shortcode_re_pattern = (
23+
shortcode_re_pattern_start +
24+
shortcode_re_body +
25+
shortcode_re_pattern_end
26+
)
27+
28+
29+
class ShortcodeTagType(Enum):
30+
"""Specifies open or close shortcode tag."""
31+
OPEN = 1
32+
CLOSE = 2
33+
34+
35+
class ShortcodeInfo:
36+
"""Represents the information in a shortcode.
37+
"""
38+
tag_type: ShortcodeTagType
39+
tag: str
40+
pos_params: list[str]
41+
named_params: dict[str, str]
42+
43+
def parse_params(self, param_str: str):
44+
param_re = "|".join([
45+
r'"(([^"]|(?<=\\)")*)"',
46+
r'((\w+)=([^"\s]+))',
47+
r'((\w+)="(([^"]|(?<=\\)")*)")',
48+
r'([^"=\s]+)'
49+
])
50+
51+
for match in re.finditer(param_re, param_str):
52+
if match is None:
53+
self.pos_params = []
54+
self.named_params = {}
55+
return
56+
57+
if match[1]:
58+
self.pos_params.append(re.sub(r'\\"', '"', match[1]))
59+
elif match[3]:
60+
self.named_params[match[4]] = match[5]
61+
elif match[6]:
62+
self.named_params[match[7]] = re.sub(r'\\"', '"', match[8])
63+
elif match[10]:
64+
self.pos_params.append(match[10])
65+
66+
def __init__(
67+
self, tag: str,
68+
tag_type: ShortcodeTagType,
69+
param_text: str = ""
70+
):
71+
self.tag = tag
72+
self.tag_type = tag_type
73+
self.pos_params = []
74+
self.named_params = {}
75+
self.parse_params(param_text or "")
76+
77+
def __str__(self) -> str:
78+
type_text: str
79+
80+
if self.tag_type == ShortcodeTagType.OPEN:
81+
type_text = "OPEN"
82+
else:
83+
type_text = "CLOSE"
84+
85+
result = f"{type_text} {self.tag}"
86+
87+
if self.pos_params or self.named_params:
88+
result += ":"
89+
90+
for pos_param in self.pos_params:
91+
result += f"\n '{pos_param}'"
92+
93+
for named_param, named_value in self.named_params.items():
94+
result += f"\n {named_param} = {named_value}"
95+
96+
return result
97+
98+
99+
class ShortcodeIterator:
100+
"""Iterates through all shortcodes in a string.
101+
"""
102+
re_iterator: Iterator[Match[str]]
103+
linenum: int
104+
sc_filter: Callable[[ShortcodeInfo], bool]
105+
106+
def __init__(
107+
self,
108+
text: str,
109+
sc_filter: Callable[[ShortcodeInfo], bool] = lambda x: True
110+
):
111+
self.re_iterator = re.finditer(shortcode_re_pattern, text)
112+
self.sc_filter = lambda self, x: sc_filter(x)
113+
self.linenum = 1
114+
115+
def __iter__(self):
116+
return self
117+
118+
def __next__(self) -> tuple[ShortcodeInfo, TextPosInfo]:
119+
next_match = self.re_iterator.__next__()
120+
121+
while True:
122+
if next_match[1]:
123+
self.linenum += 1
124+
elif next_match[2]:
125+
result = ShortcodeInfo(
126+
next_match[3], ShortcodeTagType.CLOSE
127+
)
128+
129+
if self.sc_filter(self, result):
130+
return (
131+
result,
132+
TextPosInfo(
133+
self.linenum,
134+
next_match.start(),
135+
next_match.end()
136+
)
137+
)
138+
else:
139+
result = ShortcodeInfo(
140+
next_match[3],
141+
ShortcodeTagType.OPEN,
142+
next_match[4]
143+
)
144+
145+
if self.sc_filter(self, result):
146+
return (
147+
result,
148+
TextPosInfo(
149+
self.linenum,
150+
next_match.start(),
151+
next_match.end()
152+
)
153+
)
154+
155+
next_match = self.re_iterator.__next__()

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ rdi_redis_gears_version = "1.2.6"
5555
rdi_debezium_server_version = "2.3.0.Final"
5656
rdi_db_types = "cassandra|mysql|oracle|postgresql|sqlserver"
5757
rdi_cli_latest = "latest"
58-
rdi_current_version = "v1.6.5"
58+
rdi_current_version = "v1.6.6"
5959

6060
[params.clientsConfig]
6161
"Python"={quickstartSlug="redis-py"}

content/commands/json.arrappend/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ is JSONPath to specify. Default is root `$`.
6767

6868
## Return value
6969

70-
`JSON.ARRAPEND` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of integer replies for each path, the array's new size, or `nil`, if the matching JSON value is not an array.
70+
`JSON.ARRAPPEND` returns an [array]({{< relref "develop/reference/protocol-spec#resp-arrays" >}}) of integer replies for each path, the array's new size, or `nil`, if the matching JSON value is not an array.
7171
For more information about replies, see [Redis serialization protocol specification]({{< relref "/develop/reference/protocol-spec" >}}).
7272

7373
## Examples
@@ -82,7 +82,7 @@ redis> JSON.SET item:1 $ '{"name":"Noise-cancelling Bluetooth headphones","descr
8282
OK
8383
{{< / highlight >}}
8484

85-
Add color `blue` to the end of the `colors` array. `JSON.ARRAPEND` returns the array's new size.
85+
Add color `blue` to the end of the `colors` array. `JSON.ARRAPPEND` returns the array's new size.
8686

8787
{{< highlight bash >}}
8888
redis> JSON.ARRAPPEND item:1 $.colors '"blue"'

content/commands/json.debug-memory/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Get the values' memory usage in bytes.
7272

7373
{{< highlight bash >}}
7474
redis> JSON.DEBUG MEMORY item:2
75-
(integer) 253
75+
(integer) 573
7676
{{< / highlight >}}
7777
</details>
7878

@@ -84,4 +84,3 @@ redis> JSON.DEBUG MEMORY item:2
8484

8585
* [RedisJSON]({{< relref "/develop/data-types/json/" >}})
8686
* [Index and search JSON documents]({{< relref "/develop/interact/search-and-query/indexing/" >}})
87-

0 commit comments

Comments
 (0)