Skip to content

Commit f8cd2ec

Browse files
committed
Adding functionality for the bloom module to have its commands displayed on the valkey website
Signed-off-by: zackcam <[email protected]>
1 parent 457dbc5 commit f8cd2ec

File tree

7 files changed

+57
-26
lines changed

7 files changed

+57
-26
lines changed

.github/workflows/zola-deploy.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ jobs:
3232
with:
3333
repository: valkey-io/valkey
3434
path: valkey
35-
35+
36+
- name: Checkout valkey-bloom
37+
uses: actions/checkout@v4
38+
with:
39+
repository: valkey-io/valkey-bloom
40+
path: valkey-bloom
41+
3642
- name: Init commands and topics
3743
run: |
3844
cd website
3945
./build/init-topics.sh ../valkey-doc/topics
40-
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands
46+
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands
4147
- name: Build only
4248
uses: shalzz/[email protected]
4349
env:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Valkey.io website
22

33
This repo contains the source for the valkey.io website (build scripts, template, blog posts, stylesheets, etc.).
4-
The build integrates content from [`valkey-io/valkey-doc`](https://github.com/valkey-io/valkey-doc) and the commands definitions from [`valkey-io/valkey`](https://github.com/valkey-io/valkey) (see [Build Locally](#build-locally) below for more details).
4+
The build integrates content from [`valkey-io/valkey-doc`](https://github.com/valkey-io/valkey-doc) and the commands definitions from [`valkey-io/valkey`](https://github.com/valkey-io/valkey) and [`valkey-io/valkey-bloom`](https://github.com/valkey-io/valkey-bloom) (see [Build Locally](#build-locally) below for more details).
55

66
## Contributing
77

@@ -62,8 +62,8 @@ Commit your changes to your local copy of `valkey-io/valkey-doc`.
6262

6363
### Building the command reference
6464

65-
The command reference (i.e. `/commands/set/`, `/commands/get/`, `/commands/lolwut/`) sources information from `valkey-io/valkey`, and `valkey-io/valkey-doc`.
66-
`valkey-io/valkey` provides the command metadata (items like computational complexity, version history, arguments, etc) whilst `valkey-io/valkey-doc` provides the command description and the command reply.
65+
The command reference (i.e. `/commands/set/`, `/commands/get/`, `/commands/lolwut/`) sources information from `valkey-io/valkey`, `valkey-io/valkey-bloom`, and `valkey-io/valkey-doc`.
66+
`valkey-io/valkey` and `valkey-io/valkey-bloom` provides the command metadata (items like computational complexity, version history, arguments, etc) whilst `valkey-io/valkey-doc` provides the command description and the command reply.
6767

6868
```mermaid
6969
flowchart TD
@@ -74,13 +74,13 @@ flowchart TD
7474
H --> J[Files: /resp2_replies.json,<br/>/resp3_replies.json] --> Z[Command Reply]
7575
```
7676

77-
Let's say that this repo and your local copy of `valkey-io/valkey-doc` and `valkey-io/valkey` reside in the same directories.
77+
Let's say that this repo and your local copy of `valkey-io/valkey-doc`, `valkey-io/valkey-bloom` and `valkey-io/valkey` reside in the same directories.
7878
First, stop the `zola serve` process if you're running it.
7979
From the root directory of this repo run:
8080

8181
```shell
8282
# You should only need to run this once or when you add a new command.
83-
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands
83+
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands
8484
```
8585

8686
Then, restart Zola.

build/init-commands.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,30 @@ if [ ! -d "$2" ]; then
2424
exit 1
2525
fi
2626

27+
if [ ! -d "$3" ]; then
28+
echo "The bloom module command JSON directory must exist and be a valid path"
29+
exit 1
30+
fi
31+
2732
ln -s $1 ./build-command-docs
2833
ln -s $2 ./build-command-json
29-
34+
ln -s $3 ./build-bloom-command-json
3035
for fname in $(find $1 -maxdepth 1 -iname "*.md")
3136
do
3237
base=${fname##*/}
3338
command=${base%.*}
3439
command_upper=$(awk '{ print toupper($0) }' <<< $command)
3540
if [[ "$command" != "index" ]]; then
41+
if [ -f "$2/$command.json" ]; then
42+
metadata_path="/commands/$command.json in the 'valkey' repo"
43+
elif [ -f "$3/$command.json" ]; then
44+
metadata_path="/commands/$command.json in the 'valkey-bloom' repo"
45+
fi
3646
cat << EOF > "./content/commands/$command.md"
3747
+++
3848
# This is a generated stub file.
3949
# To edit the command description see /commands/$command.md in the 'valkey-doc' repo
40-
# The command metadata is generated from /src/$command.json in the 'valkey' repo
50+
# The command metadata is generated from $metadata_path
4151
aliases = ["/commands/$command_upper/"]
4252
+++
4353
EOF

config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ highlight_code = true
2121
[extra]
2222
command_description_path = "../build-command-docs/"
2323
command_json_path = "../build-command-json/"
24+
command_bloom_json_path = "../build-bloom-command-json/"
2425
doc_topic_path = "../build-topics/"
2526

2627
review_list = [

templates/command-page.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
{% set upper_slug = page.slug | upper %}
88

99
{% set command_description = load_data(path=config.extra.command_description_path ~ page.slug ~ ".md", required= false) %}
10-
{% set command_data = load_data(path= commands::command_json_path(slug= page.slug), required= false) %}
10+
{% set command_sources = [
11+
load_data(path= commands::command_json_path(slug= page.slug), required= false),
12+
load_data(path= commands::command_bloom_json_path(slug= page.slug), required= false)
13+
] %}
14+
15+
{% set command_data = command_sources | filter(attribute="") | first %}
16+
1117
{% if command_data %}
1218
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
1319
{% set command_data_obj = command_data[command_obj_name] %}

templates/commands.html

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,27 @@
1111

1212
{% set commands_entries = [] %}
1313
{% for page in section.pages %}
14-
{% set command_data = load_data(path= commands::command_json_path(slug= page.slug), required= false) %}
15-
{% if command_data %}
16-
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
17-
{% set command_data_obj = command_data[command_obj_name] %}
18-
{% set command_display = command_obj_name %}
19-
{% if command_data_obj.container %}
20-
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
14+
{% for json_path in [
15+
commands::command_json_path(slug=page.slug),
16+
commands::command_bloom_json_path(slug=page.slug)
17+
] %}
18+
{% set command_data = load_data(path= json_path, required= false) %}
19+
{% if command_data %}
20+
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
21+
{% set command_data_obj = command_data[command_obj_name] %}
22+
{% set command_display = command_obj_name %}
23+
{% if command_data_obj.container %}
24+
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
25+
{% endif %}
26+
{% set command_entry = [
27+
command_display,
28+
page.permalink | safe,
29+
command_data_obj.summary,
30+
command_data_obj.group
31+
] %}
32+
{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}
2133
{% endif %}
22-
23-
{% set command_entry = [
24-
command_display,
25-
page.permalink | safe,
26-
command_data_obj.summary,
27-
command_data_obj.group
28-
] %}
29-
{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}
30-
{% endif %}
34+
{% endfor %}
3135
{% endfor %}
3236
{% set_global grouped = commands_entries | sort(attribute="3") | group_by(attribute="3") %}
3337

templates/macros/command.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
{{config.extra.command_json_path }}{{ slug }}.json
5353
{%- endmacro load_command_json -%}
5454

55+
{%- macro command_bloom_json_path(slug) -%}
56+
{{config.extra.command_bloom_json_path }}{{ slug }}.json
57+
{%- endmacro load_bloom_command_json -%}
58+
5559
{%- macro fix_links(content) -%}
5660
{{ content
5761
| regex_replace(pattern=`\]\(\.\./topics/(?P<fname>.*?).md#(?P<hash>.*?)\)`, rep=`](/topics/$fname#$hash)`)

0 commit comments

Comments
 (0)