Skip to content

Latest commit

 

History

History
134 lines (99 loc) · 11.6 KB

CLAUDE.md

File metadata and controls

134 lines (99 loc) · 11.6 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

Hugo documentation website for Cozystack (Kubernetes-based cloud platform) using the Google Docsy theme. Production is served by GitHub Pages. Netlify is only used for deploy previews on PRs. Do not rely on Netlify-specific redirects or headers for production behavior. The stable /docs/ and /docs/v<major>/ paths are real copies of the latest version, produced after hugo by hack/mirror_latest.sh (Python 3 standard library). Current numbered docs and both copies use canonical URLs under /docs/. Older numbered docs remain noindex and are excluded from sitemaps. Preview builds are noindex. The version-selection landing is copied to /docs/versions/; mirroring preserves numbered versions and unrelated legacy aliases. The .docs-mirror.json file tracks root and major copies for cleanup on repeat builds. Under hugo server, version-selection links use the existing /docs/ landing.

Build & Development Commands

# Install dependencies
npm install

# Local dev server (serves at http://localhost:1313/docs; wipes public/ first)
make serve

# Production build
./hack/download_openapi.sh && hugo --gc --minify && ./hack/mirror_latest.sh

# Sync app docs from cozystack/cozystack repo.
# By default targets content/en/docs/next/ (the version-agnostic trunk).
# With RELEASE_TAG, routing depends on whether the minor version is already released:
#   - patch of an existing released version → updates that vX.Y/ in place
#   - otherwise                              → updates next/ (upcoming release)
make update-all                        # update trunk from upstream main
make update-all RELEASE_TAG=v1.2.5     # patch release → updates v1.2/
make update-all RELEASE_TAG=v1.3.0     # v1.3 not yet released → still updates next/
make update-apps                       # application docs only (also: update-vms, update-networking, update-k8s, update-services)
make update-oss-health                 # OSS health metrics (requires Python 3.12+)

# Scaffold front-matter-only stubs into DEST/_include (scaffolding variant of update-*, via hack/fill_templates.sh)
make template-all                      # or template-apps / template-vms / template-networking / template-k8s / template-services

# Version lifecycle (requires yq v4+)
make init-next                         # (re)create content/en/docs/next/ from latest released version
make release-next RELEASE_TAG=v1.3.0   # promote next/ → v1.3/, register in hugo.yaml

# Initialize a new docs version directory directly (edge cases / manual backfills)
make init-version DOC_VERSION=v1.3

# Override the app list for any update-*/template-* target
make update-apps APPS="tenant redis"

# Debug routing
make show-target RELEASE_TAG=v1.3.0    # prints the resolved DOC_VERSION/BRANCH

Required tools: Hugo extended v0.164.0, Go 1.23+, Node 22+, yq v4+ (for version lifecycle targets), jq (for hack/download_openapi.sh in the production build and make update-all without RELEASE_TAG).

Architecture

  • Hugo modules (not git submodules): Docsy theme v0.12.0 pulled via go.mod
  • Versioned docs: content/en/docs/v0/, content/en/docs/v1.0/, content/en/docs/v1.1/, content/en/docs/v1.2/ plus the permanent trunk content/en/docs/next/. Version switching handled by layouts/partials/version-switcher.html (honours the hidden: true flag on version entries). Version derived from RELEASE_TAG (e.g., v1.2.1 → v1.2)
  • Content sync scripts: hack/update_apps.sh fetches READMEs from the upstream cozystack repo and appends autogenerated notices. Driven by the make update-* targets (manual)
  • OpenAPI specs: v0/v1.0 api.json stored in git; v1.1+ downloaded at build time from GitHub releases via hack/download_openapi.sh
  • OSS health pipeline: hack/update_oss_health.py collects metrics from GitHub API, OpenSSF, DevStats, OSS Insight → writes JSON to data/oss-health/ and static/oss-health-data/. Monthly GitHub Action
  • Asset pipeline: Bootstrap 5.3 + Font Awesome 6.7 mounted from node_modules via Hugo mounts (configured in hugo.yaml). SCSS entry point: assets/scss/main.scss
  • Blog: content/en/blog/ with permalink pattern :section/:year/:month/:slug/

Versioning

Docs are versioned per Cozystack minor release. Each version is an independent copy of the tree under content/en/docs/<version>/ and is built into its own URL prefix (/docs/<version>/).

Directory layout

  • One directory per minor version: content/en/docs/v0/, v1.0/, v1.1/, v1.2/
  • Version name derivation: major 0 → v0 (legacy, covers all 0.x); major ≥ 1 → v<major>.<minor> (e.g., v1.2). Patch level is not reflected in the directory name
  • Each version directory is self-contained: all pages under applications/, virtualization/, networking/, operations/, storage/, install/, guides/, etc. live once per version
  • content/en/docs/_index.md is the version-selection landing, published at /docs/versions/ after mirroring
  • content/en/docs/next/ is the permanent trunk for upcoming/unreleased docs. Internal links use /docs/next/; these are rewritten at release time by hack/release_next.sh. Excluded from production builds via the hidden: true entry in hugo.yaml and the content mount exclusion - '! docs/next/**'

Version registration (hugo.yaml)

  • params.latest_version_id — id of the current/default version
  • params.versions[] — ordered list consumed by the version switcher (layouts/partials/version-switcher.html). Newest goes first, order highest. When adding a new version, update both fields.
  • params.versions_visible — how many of the newest non-hidden versions (ranked by order, minimum 1) stay in the switcher, the version table and the sidebar tree on the version-selection page (/docs/versions/); the rest are grouped under "Older versions". hack/register_version.sh needs no change: a new release pushes the oldest visible version into the group on its own. The split lives in layouts/partials/docs-versions.html.
  • hidden: true on a version entry hides it from the dropdown selector. Combined with the content mount exclusion pattern (- '! docs/<id>/**'), the whole version is also excluded from production builds. Used for the next trunk; the dev server and Netlify deploy previews still render it at /docs/next/.

