Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 8 additions & 49 deletions .github/actions/build-site/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Build the website
description: >
Builds a checkout of this repository into <path>/public, with its topics and
commands from valkey-doc and the command metadata from valkey and the modules, checked out
next to it in the workspace.
Builds a checkout of this repository into <path>/public, with the commands and topics of
the repos in build/doc-sources.toml, checked out next to it in the workspace.

inputs:
path:
Expand All @@ -18,57 +17,17 @@ inputs:
runs:
using: composite
steps:
- name: Checkout valkey
# Clones the repos in build/doc-sources.toml next to the website checkout.
- name: Checkout the doc sources
if: inputs.checkout-content == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey
path: valkey

- name: Checkout valkey-bloom
if: inputs.checkout-content == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-bloom
path: valkey-bloom

- name: Checkout valkey-doc
if: inputs.checkout-content == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-doc
path: valkey-doc

- name: Checkout valkey-json
if: inputs.checkout-content == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-json
path: valkey-json

- name: Checkout valkey-search
if: inputs.checkout-content == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-search
path: valkey-search

- name: Checkout valkey-large-object
if: inputs.checkout-content == 'true'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-large-object
path: valkey-large-object
shell: bash
working-directory: ${{ inputs.path }}
run: ./build/checkout-doc-sources.sh ..

- name: Init commands and topics
shell: bash
working-directory: ${{ inputs.path }}
run: |
./build/init-topics.sh ../valkey-doc/topics
./build/init-commands.sh ../valkey-doc/commands \
../valkey/src/commands ../valkey-bloom/src/commands \
../valkey-json/src/commands ../valkey-search/src/commands \
../valkey-large-object/src/commands
run: ./build/init-docs.sh ..

