From c2496e6d7589e3e533a315564f80286f478facc3 Mon Sep 17 00:00:00 2001 From: zackcam Date: Wed, 19 Feb 2025 20:34:56 +0000 Subject: [PATCH 1/2] Adding functionality for the bloom module to have its commands displayed on the valkey website Signed-off-by: zackcam --- .github/workflows/zola-deploy.yml | 10 +++++++-- .gitignore | 1 + README.md | 10 ++++----- build/init-commands.sh | 16 +++++++++++--- config.toml | 1 + templates/command-page.html | 22 +++++++++++++++++-- templates/commands.html | 36 +++++++++++++++++-------------- templates/macros/command.html | 4 ++++ 8 files changed, 72 insertions(+), 28 deletions(-) diff --git a/.github/workflows/zola-deploy.yml b/.github/workflows/zola-deploy.yml index d13a41fa..89cdeb7b 100644 --- a/.github/workflows/zola-deploy.yml +++ b/.github/workflows/zola-deploy.yml @@ -32,12 +32,18 @@ jobs: with: repository: valkey-io/valkey path: valkey - + + - name: Checkout valkey-bloom + uses: actions/checkout@v4 + with: + repository: valkey-io/valkey-bloom + path: valkey-bloom + - name: Init commands and topics run: | cd website ./build/init-topics.sh ../valkey-doc/topics - ./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands + ./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands - name: Build only uses: shalzz/zola-deploy-action@v0.19.1 env: diff --git a/.gitignore b/.gitignore index 728ce5c6..1297de9d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ _site _data/groups.json _data/resp2_replies.json _data/resp3_replies.json +_data/modules.json diff --git a/README.md b/README.md index 9a6468d5..aa50548f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Valkey.io website This repo contains the source for the valkey.io website (build scripts, template, blog posts, stylesheets, etc.). -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). +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). ## Contributing @@ -62,8 +62,8 @@ Commit your changes to your local copy of `valkey-io/valkey-doc`. ### Building the command reference -The command reference (i.e. `/commands/set/`, `/commands/get/`, `/commands/lolwut/`) sources information from `valkey-io/valkey`, and `valkey-io/valkey-doc`. -`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. +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`. +`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. ```mermaid flowchart TD @@ -74,13 +74,13 @@ flowchart TD H --> J[Files: /resp2_replies.json,
/resp3_replies.json] --> Z[Command Reply] ``` -Let's say that this repo and your local copy of `valkey-io/valkey-doc` and `valkey-io/valkey` reside in the same directories. +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. First, stop the `zola serve` process if you're running it. From the root directory of this repo run: ```shell # You should only need to run this once or when you add a new command. -./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands +./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands ``` Then, restart Zola. diff --git a/build/init-commands.sh b/build/init-commands.sh index 031eec04..f23f58e2 100755 --- a/build/init-commands.sh +++ b/build/init-commands.sh @@ -24,20 +24,30 @@ if [ ! -d "$2" ]; then exit 1 fi +if [ ! -d "$3" ]; then + echo "The bloom module command JSON directory must exist and be a valid path" + exit 1 +fi + ln -s $1 ./build-command-docs ln -s $2 ./build-command-json - +ln -s $3 ./build-bloom-command-json for fname in $(find $1 -maxdepth 1 -iname "*.md") do base=${fname##*/} command=${base%.*} command_upper=$(awk '{ print toupper($0) }' <<< $command) if [[ "$command" != "index" ]]; then + if [ -f "$2/$command.json" ]; then + metadata_path="/commands/$command.json in the 'valkey' repo" + elif [ -f "$3/$command.json" ]; then + metadata_path="/commands/$command.json in the 'valkey-bloom' repo" + fi cat << EOF > "./content/commands/$command.md" +++ # This is a generated stub file. # To edit the command description see /commands/$command.md in the 'valkey-doc' repo -# The command metadata is generated from /src/$command.json in the 'valkey' repo +# The command metadata is generated from $metadata_path aliases = ["/commands/$command_upper/"] +++ EOF @@ -46,7 +56,7 @@ done echo "Command stub files created." -for datafile in groups.json resp2_replies.json resp3_replies.json; do +for datafile in groups.json resp2_replies.json resp3_replies.json modules.json; do ln -s "../${1}/../${datafile}" "./_data/${datafile}" echo "Created link to ${datafile}" diff --git a/config.toml b/config.toml index db8a89ff..92154403 100644 --- a/config.toml +++ b/config.toml @@ -21,6 +21,7 @@ highlight_code = true [extra] command_description_path = "../build-command-docs/" command_json_path = "../build-command-json/" +command_bloom_json_path = "../build-bloom-command-json/" doc_topic_path = "../build-topics/" review_list = [ diff --git a/templates/command-page.html b/templates/command-page.html index b431896f..1e41182d 100644 --- a/templates/command-page.html +++ b/templates/command-page.html @@ -7,7 +7,13 @@ {% set upper_slug = page.slug | upper %} {% set command_description = load_data(path=config.extra.command_description_path ~ page.slug ~ ".md", required= false) %} -{% set command_data = load_data(path= commands::command_json_path(slug= page.slug), required= false) %} +{% set command_sources = [ + load_data(path= commands::command_json_path(slug= page.slug), required= false), + load_data(path= commands::command_bloom_json_path(slug= page.slug), required= false) +] %} + +{% set command_data = command_sources | filter(attribute="") | first %} + {% if command_data %} {% set command_obj_name = commands::command_obj_name(command_data= command_data) %} {% set command_data_obj = command_data[command_obj_name] %} @@ -48,13 +54,25 @@
{{ command_data_obj.complexity }}
{% endif %} + {% if command_data_obj.module_since %} +
+ {% if "bf." in page.slug %} + {% set module_reply = load_data(path="../_data/modules.json", required=false) -%} +
Module:
+
{{module_reply.valkey_bloom.name}}
+ {% endif %} +
+
+
Since module version:
+
{{ command_data_obj.module_since }}
+
+ {% endif %} {% if command_data_obj.since %}
Since:
{{ command_data_obj.since }}
{% endif %} -
{% else %} diff --git a/templates/commands.html b/templates/commands.html index ae42856b..ff4b7504 100644 --- a/templates/commands.html +++ b/templates/commands.html @@ -11,23 +11,27 @@ {% set commands_entries = [] %} {% for page in section.pages %} - {% set command_data = load_data(path= commands::command_json_path(slug= page.slug), required= false) %} - {% if command_data %} - {% set command_obj_name = commands::command_obj_name(command_data= command_data) %} - {% set command_data_obj = command_data[command_obj_name] %} - {% set command_display = command_obj_name %} - {% if command_data_obj.container %} - {% set command_display = command_data_obj.container ~ " " ~ command_display %} + {% for json_path in [ + commands::command_json_path(slug=page.slug), + commands::command_bloom_json_path(slug=page.slug) + ] %} + {% set command_data = load_data(path= json_path, required= false) %} + {% if command_data %} + {% set command_obj_name = commands::command_obj_name(command_data= command_data) %} + {% set command_data_obj = command_data[command_obj_name] %} + {% set command_display = command_obj_name %} + {% if command_data_obj.container %} + {% set command_display = command_data_obj.container ~ " " ~ command_display %} + {% endif %} + {% set command_entry = [ + command_display, + page.permalink | safe, + command_data_obj.summary, + command_data_obj.group + ] %} + {% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %} {% endif %} - - {% set command_entry = [ - command_display, - page.permalink | safe, - command_data_obj.summary, - command_data_obj.group - ] %} - {% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %} - {% endif %} + {% endfor %} {% endfor %} {% set_global grouped = commands_entries | sort(attribute="3") | group_by(attribute="3") %} diff --git a/templates/macros/command.html b/templates/macros/command.html index fdf9eb2a..81d55d93 100644 --- a/templates/macros/command.html +++ b/templates/macros/command.html @@ -52,6 +52,10 @@ {{config.extra.command_json_path }}{{ slug }}.json {%- endmacro load_command_json -%} +{%- macro command_bloom_json_path(slug) -%} +{{config.extra.command_bloom_json_path }}{{ slug }}.json +{%- endmacro load_bloom_command_json -%} + {%- macro fix_links(content) -%} {{ content | regex_replace(pattern=`\]\(\.\./topics/(?P.*?).md#(?P.*?)\)`, rep=`](/topics/$fname#$hash)`) From fefd2e03b8c929b075bf88c627505710c8cfae52 Mon Sep 17 00:00:00 2001 From: Nikhil Manglore Date: Sat, 29 Mar 2025 01:04:25 +0000 Subject: [PATCH 2/2] Adding JSON code on top of bloom in order to document the commands on the website Signed-off-by: Nikhil Manglore --- .github/workflows/zola-deploy.yml | 8 +++++++- README.md | 8 ++++---- build-json-command-json | 1 + build/init-commands.sh | 8 ++++++++ config.toml | 1 + templates/command-page.html | 7 ++++++- templates/commands.html | 3 ++- templates/macros/command.html | 4 ++++ 8 files changed, 33 insertions(+), 7 deletions(-) create mode 120000 build-json-command-json diff --git a/.github/workflows/zola-deploy.yml b/.github/workflows/zola-deploy.yml index e81d1d20..02468130 100644 --- a/.github/workflows/zola-deploy.yml +++ b/.github/workflows/zola-deploy.yml @@ -40,11 +40,17 @@ jobs: repository: valkey-io/valkey-bloom path: valkey-bloom + - name: Checkout valkey-json + uses: actions/checkout@v4 + with: + repository: valkey-io/valkey-json + path: valkey-json + - name: Init commands, topics and clients run: | cd website ./build/init-topics-and-clients.sh ../valkey-doc/topics ../valkey-doc/clients - ./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands + ./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands ../valkey-json/commands - name: Build only uses: shalzz/zola-deploy-action@v0.19.1 diff --git a/README.md b/README.md index f12ec773..27c007ed 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Valkey.io website This repo contains the source for the valkey.io website (build scripts, template, blog posts, stylesheets, etc.). -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). +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) ## Contributing @@ -64,7 +64,7 @@ Commit your changes to your local copy of `valkey-io/valkey-doc`. ### Building the command reference 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`. -`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. +`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. ```mermaid flowchart TD @@ -75,13 +75,13 @@ flowchart TD H --> J[Files: /resp2_replies.json,
/resp3_replies.json] --> Z[Command Reply] ``` -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. +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. First, stop the `zola serve` process if you're running it. From the root directory of this repo run: ```shell # You should only need to run this once or when you add a new command. -./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands +./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands ../valkey-bloom/src/commands ../valkey-json/src/commands ``` Then, restart Zola. diff --git a/build-json-command-json b/build-json-command-json new file mode 120000 index 00000000..97714961 --- /dev/null +++ b/build-json-command-json @@ -0,0 +1 @@ +../valkey-json/src/commands \ No newline at end of file diff --git a/build/init-commands.sh b/build/init-commands.sh index f23f58e2..fe4ca920 100755 --- a/build/init-commands.sh +++ b/build/init-commands.sh @@ -29,9 +29,15 @@ if [ ! -d "$3" ]; then exit 1 fi +if [ ! -d "$4" ]; then + echo "The JSON module command JSON directory must exist and be a valid path" + exit 1 +fi + ln -s $1 ./build-command-docs ln -s $2 ./build-command-json ln -s $3 ./build-bloom-command-json +ln -s $4 ./build-json-command-json for fname in $(find $1 -maxdepth 1 -iname "*.md") do base=${fname##*/} @@ -42,6 +48,8 @@ do metadata_path="/commands/$command.json in the 'valkey' repo" elif [ -f "$3/$command.json" ]; then metadata_path="/commands/$command.json in the 'valkey-bloom' repo" + elif [ -f "$4/$command.json" ]; then + metadata_path="/commands/$command.json in the 'valkey-json' repo" fi cat << EOF > "./content/commands/$command.md" +++ diff --git a/config.toml b/config.toml index e7ea2663..0a194cb9 100644 --- a/config.toml +++ b/config.toml @@ -22,6 +22,7 @@ highlight_code = true command_description_path = "../build-command-docs/" command_json_path = "../build-command-json/" command_bloom_json_path = "../build-bloom-command-json/" +command_json_json_path = "../build-json-command-json/" client_json_path = "../build-clients/" doc_topic_path = "../build-topics/" diff --git a/templates/command-page.html b/templates/command-page.html index 1e41182d..31081e76 100644 --- a/templates/command-page.html +++ b/templates/command-page.html @@ -9,7 +9,8 @@ {% set command_description = load_data(path=config.extra.command_description_path ~ page.slug ~ ".md", required= false) %} {% set command_sources = [ load_data(path= commands::command_json_path(slug= page.slug), required= false), - load_data(path= commands::command_bloom_json_path(slug= page.slug), required= false) + load_data(path= commands::command_bloom_json_path(slug= page.slug), required= false), + load_data(path= commands::command_json_json_path(slug= page.slug), required= false) ] %} {% set command_data = command_sources | filter(attribute="") | first %} @@ -60,6 +61,10 @@ {% set module_reply = load_data(path="../_data/modules.json", required=false) -%}
Module:
{{module_reply.valkey_bloom.name}}
+ {% elif "json." in page.slug %} + {% set module_reply = load_data(path="../_data/modules.json", required=false) -%} +
Module:
+
{{module_reply.valkey_json.name}}
{% endif %}
diff --git a/templates/commands.html b/templates/commands.html index ff4b7504..e05225f4 100644 --- a/templates/commands.html +++ b/templates/commands.html @@ -13,7 +13,8 @@ {% for page in section.pages %} {% for json_path in [ commands::command_json_path(slug=page.slug), - commands::command_bloom_json_path(slug=page.slug) + commands::command_bloom_json_path(slug=page.slug), + commands::command_json_json_path(slug=page.slug) ] %} {% set command_data = load_data(path= json_path, required= false) %} {% if command_data %} diff --git a/templates/macros/command.html b/templates/macros/command.html index 81d55d93..c40c3a3f 100644 --- a/templates/macros/command.html +++ b/templates/macros/command.html @@ -56,6 +56,10 @@ {{config.extra.command_bloom_json_path }}{{ slug }}.json {%- endmacro load_bloom_command_json -%} +{%- macro command_json_json_path(slug) -%} +{{config.extra.command_json_json_path }}{{ slug }}.json +{%- endmacro load_json_command_json -%} + {%- macro fix_links(content) -%} {{ content | regex_replace(pattern=`\]\(\.\./topics/(?P.*?).md#(?P.*?)\)`, rep=`](/topics/$fname#$hash)`)