Skip to content

Commit a5d94b2

Browse files
Adding functionality for the JSON module to have commands displayed on the Valkey Website (#230)
### Description This PR will add the JSON commands on the Valkey website. Note that this PR was created off of a branch of the [bloom filter documentation PR](#212). Merge conflicts will occur if that PR needs to be changed so I will update accordingly. Example: <img width="958" alt="Screenshot 2025-04-02 at 5 10 01 PM" src="https://github.com/user-attachments/assets/0e4e7b6f-6a82-4757-a70f-e320dc9cae00" /> ### 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]> Signed-off-by: Nikhil Manglore <[email protected]> Signed-off-by: Nikhil Manglore <[email protected]> Co-authored-by: zackcam <[email protected]>
1 parent 78e4e78 commit a5d94b2

File tree

8 files changed

+33
-7
lines changed

8 files changed

+33
-7
lines changed

.github/workflows/zola-deploy.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ jobs:
4040
repository: valkey-io/valkey-bloom
4141
path: valkey-bloom
4242

43+
- name: Checkout valkey-json
44+
uses: actions/checkout@v4
45+
with:
46+
repository: valkey-io/valkey-json
47+
path: valkey-json
48+
4349
- name: Init commands, topics and clients
4450
run: |
4551
cd website
4652
./build/init-topics-and-clients.sh ../valkey-doc/topics ../valkey-doc/clients
47-
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands
53+
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands ../valkey-json/commands
4854
4955
- name: Build only
5056
uses: shalzz/[email protected]

README.md

Lines changed: 4 additions & 4 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) and [`valkey-io/valkey-bloom`](https://github.com/valkey-io/valkey-bloom) (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), [`valkey-io/valkey-bloom`](https://github.com/valkey-io/valkey-bloom), and [`valkey-io/valkey-json`](https://github.com/valkey-io/valkey-json) (see [Build Locally](#build-locally) below for more details)
55

66
## Contributing
77

@@ -64,7 +64,7 @@ Commit your changes to your local copy of `valkey-io/valkey-doc`.
6464
### Building the command reference
6565

6666
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.
67+
`valkey-io/valkey`, `valkey-io/valkey-bloom` and `valkey-io/valkey-json` 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`, `valkey-io/valkey-bloom` 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`, `valkey-io/valkey-json`, 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 ../valkey-bloom/src/commands
84+
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands ../valkey-json/src/commands
8585
```
8686

8787
Then, restart Zola.

build-json-command-json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../valkey-json/src/commands

build/init-commands.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ if [ ! -d "$3" ]; then
2929
exit 1
3030
fi
3131

32+
if [ ! -d "$4" ]; then
33+
echo "The JSON module command JSON directory must exist and be a valid path"
34+
exit 1
35+
fi
36+
3237
ln -s $1 ./build-command-docs
3338
ln -s $2 ./build-command-json
3439
ln -s $3 ./build-bloom-command-json
40+
ln -s $4 ./build-json-command-json
3541
for fname in $(find $1 -maxdepth 1 -iname "*.md")
3642
do
3743
base=${fname##*/}
@@ -42,6 +48,8 @@ do
4248
metadata_path="/commands/$command.json in the 'valkey' repo"
4349
elif [ -f "$3/$command.json" ]; then
4450
metadata_path="/commands/$command.json in the 'valkey-bloom' repo"
51+
elif [ -f "$4/$command.json" ]; then
52+
metadata_path="/commands/$command.json in the 'valkey-json' repo"
4553
fi
4654
cat << EOF > "./content/commands/$command.md"
4755
+++

config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ highlight_code = true
2222
command_description_path = "../build-command-docs/"
2323
command_json_path = "../build-command-json/"
2424
command_bloom_json_path = "../build-bloom-command-json/"
25+
command_json_json_path = "../build-json-command-json/"
2526
client_json_path = "../build-clients/"
2627
doc_topic_path = "../build-topics/"
2728

templates/command-page.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{% set command_description = load_data(path=config.extra.command_description_path ~ page.slug ~ ".md", required= false) %}
1010
{% set command_sources = [
1111
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)
12+
load_data(path= commands::command_bloom_json_path(slug= page.slug), required= false),
13+
load_data(path= commands::command_json_json_path(slug= page.slug), required= false)
1314
] %}
1415

1516
{% set command_data = command_sources | filter(attribute="") | first %}
@@ -60,6 +61,10 @@
6061
{% set module_reply = load_data(path="../_data/modules.json", required=false) -%}
6162
<dt>Module:</dt>
6263
<dd><a href={{module_reply.valkey_bloom.repo}}>{{module_reply.valkey_bloom.name}}</a></dd>
64+
{% elif "json." in page.slug %}
65+
{% set module_reply = load_data(path="../_data/modules.json", required=false) -%}
66+
<dt>Module:</dt>
67+
<dd><a href={{module_reply.valkey_json.repo}}>{{module_reply.valkey_json.name}}</a></dd>
6368
{% endif %}
6469
<dl>
6570
<dl>

templates/commands.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
{% for page in section.pages %}
1919
{% for json_path in [
2020
commands::command_json_path(slug=page.slug),
21-
commands::command_bloom_json_path(slug=page.slug)
21+
commands::command_bloom_json_path(slug=page.slug),
22+
commands::command_json_json_path(slug=page.slug)
2223
] %}
2324
{% set command_data = load_data(path= json_path, required= false) %}
2425
{% if command_data %}

templates/macros/command.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
{{config.extra.command_bloom_json_path }}{{ slug }}.json
5757
{%- endmacro load_bloom_command_json -%}
5858

59+
{%- macro command_json_json_path(slug) -%}
60+
{{config.extra.command_json_json_path }}{{ slug }}.json
61+
{%- endmacro load_json_command_json -%}
62+
5963
{%- macro fix_links(content) -%}
6064
{{ content
6165
| regex_replace(pattern=`\]\(\.\./topics/(?P<fname>.*?).md#(?P<hash>.*?)\)`, rep=`](/topics/$fname#$hash)`)

0 commit comments

Comments
 (0)