- name: Build only
uses: shalzz/zola-deploy-action@1be083648a1db2853ce4970e381740c0e2fd06de # v0.23.6
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
.DS_Store
public
package-lock.json
build-bloom-command-json
build-command-docs
build-command-json
build-json-command-json
build-search-command-json
build-large-object-command-json
build-nav
build-topics
content/commands/*
!content/commands/_index.md
Expand Down
98 changes: 42 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -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), [`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)
The build integrates the command and topic docs from [`valkey-io/valkey`](https://github.com/valkey-io/valkey) and the module repos, with [`valkey-io/valkey-doc`](https://github.com/valkey-io/valkey-doc) as the fallback (see [Building additional content](#building-additional-content) below).

## Contributing

Expand Down Expand Up @@ -43,79 +43,65 @@ The script downloads the SPDX license list, so it needs network access.
## Building additional content

**By default, the site will build without documentation topics or the command reference.**
The content for documentation topics is stored within the `valkey-io/valkey-doc` repo.
The content for the command reference page is in the `valkey-io/valkey` repo.
The command and topic pages live next to the code: valkey's in [`valkey-io/valkey`](https://github.com/valkey-io/valkey), each module's in its own repo.
[`valkey-io/valkey-doc`](https://github.com/valkey-io/valkey-doc) is the fallback: it holds the pages that haven't moved yet and the pages that live there, such as the Valkey Bundle page, and `modules.json`.
The clients and integrations pages (`/clients/`, `/integrations/`) are built from `_data/libraries/` in this repo, so they need no other repo.

If you want to build the site with this content, you'll need to have a local copy of `valkey-io/valkey-doc` and `valkey-io/valkey` _outside_ of this repo.
Then follow the instructions to [build the documentation topics](#building-the-documentation-topics) and/or [build the command reference](#building-the-command-reference).
The instructions show how to use scripts that create symbolic links to the `valkey-io/valkey-doc` and `valkey-io/valkey` repos as well as create a series of empty stub files that tell Zola to create pages.
To build the site with the docs, check out the repos listed in `build/doc-sources.toml` next to this repo, then gather their docs (the scripts need Python 3.11 or later to read the TOML file):

### Building the documentation topics

Documentation 'topics' (i.e. `/topics/keyspace/`, `/topics/encryption/`, `/topics/transactions/`) source content from `valkey-io/valkey-doc`.

```mermaid
flowchart TD
A[Webpage: /topics/keyspace/ ]
A --> B[Template: valkey-io/valkey-website]
B --> H[Repo: valkey-io/valkey-doc ] --> I[File: /topics/keyspace.md ] --> Y[Topic content]
```shell
# Clones the repos that aren't there yet (shallow, so it's quick).
./build/checkout-doc-sources.sh ..
# Run again when you add or remove a command or topic, or change a command's group or container.
./build/init-docs.sh ..
```

Let's say that this repo and your local copy of `valkey-io/valkey-doc` reside in the same directory.
First, stop the `zola serve` process if you're running it.
From the root directory of this repo run:
Then restart `zola serve`.
`init-docs.sh` links the docs into `build-*` directories and writes a stub file in `content/commands/` or `content/topics/` for each page; all of them are ignored by git.
Edit the pages in their own repos; every page links to its source with "Update this Page on GitHub!".
The script uses [jq](https://jqlang.org/), if installed, to store each command's group and container for the documentation menu; without it the site still builds, but more slowly.

```shell
# You should only need to run this once or when you add a new topic.
./build/init-topics.sh ../valkey-doc/topics
```
### Where the docs come from

Then, restart Zola.
Point your browser at `http://127.0.0.1:1111/topics/` and you should see the fully populated list of topics.
All files created in this process are ignored by git.
Commit your changes to your local copy of `valkey-io/valkey-doc`.
Each repo in `build/doc-sources.toml` can provide:

### Building the command reference
| File | Page |
|---|---|
| `docs/commands/<name>.md` | `/commands/<name>/`, with the metadata from `src/commands/<name>.json` |
| `docs/topics/<name>.md`, and images next to it | `/topics/<name>/` |
| `docs/nav.yml` | Its entries in the documentation menu |
| `docs/groups.json` (core repo only) | The command groups |

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`, `valkey-io/valkey-bloom`, `valkey-io/valkey-json`, `valkey-io/valkey-search` and `valkey-io/valkey-large-object` 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.
`src/commands/<name>.json` is the command's metadata (arguments, complexity, history); it gets a page only if some repo has `docs/commands/<name>.md`.
The fallback repo (valkey-doc) has the same files without the `docs/` prefix, its menu files in `nav.yml` and `modules-nav/<repo>.yml`.
A code repo's file wins over the fallback's copy with the same name.
If two code repos provide the same command, topic, image or command JSON, `init-docs.sh` lists both paths and fails, so a URL can't silently change source.
The menu merges the core repo's `nav.yml` with the other repos' menu files, in the order of `build/doc-sources.toml`, then the fallback's menu files that no repo is named after.

```mermaid
flowchart TD
A[Webpage: valkey.io/commands/set]
A --> B[Template: valkey-io/valkey-website]
B --> F[Repo: valkey-io/valkey ] --> G[File: /src/commands/set.json ] --> X[Command Metadata]
B --> H[Repo: valkey-io/valkey-doc ] --> I[File: /commands/set.md ] --> Y[Command Description]
H --> J[Files: /resp2_replies.json,<br/>/resp3_replies.json] --> Z[Command Reply]
```
`/topics/modules-api-ref/` is generated from valkey's `src/module.c` with `utils/generate-module-api-doc.rb`, which needs Ruby 2.3 or later and valkey's release tags (`checkout-doc-sources.sh` fetches them).
Without Ruby, the fallback's copy is used if it has one.

Let's say that this repo and your local copy of `valkey-io/valkey-doc`, `valkey-io/valkey-bloom`, `valkey-io/valkey-json`, `valkey-io/valkey-search`,
`valkey-io/valkey-large-object` and `valkey-io/valkey` reside in the same directories.
### Adding a repo

First, stop the `zola serve` process if you're running it.
From the root directory of this repo run:
Add a `[[source]]` table to `build/doc-sources.toml`; nothing else in this repo needs to change.

```shell
# You should only need to run this once or when you add a new command,
# or when a command's group or container changes.
./build/init-commands.sh ../valkey-doc/commands ../valkey/src/commands \
../valkey-bloom/src/commands ../valkey-json/src/commands ../valkey-search/src/commands \
../valkey-large-object/src/commands
```toml
[[source]]
name = "valkey-bloom"
repository = "valkey-io/valkey-bloom"
branch = "unstable"
path = "valkey-bloom"
role = "module"
```

The script uses [jq](https://jqlang.org/), if installed, to store each command's group and container for the documentation menu.
Without jq, the site still builds correctly, but more slowly.

Then, restart Zola.
Point your browser at `http://127.0.0.1:1111/commands/` and you should see the fully populated list of topics.
All files created in this process are ignored by git.
Commit your changes to your local copy of `valkey-io/valkey-doc` for description changes and `valkey-io/valkey` for command JSON changes (if you have any).
- `name`: the repo's name in the menu data and the stub comments, and the name of its fallback menu file (`modules-nav/<name>.yml`).
- `repository` and `branch`: what CI checks out, and where "Update this Page on GitHub!" points. To build against a fork's branch, change these two.
- `path`: the checkout directory, relative to the directory that holds this repo.
- `role`: `core` (valkey: the core menu and `groups.json`), `fallback` (valkey-doc), or `module` (its menu entries get a "module" label).

### Checking links

Pull requests and deploys check the built site for links to missing pages or `#anchors`, and for valkey-doc links that weren't converted to site URLs.
Pull requests and deploys check the built site for links to missing pages or `#anchors`, and for doc links that weren't converted to site URLs.
To run the checks locally (needs [lychee](https://lychee.cli.rs/) and jq), set up the topics and commands as above, then:

```shell
Expand Down
23 changes: 23 additions & 0 deletions build/checkout-doc-sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# See README for usage.
# Clones every repo in build/doc-sources.toml into the directory given as the
# first argument (default: the parent directory of this repo). Repos that are
# already there are left alone.
set -e

registry=$(python3 "$(dirname "$0")/doc-sources.py")
cd "${1:-$(dirname "$0")/../..}"

while IFS=$'\t' read -r name repository branch path role; do
if [ -e "$path" ]; then
echo "$name: $path exists, skipped"
continue
fi
git clone --quiet --depth 1 --branch "$branch" "https://github.com/$repository.git" "$path"
# The core repo's release tags fill in "Available since" in the
# generated module API reference. Each tag needs only its own commit.
if [ "$role" = core ]; then
git -C "$path" fetch --quiet --depth 1 origin '+refs/tags/*:refs/tags/*'
fi
echo "$name: cloned $repository $branch into $path"
done <<< "$registry"
51 changes: 51 additions & 0 deletions build/doc-sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
# Checks build/doc-sources.toml (or the file given as the first argument) and
# prints one tab-separated line per source, in file order:
# name repository branch path role
# Used by build/checkout-doc-sources.sh and build/init-docs.sh.
import sys

if sys.version_info < (3, 11):
sys.exit("build/doc-sources.py needs Python 3.11 or later (for tomllib), found %d.%d"
% sys.version_info[:2])

import os
import tomllib

KEYS = ["name", "repository", "branch", "path", "role"]
ROLES = ["core", "module", "fallback"]

path = sys.argv[1] if len(sys.argv) > 1 else os.path.join(os.path.dirname(os.path.abspath(__file__)), "doc-sources.toml")


def fail(message):
sys.exit("%s: %s" % (path, message))


try:
with open(path, "rb") as f:
sources = tomllib.load(f).get("source", [])
except (OSError, tomllib.TOMLDecodeError) as e:
fail(e)

if not isinstance(sources, list) or not all(isinstance(s, dict) for s in sources):
fail("'source' must be an array of tables ([[source]])")

for n, source in enumerate(sources, 1):
for key in KEYS:
value = source.get(key)
if not isinstance(value, str) or not value or any(c in value for c in "\t\n"):
fail("source %d (%s) needs '%s', a non-empty string on one line"
% (n, source.get("name", "no name"), key))
if source["role"] not in ROLES:
fail("source %d (%s) has role '%s', must be one of %s"
% (n, source["name"], source["role"], ", ".join(ROLES)))

for role in ["core", "fallback"]:
found = [s["name"] for s in sources if s["role"] == role]
if len(found) != 1:
fail("needs exactly one source with role '%s', found %d%s"
% (role, len(found), " (%s)" % ", ".join(found) if found else ""))

for source in sources:
print("\t".join(source[key] for key in KEYS))
84 changes: 84 additions & 0 deletions build/doc-sources.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# The repos the documentation comes from. See "Building additional content"
# in README.md.
#
# One [[source]] table per repo. Their order is the menu merge order: the
# other repos' menu files are merged into the core menu in this order.
#
# name The repo's name in the menu data and the stub comments, and the
# name of its fallback menu file (modules-nav/<name>.yml in the
# fallback repo).
# repository The GitHub repo (owner/name) that build/checkout-doc-sources.sh
# clones, and where "Update this Page on GitHub!" points.
# branch The branch to clone and link to. To build against a fork's
# branch, change repository and branch.
# path The checkout directory, relative to the directory that holds
# this repo.
# role One of:
# core valkey: the core menu (docs/nav.yml), groups.json and
# the generated module API reference. Exactly one.
# module A module: its menu entries get a "module" label.
# fallback valkey-doc: pages, menus and data files that haven't
# moved to a code repo yet, and pages that live there,
# such as the Valkey Bundle page. Its menu files that
# no source is named after are merged last. Exactly one.
#
# To add a module, add a [[source]] table with role = "module" where its menu
# entries should go, for example:
#
# [[source]]
# name = "valkey-example"
# repository = "valkey-io/valkey-example"
# branch = "main"
# path = "valkey-example"
# role = "module"
#
# build/doc-sources.py checks this file and prints it for the shell scripts.

[[source]]
name = "valkey"
repository = "valkey-io/valkey"
branch = "unstable"
path = "valkey"
role = "core"

[[source]]
name = "valkey-bloom"
repository = "valkey-io/valkey-bloom"
branch = "unstable"
path = "valkey-bloom"
role = "module"

[[source]]
name = "valkey-json"
repository = "valkey-io/valkey-json"
branch = "unstable"
path = "valkey-json"
role = "module"

[[source]]
name = "valkey-search"
repository = "valkey-io/valkey-search"
branch = "main"
path = "valkey-search"
role = "module"

[[source]]
name = "valkey-ldap"
repository = "valkey-io/valkey-ldap"
branch = "main"
path = "valkey-ldap"
role = "module"

[[source]]
name = "valkey-large-object"
repository = "valkey-io/valkey-large-object"
branch = "main"
path = "valkey-large-object"
role = "module"

[[source]]
name = "valkey-doc"
repository = "valkey-io/valkey-doc"
branch = "main"
path = "valkey-doc"
role = "fallback"
Loading
Loading