Where to add changes

  • Docs for an upcoming (unreleased) feature → edit content/en/docs/next/. These materialize as v<next-release>/ when make release-next RELEASE_TAG=vX.Y.Z runs
  • Bug fix or addition to the current release → edit only content/en/docs/<latest_version_id>/ (the params.latest_version_id value in hugo.yaml)
  • Content that also applies to older supported versions → copy the change into each relevant v*/ directory (no automatic backport)
  • Cross-version/landing content → content/en/docs/_index.md
  • Blog posts are version-independent → content/en/blog/

Autogenerated files — do not edit in-place

  • App/VM/networking/services pages synced from cozystack/cozystack have the footer Autogenerated content. Don't edit this file directly; edit sources instead. (injected by hack/update_apps.sh)
  • To change the body: edit the upstream README in cozystack/cozystack under packages/apps/<app>/ (or packages/extra/<svc>/ for services), then re-run the corresponding make update-* target
  • To change only front matter (title, weight, aliases) for a specific version: edit the stub at content/en/docs/<version>/<section>/_include/<app>.md — update-* merges this with the upstream README. make template-* scaffolds these stubs

RELEASE_TAG → routing (Makefile)

The Makefile routes updates between next/ and released vX.Y/ directories. Given a RELEASE_TAG like v1.2.5 the minor version v1.2 is derived; routing is:

  • make update-all (no tag) → DOC_VERSION=next, BRANCH=main
  • make update-all RELEASE_TAG=v1.2.5 and content/en/docs/v1.2/ exists and is a non-hidden entry in hugo.yaml → DOC_VERSION=v1.2 (patch release, updates in place)
  • make update-all RELEASE_TAG=v1.3.0 and content/en/docs/v1.3/ does not yet exist → DOC_VERSION=next (still accumulating in the trunk)
  • make release-next RELEASE_TAG=v1.3.0 copies content/en/docs/next/ → content/en/docs/v1.3/, rewrites /docs/next/ links, and registers v1.3 via hack/register_version.sh --release v1.3. next/ is unchanged
  • After release-next, subsequent make update-all RELEASE_TAG=v1.3.1 routes to v1.3/

Releasing a new minor (v1.3.0)

  1. make release-next RELEASE_TAG=v1.3.0 — copies next/ → v1.3/, rewrites internal links, registers v1.3 as the new latest_version_id. next/ stays in place for the next cycle
  2. (optional) make update-all RELEASE_TAG=v1.3.0 — pulls fresh upstream READMEs pinned to the exact tag into v1.3/

Refreshing the trunk from the latest released version

  • make init-next — removes content/en/docs/next/ and reinitializes it from the latest v*/ directory. hack/init_version.sh handles the next/ case specially (sets title to "Cozystack Next (unreleased)", strips aliases, prepends a draft banner shortcode)

OpenAPI per version

  • v0 and v1.0 ship their api.json in git under static/docs/<version>/cozystack-api/api.json
  • v1.1+ are fetched at build time from https://github.com/cozystack/cozystack/releases/download/<tag>/openapi.json by hack/download_openapi.sh (run before hugo --gc --minify). openapi.json is produced as a release asset by the upstream tags workflow (cozystack/cozystack#2214)

How new-version docs arrive

  • Docs updates are pushed by the upstream cozystack/cozystack release workflow (.github/workflows/tags.yaml, update-website-docs job). On every vX.Y.Z tag it checks out this repo at main and opens/updates a PR titled [docs] Update managed apps reference for v<version>
  • Upstream workflow contract:
    • Always calls make update-all RELEASE_TAG=vX.Y.Z — routing (above) picks the right target directory
    • Additionally calls make release-next RELEASE_TAG=vX.Y.Z for new minor/major releases (not patch releases). release-next validates preconditions and fails hard if they aren't met — there is no silent no-op. Detection of "new minor vs patch" is owned by the upstream workflow (explicit conditional), not by the website-side Makefile
  • The website-side make update-* / make template-* / make release-next / make init-next targets and hack/update_apps.sh / hack/fill_templates.sh / hack/download_openapi.sh / hack/release_next.sh are the contract this upstream workflow invokes
  • The previous website-side daily cron (.github/workflows/update-managed-apps.yaml) is obsolete (superseded by the upstream flow from cozystack/cozystack#2214)

Key Config

  • hugo.yaml — main Hugo config including module mounts, menus, params, multi-version setup
  • netlify.toml — Netlify build settings (deploy previews include --buildFuture)
  • package.json — npm deps (Bootstrap, Font Awesome, PostCSS/autoprefixer)

Custom Shortcodes

Located in layouts/shortcodes/: tabs/tab, note, warning, caution, include, youtube, system-resource-calculator, blocks/hero, blocks/resource, blocks/flux_ui_galleries.

Content Conventions

  • Docs synced from upstream have autogenerated notices — don't manually edit those files; update the source in cozystack/cozystack instead
  • Hugo frontmatter uses YAML
  • OSS health app pages use custom layout (layouts/_default/oss-health-app.html) with frontmatter keys: oss_health_key, oss_health_kind, lede, source_url
  • Goldmark rendering has unsafe: true enabled (raw HTML allowed in markdown)