Skip to content

Commit

Permalink
parsing the valkey command JSON files (draft only) (#8)
Browse files Browse the repository at this point in the history
Initial work to parse the command json files from Valkey.

* Add submodules for valkey-io/valkey and valkey-io/valkey-doc
* Adds a bash script to generate stub files for all the commands
* Adds recursive argument template
* Adds a command layout (e.g. template for each command)
* Two tweaks to SCSS to make it look readable and consistent
* Adds a file to render the command listing
* Adds all command stubs (generated by the bash script)

Signed-off-by: Kyle J. Davis <[email protected]>
  • Loading branch information
stockholmux authored Apr 8, 2024
1 parent a6a43bd commit 53318a5
Show file tree
Hide file tree
Showing 402 changed files with 2,114 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ _site
.jekyll-metadata
vendor
.DS_Store
/_data/commands/
/_includes/commands/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "_submodules/valkey"]
path = _submodules/valkey
url = https://github.com/valkey-io/valkey
[submodule "_submodules/valkey-doc"]
path = _submodules/valkey-doc
url = https://github.com/valkey-io/valkey-doc
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GEM
eventmachine (1.2.7)
ffi (1.16.3)
forwardable-extended (2.6.0)
google-protobuf (3.25.3-arm64-darwin)
google-protobuf (3.25.3-x86_64-darwin)
http_parser.rb (0.8.0)
i18n (1.14.4)
Expand All @@ -33,6 +34,7 @@ GEM
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-datapage-generator (1.4.0)
jekyll-feed (0.15.1)
jekyll (>= 3.7, < 5.0)
jekyll-last-modified-at (1.3.0)
Expand Down Expand Up @@ -73,6 +75,8 @@ GEM
rouge (3.26.0)
ruby-link-checker (0.2.0)
safe_yaml (1.0.5)
sass-embedded (1.69.5-arm64-darwin)
google-protobuf (~> 3.23)
sass-embedded (1.69.5-x86_64-darwin)
google-protobuf (~> 3.23)
terminal-table (3.0.2)
Expand All @@ -83,11 +87,13 @@ GEM
webrick (1.8.1)

PLATFORMS
arm64-darwin-22
x86_64-darwin-19
x86_64-darwin-21

DEPENDENCIES
jekyll (~> 4.3.2)
jekyll-datapage-generator
jekyll-feed (~> 0.12)
jekyll-last-modified-at
jekyll-paginate
Expand Down
26 changes: 26 additions & 0 deletions _build/commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# this bash script generates stubs directories/index files based on the command JSONs

COMMANDS="./_data/commands/latest/*.json"
for f in $COMMANDS
do
COMMAND=$(basename -- "$f")
COMMAND_FNAME=${COMMAND%.*}
DESCRIPTION_FNAME="./_includes/commands/latest/${COMMAND_FNAME}.md"
echo $DESCRIPTION_FNAME
mkdir ./commands/$COMMAND_FNAME
if [ -f "$DESCRIPTION_FNAME" ]; then
echo "Exists, ${DESCRIPTION_FNAME}"
DESCRIPTION_FRONTMATTER="description: ${COMMAND_FNAME}.md"
else
DESCRIPTION_FRONTMATTER=""
fi

cat << EOF > ./commands/$COMMAND_FNAME/index.html
---
layout: command
title: $COMMAND_FNAME
$DESCRIPTION_FRONTMATTER
---
EOF
done
26 changes: 26 additions & 0 deletions _includes/command/arguments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% for arguments in include.arguments_array %}

{% capture arguments_str %}
{% if arguments.optional == true %}[{% elsif arguments.type == "oneof"%}〈{%endif%}
{% if arguments.type != "pure-token" and arguments.token %}
{{ arguments.token }}
{% endif %}
{% if arguments.type != "block" and arguments.type != "oneof" %}
{{ arguments.name }}
{% endif %}

{% if arguments.type == "oneof" %}
{% include command/arguments.html arguments_array=arguments.arguments separator="|" %}
{% else %}
{% include command/arguments.html arguments_array=arguments.arguments %}
{% endif %}
{% if include.separator == "|" and forloop.last == false %} | {% endif %}

{% if arguments.optional == true %}]{% elsif arguments.type == "oneof"%}〉{%endif%}
{% endcapture %}
{{ arguments_str }}

{% if arguments.multiple %}
[ {{ arguments_str }} ...]
{% endif %}
{% endfor %}
59 changes: 59 additions & 0 deletions _layouts/command.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
layout: default
---

{% for command in site.data.commands.latest[page.title] %}
{% assign command_name = command[0] %}
{% assign command_lower = command[0] | downcase %}
{% assign command_details = command[1] %}
{% capture usage %}{{command_details.container }} {{ command_name }} {% include command/arguments.html arguments_array=command_details.arguments %}{% endcapture %}
<h1 class="page-title">{{command_details.container }} {{ command_name }}
{% if command_details.doc_flags contains "DEPRECATED" %}
<small>Deprecated</small>
{% endif %}
</h1>
<div class="width-limiter">
<main class="container">

