Skip to content

Commit 4ee9881

Browse files
authored
Adding functionality for the bloom module to have its commands displayed on the Valkey website (#212)
Related PR's Bloom repo json command files: valkey-io/valkey-bloom#47 Valkey-doc repo: valkey-io/valkey-doc#233 ### Description This PR will allow set the framework so that modules can have their commands displayed on the valkey website (By adding the bloom module commands in a way that can be easily expanded on). I have tried to make this future proof by using a for loop on the `commands.html` page which can be expanded by just adding any new folders we want to pull commands from. For the `command-page.html` I have used an array to hold the data from the multiple folders with commands and then get the first occurrence that isn't empty (i.e the command belongs to that folder). This will keep ability so that if the command doesn't exist we still have the same fallback. Updated the `init-commands.sh` to create a link for the bloom commands as well and take in the bloom repository. I have updated the README as well to include the new repo that will be needed for the commands and the information change associated with now expecting commands from the bloom repo. Lastly updated the github workflow as well to also now build and take in the bloom repo **For screenshots of the new documentation the two pr's above (valkey-io/valkey-doc#233 and valkey-io/valkey-bloom#47) have screenshots of all sections being added** ### Check List - [x] Commits are signed per the DCO using `--signoff` By submitting this pull request, I confirm that my contribution is made under the terms of the BSD-3-Clause License. Signed-off-by: zackcam <[email protected]>
1 parent 50a63ec commit 4ee9881

File tree

8 files changed

+73
-28
lines changed

8 files changed

+73
-28
lines changed

.github/workflows/zola-deploy.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ jobs:
3333
with:
3434
repository: valkey-io/valkey
3535
path: valkey
36-
36+
37+
- name: Checkout valkey-bloom
38+
uses: actions/checkout@v4
39+
with:
40+
repository: valkey-io/valkey-bloom
41+
path: valkey-bloom
42+
3743
- name: Init commands, topics and clients
3844
run: |
3945
cd website
4046
./build/init-topics-and-clients.sh ../valkey-doc/topics ../valkey-doc/clients
41-
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands
47+
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands
48+
4249
- name: Build only
4350
uses: shalzz/[email protected]
4451
env:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ _site
1212
_data/groups.json
1313
_data/resp2_replies.json
1414
_data/resp3_replies.json
15+
_data/modules.json

README.md

+5-5
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

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

6464
### Building the command reference
6565

66-
The command reference (i.e. `/commands/set/`, `/commands/get/`, `/commands/lolwut/`) sources information from `valkey-io/valkey`, and `valkey-io/valkey-doc`.
67-
`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.
66+
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`.
67+
`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.
6868

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

78-
Let's say that this repo and your local copy of `valkey-io/valkey-doc` and `valkey-io/valkey` reside in the same directories.
78+
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.
7979
First, stop the `zola serve` process if you're running it.
8080
From the root directory of this repo run:
8181

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

8787
Then, restart Zola.

build/init-commands.sh

+13-3
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
@@ -46,7 +56,7 @@ done
4656

4757
echo "Command stub files created."
4858

49-
for datafile in groups.json resp2_replies.json resp3_replies.json; do
59+
for datafile in groups.json resp2_replies.json resp3_replies.json modules.json; do
5060
ln -s "../${1}/../${datafile}" "./_data/${datafile}"
5161

5262
echo "Created link to ${datafile}"

config.toml

+1
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
client_json_path = "../build-clients/"
2526
doc_topic_path = "../build-topics/"
2627

templates/command-page.html

+20-2
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] %}
@@ -48,13 +54,25 @@
4854
<dd>{{ command_data_obj.complexity }}</dd>
4955
<dl>
5056
{% endif %}
57+
{% if command_data_obj.module_since %}
58+
<dl>
59+
{% if "bf." in page.slug %}
60+
{% set module_reply = load_data(path="../_data/modules.json", required=false) -%}
61+
<dt>Module:</dt>
62+
<dd><a href={{module_reply.valkey_bloom.repo}}>{{module_reply.valkey_bloom.name}}</a></dd>
63+
{% endif %}
64+
<dl>
65+
<dl>
66+
<dt>Since module version:</dt>
67+
<dd>{{ command_data_obj.module_since }}</dd>
68+
<dl>
69+
{% endif %}
5170
{% if command_data_obj.since %}
5271
<dl>
5372
<dt>Since:</dt>
5473
<dd>{{ command_data_obj.since }}</dd>
5574
<dl>
5675
{% endif %}
57-
5876
</dl>
5977

6078
{% else %}

templates/commands.html

+20-16
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@
1616
</div>
1717

1818
{% for page in section.pages %}
19-
{% set command_data = load_data(path= commands::command_json_path(slug= page.slug), required= false) %}
20-
{% if command_data %}
21-
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
22-
{% set command_data_obj = command_data[command_obj_name] %}
23-
{% set command_display = command_obj_name %}
24-
{% if command_data_obj.container %}
25-
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
19+
{% for json_path in [
20+
commands::command_json_path(slug=page.slug),
21+
commands::command_bloom_json_path(slug=page.slug)
22+
] %}
23+
{% set command_data = load_data(path= json_path, required= false) %}
24+
{% if command_data %}
25+
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
26+
{% set command_data_obj = command_data[command_obj_name] %}
27+
{% set command_display = command_obj_name %}
28+
{% if command_data_obj.container %}
29+
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
30+
{% endif %}
31+
{% set command_entry = [
32+
command_display,
33+
page.permalink | safe,
34+
command_data_obj.summary,
35+
command_data_obj.group
36+
] %}
37+
{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}
2638
{% endif %}
27-
28-
{% set command_entry = [
29-
command_display,
30-
page.permalink | safe,
31-
command_data_obj.summary,
32-
command_data_obj.group
33-
] %}
34-
{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}
35-
{% endif %}
39+
{% endfor %}
3640
{% endfor %}
3741
{% set_global grouped = commands_entries | sort(attribute="3") | group_by(attribute="3") %}
3842

templates/macros/command.html

+4
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)