Stream: ideas

Topic: Add flag to roc docs for subfolder


view this post on Zulip Luke Boswell (Jan 08 2025 at 01:15):

Luke Boswell said:

I wonder if we could just commit the html files into the repo under a folder structure...

www/
- 0.16.0/
- 0.17.0/

I'm not sure if this is compatible with GH pages...

I've been messing around with this... it'd be really nice if we had a flag in roc cli roc docs --mount "/0.11.0/" that could say, hey generate the static site but assume you will be mounted at this folder /0.11.0/ or something... so all the links point at the correct location and there is no need to replace things.

view this post on Zulip Notification Bot (Jan 08 2025 at 01:17):

A message was moved here from #compiler development > casual conversation by Luke Boswell.

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:17):

Does this idea sound like something we should/shouldn't add?

view this post on Zulip Brendan Hansknecht (Jan 08 2025 at 01:23):

Sounds reasonable if we don't have a better way to do relative links. Sometimes it is also useful to specify the full urls in apps and html files. So some sort of config here sounds really reasonable.

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:26):

Yeah doing a little research, it seems a common feature for static site generators to provide a path prefix.

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:29):

Oh we might already have it, I wonder what this var does? ROC_DOCS_URL_ROOT

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:32):

Hey I think it works!. .. well at least locally

view this post on Zulip Brendan Hansknecht (Jan 08 2025 at 01:34):

Probably should change that to a cli arg that can be found via help.

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:36):

I can do that soon, just testing the multiple docs version idea in roc-json

view this post on Zulip Richard Feldman (Jan 08 2025 at 01:44):

yeah it was originally added just for builtins

view this post on Zulip Richard Feldman (Jan 08 2025 at 01:44):

but cli flag seems fine :thumbs_up:

view this post on Zulip Richard Feldman (Jan 08 2025 at 01:44):

like --root or something

view this post on Zulip Richard Feldman (Jan 08 2025 at 01:45):

or --root-dir

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:46):

Hey it works... :tada:

https://lukewilliamboswell.github.io/roc-json/0.11.0/
https://lukewilliamboswell.github.io/roc-json/0.10.2/

view this post on Zulip Luke Boswell (Jan 08 2025 at 01:46):

That's the simplest multi-version docs site ever

view this post on Zulip Luke Boswell (Jan 08 2025 at 02:09):

Screenshot 2025-01-08 at 13.08.57.png

Added a default index page that redirects to the latest docs, or shows a link if JS is disabled.

view this post on Zulip Anthony Bullard (Jan 08 2025 at 02:51):

next we need to be able to put the package/app/platform name in the place of the word “documentation” :wink:

view this post on Zulip Anthony Bullard (Jan 08 2025 at 02:51):

Even if with a cli arg

view this post on Zulip Richard Feldman (Jan 08 2025 at 03:01):

yeah there's a design question there

view this post on Zulip Richard Feldman (Jan 08 2025 at 03:02):

need to figure out how package naming will actually work before we can display the names :big_smile:

view this post on Zulip Luke Boswell (Jan 23 2025 at 23:05):

In case it's helpful to anyone... here's a script I've used to generate the static docs for roc-json. It uses the --root-dir so these play nicely with GH Pages static sites.

https://lukewilliamboswell.github.io/roc-json/0.12.0/
https://lukewilliamboswell.github.io/roc-json/0.11.0/

#!/usr/bin/env bash

# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail

# Function to validate version number format (x.y.z)
validate_version() {
    if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
        echo "Error: Version number must be in format x.y.z (e.g., 0.12.0)"
        exit 1
    fi
}

# Check if version argument is provided
if [ $# -ne 1 ]; then
    echo "Usage: $0 <version>"
    echo "Example: $0 0.12.0"
    exit 1
fi

VERSION=$1

# Validate version number
validate_version "$VERSION"

# Run roc docs with validated version
roc docs --root-dir "/roc-json/$VERSION/" package/main.roc

# Create new version directory in www/
mkdir www/$VERSION

# Move generated docs to version directory
mv generated-docs/* www/$VERSION

Last updated: Jun 16 2026 at 16:19 UTC