<dl>
<dt>Usage:</dt>
<dd><code>{{usage}}</code></dd>
</dl>
<dl>
<dt>Complexity:</dt>
<dd>{{ command_details.complexity }}</dd>
</dl>
<dl>
<dt>Since:</dt>
<dd>{{ command_details.since }}</dd>
</dl>
{% if page.description %}
{% assign command_description_file = "commands/latest/FILE" | replace: "FILE", page.description %}
{% capture description %}{% include {{ command_description_file }} %}{% endcapture %}
{{ description | replace: "@examples", "## Examples" | markdownify }}
{% endif %}
{% if command_details.history %}
<h3>History</h3>
<table>
<thead>
<tr>
<th>Version</th>
<th>Change</th>
</tr>
</thead>

<tbody>
{% for history_line in command_details.history %}
<tr>
<td>{{history_line[0]}}</td>
<td>{{history_line[1]}}</td>
</tr>
{% endfor %}
</tbody>

</table>
{% endif %}
</main>
</div>

{% endfor %}
10 changes: 9 additions & 1 deletion _sass/_valkey.scss
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ p {
max-width: var(--max-width);
background: #fff;
margin: 0 auto;
padding: 4rem;
padding: 2rem;
color: $body-text-color;
border-bottom: 10px solid $body-heading-color;
font-weight: 300;
Expand Down Expand Up @@ -471,4 +471,12 @@ aside {
padding: .5rem 1rem;
}
}
}

.command-entry {
border-bottom: 1px dotted $line;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
padding-top: 1rem;
padding-bottom: 1rem;
}
1 change: 1 addition & 0 deletions _submodules/valkey
Submodule valkey added at 9f03df
1 change: 1 addition & 0 deletions _submodules/valkey-doc
Submodule valkey-doc added at a26a6c
5 changes: 5 additions & 0 deletions commands/acl-cat/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-cat
description: acl-cat.md
---
5 changes: 5 additions & 0 deletions commands/acl-deluser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-deluser
description: acl-deluser.md
---
5 changes: 5 additions & 0 deletions commands/acl-dryrun/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-dryrun
description: acl-dryrun.md
---
5 changes: 5 additions & 0 deletions commands/acl-genpass/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-genpass
description: acl-genpass.md
---
5 changes: 5 additions & 0 deletions commands/acl-getuser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-getuser
description: acl-getuser.md
---
5 changes: 5 additions & 0 deletions commands/acl-help/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-help
description: acl-help.md
---
5 changes: 5 additions & 0 deletions commands/acl-list/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-list
description: acl-list.md
---
5 changes: 5 additions & 0 deletions commands/acl-load/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-load
description: acl-load.md
---
5 changes: 5 additions & 0 deletions commands/acl-log/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-log
description: acl-log.md
---
5 changes: 5 additions & 0 deletions commands/acl-save/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-save
description: acl-save.md
---
5 changes: 5 additions & 0 deletions commands/acl-setuser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-setuser
description: acl-setuser.md
---
5 changes: 5 additions & 0 deletions commands/acl-users/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-users
description: acl-users.md
---
5 changes: 5 additions & 0 deletions commands/acl-whoami/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl-whoami
description: acl-whoami.md
---
5 changes: 5 additions & 0 deletions commands/acl/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: acl
description: acl.md
---
5 changes: 5 additions & 0 deletions commands/append/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: append
description: append.md
---
5 changes: 5 additions & 0 deletions commands/asking/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: asking
description: asking.md
---
5 changes: 5 additions & 0 deletions commands/auth/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: auth
description: auth.md
---
5 changes: 5 additions & 0 deletions commands/bgrewriteaof/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bgrewriteaof
description: bgrewriteaof.md
---
5 changes: 5 additions & 0 deletions commands/bgsave/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bgsave
description: bgsave.md
---
5 changes: 5 additions & 0 deletions commands/bitcount/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bitcount
description: bitcount.md
---
5 changes: 5 additions & 0 deletions commands/bitfield/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bitfield
description: bitfield.md
---
5 changes: 5 additions & 0 deletions commands/bitfield_ro/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bitfield_ro
description: bitfield_ro.md
---
5 changes: 5 additions & 0 deletions commands/bitop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bitop
description: bitop.md
---
5 changes: 5 additions & 0 deletions commands/bitpos/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bitpos
description: bitpos.md
---
5 changes: 5 additions & 0 deletions commands/blmove/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: blmove
description: blmove.md
---
5 changes: 5 additions & 0 deletions commands/blmpop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: blmpop
description: blmpop.md
---
5 changes: 5 additions & 0 deletions commands/blpop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: blpop
description: blpop.md
---
5 changes: 5 additions & 0 deletions commands/brpop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: brpop
description: brpop.md
---
5 changes: 5 additions & 0 deletions commands/brpoplpush/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: brpoplpush
description: brpoplpush.md
---
5 changes: 5 additions & 0 deletions commands/bzmpop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bzmpop
description: bzmpop.md
---
5 changes: 5 additions & 0 deletions commands/bzpopmax/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bzpopmax
description: bzpopmax.md
---
5 changes: 5 additions & 0 deletions commands/bzpopmin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: bzpopmin
description: bzpopmin.md
---
5 changes: 5 additions & 0 deletions commands/client-caching/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: command
title: client-caching
description: client-caching.md
---
Loading

0 comments on commit 53318a5

Please sign in to comment.