diff --git a/.github/workflows/build_documentation.yml b/.github/workflows/build_documentation.yml deleted file mode 100644 index 4a3c902d7..000000000 --- a/.github/workflows/build_documentation.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Build documentation - -on: - push: - branches: - - main - - doc-builder* - - v*-release - -jobs: - build: - uses: huggingface/doc-builder/.github/workflows/build_main_documentation.yml@7b35a31ae9844db8b177ef3ca869184a79d791f8 # main - with: - commit_sha: ${{ github.sha }} - package: openenv - repo_owner: openenv - version_tag_suffix: "" - secrets: - hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }} diff --git a/.github/workflows/build_pr_documentation.yml b/.github/workflows/build_pr_documentation.yml deleted file mode 100644 index 4f722ef32..000000000 --- a/.github/workflows/build_pr_documentation.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Build PR Documentation - -on: - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build: - if: github.event.pull_request.draft == false - uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@7b35a31ae9844db8b177ef3ca869184a79d791f8 # main - with: - commit_sha: ${{ github.event.pull_request.head.sha }} - pr_number: ${{ github.event.number }} - package: openenv - repo_owner: openenv - version_tag_suffix: "" -# doc-builder registry now provides tomli for the light install diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..daeeba086 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,173 @@ +name: Docs + +# Builds the docs with HF doc-builder and publishes them to GitHub Pages (gh-pages +# branch), with no Hugging Face token: +# - push to main -> /main/ +# - release tag vX.Y.Z -> /vX.Y.Z/ +# - manual run + version -> rebuilds that release from its tag +# - pull request -> build only; docs_pr_preview.yml publishes it to +# /pr-preview/pr-N/ +# docs/pages/ adds the site layout that huggingface.co provides for doc-builder pages. + +on: + push: + branches: + - main + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + pull_request: + paths: + - "docs/**" + - "src/openenv/**" + - "pyproject.toml" + - "uv.lock" + - ".github/workflows/docs.yml" + workflow_dispatch: + inputs: + version: + description: "Release tag to rebuild, e.g. v0.14.0. Leave empty to rebuild main." + required: false + default: "" + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || inputs.version || github.ref }} + cancel-in-progress: true + +env: + # doc-builder commit used for the build. docs_builder_update.yml opens an issue + # when huggingface/doc-builder moves ahead of it. + DOC_BUILDER_SHA: 07d98817a2624c1fe067d4268e1f80d1988cfe71 + # Set the DOCS_SITE_URL repository variable when moving to a custom domain. + ROOT_URL: ${{ vars.DOCS_SITE_URL || 'https://openenv.github.io/OpenEnv' }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + dest: ${{ steps.target.outputs.dest }} + publish: ${{ steps.target.outputs.publish }} + steps: + - name: Pick the target + id: target + env: + EVENT: ${{ github.event_name }} + PR_NUMBER: ${{ github.event.pull_request.number }} + INPUT_VERSION: ${{ inputs.version }} + run: | + if [ "$EVENT" = pull_request ]; then + version=main dest="pr-preview/pr-$PR_NUMBER" label="PR #$PR_NUMBER" ref="$GITHUB_SHA" publish=false noindex=true + elif [ -n "$INPUT_VERSION" ]; then + version="$INPUT_VERSION" dest="$INPUT_VERSION" label="$INPUT_VERSION" ref="refs/tags/$INPUT_VERSION" + elif [ "$GITHUB_REF_TYPE" = tag ]; then + version="$GITHUB_REF_NAME" dest="$GITHUB_REF_NAME" label="$GITHUB_REF_NAME" ref="$GITHUB_SHA" + else + version=main dest=main label=main ref="$GITHUB_SHA" + fi + if [[ ! "$version" =~ ^(main|v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + echo "::error::Not a release tag: $version" + exit 1 + fi + if [ "$EVENT" != pull_request ]; then + # Only main publishes (a manual run from another branch only builds). + if [ "$GITHUB_REF" = refs/heads/main ] || [ "$GITHUB_REF_TYPE" = tag ]; then publish=true; else publish=false; fi + versions_url="$ROOT_URL/versions.json" + fi + { + echo "version=$version" + echo "dest=$dest" + echo "label=$label" + echo "ref=$ref" + echo "publish=$publish" + echo "versions_url=${versions_url:-}" + echo "noindex=${noindex:-}" + } >> "$GITHUB_OUTPUT" + + # doc-builder derives the "Update on GitHub" links from this folder name. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ steps.target.outputs.ref }} + path: OpenEnv + persist-credentials: false + + # Site scripts come from this commit, so older release tags can be rebuilt. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: tools + sparse-checkout: docs/pages + persist-credentials: false + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: huggingface/doc-builder + ref: ${{ env.DOC_BUILDER_SHA }} + path: doc-builder + persist-credentials: false + + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: "20" + + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 + + - name: Install doc-builder and OpenEnv + run: | + uv venv --python 3.11 + uv pip install ./doc-builder "./OpenEnv[core,cli]" + + - name: Build pages with doc-builder + env: + NODE_OPTIONS: --max-old-space-size=6656 + VERSION: ${{ steps.target.outputs.version }} + run: | + source .venv/bin/activate + cd doc-builder + doc-builder build openenv ../OpenEnv/docs/source \ + --build_dir ../build --html --clean --version "$VERSION" \ + --repo_owner openenv --repo_name OpenEnv + + - name: Add the site layout + env: + VERSION: ${{ steps.target.outputs.version }} + DEST: ${{ steps.target.outputs.dest }} + LABEL: ${{ steps.target.outputs.label }} + VERSIONS_URL: ${{ steps.target.outputs.versions_url }} + NOINDEX: ${{ steps.target.outputs.noindex }} + run: | + source .venv/bin/activate + python tools/docs/pages/build_site.py "build/openenv/$VERSION/en" site \ + --site-url "$ROOT_URL/$DEST" --version-label "$LABEL" \ + ${VERSIONS_URL:+--versions-url "$VERSIONS_URL"} ${NOINDEX:+--noindex} + + - name: Compile the stylesheet + run: | + npm ci --prefix doc-builder/kit --no-audit --no-fund + node tools/docs/pages/build_css.mjs doc-builder/kit site site/docs.css + + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: docs-site + path: site + retention-days: 7 + + publish: + needs: build + if: needs.build.outputs.publish == 'true' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: docs-site + path: site + + - name: Publish to gh-pages + env: + DEST: ${{ needs.build.outputs.dest }} + run: docs/pages/publish.sh "$DEST" site diff --git a/.github/workflows/docs_builder_update.yml b/.github/workflows/docs_builder_update.yml new file mode 100644 index 000000000..b32403406 --- /dev/null +++ b/.github/workflows/docs_builder_update.yml @@ -0,0 +1,56 @@ +name: doc-builder update check + +# Dependabot cannot see the doc-builder commit pinned in docs.yml (it is not a +# `uses:` reference), so check it weekly and keep one issue open while +# huggingface/doc-builder main is ahead of the pin. + +on: + schedule: + - cron: "0 7 * * 1" + workflow_dispatch: + +permissions: {} + +jobs: + check: + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + TITLE: "Update the pinned doc-builder commit" + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + sparse-checkout: .github/workflows/docs.yml + sparse-checkout-cone-mode: false + persist-credentials: false + + - name: Compare the pin with doc-builder main + run: | + pinned=$(sed -nE 's/^ *DOC_BUILDER_SHA: ([0-9a-f]{40}).*/\1/p' .github/workflows/docs.yml) + latest=$(gh api repos/huggingface/doc-builder/commits/main --jq .sha) + issue=$(gh issue list -R "$REPO" --state open --search "\"$TITLE\" in:title" \ + --json number,title --jq "map(select(.title == \"$TITLE\")) | .[0].number // empty") + if [ "$pinned" = "$latest" ]; then + echo "doc-builder pin is up to date" + if [ -n "$issue" ]; then + gh issue close "$issue" -R "$REPO" --comment "The pin now matches doc-builder main." + fi + exit 0 + fi + ahead=$(gh api "repos/huggingface/doc-builder/compare/$pinned...$latest" --jq .ahead_by) + body="huggingface/doc-builder main is $ahead commit(s) ahead of the commit pinned in \`.github/workflows/docs.yml\`. + + - Pinned: \`$pinned\` + - Latest: \`$latest\` + - Changes: https://github.com/huggingface/doc-builder/compare/$pinned...$latest + + To update, set \`DOC_BUILDER_SHA\` in \`.github/workflows/docs.yml\` to the latest commit and check the docs preview on the pull request. This issue closes on its own once the pin matches." + if [ -n "$issue" ]; then + gh issue edit "$issue" -R "$REPO" --body "$body" + else + gh issue create -R "$REPO" --title "$TITLE" --body "$body" + fi diff --git a/.github/workflows/docs_pr_preview.yml b/.github/workflows/docs_pr_preview.yml new file mode 100644 index 000000000..ec45e7b36 --- /dev/null +++ b/.github/workflows/docs_pr_preview.yml @@ -0,0 +1,124 @@ +name: Docs PR preview + +# Publishes the docs built by docs.yml for a pull request to +# /pr-preview/pr-N/ and removes them when the pull request closes. +# +# docs.yml builds pull requests without write access (forks included). This +# workflow runs from main with write access and never runs pull request code: it +# only copies the static files the build uploaded. Previews are served from the +# docs domain, so pull requests from outside contributors are published only +# after a maintainer adds the docs-preview label and re-runs their Docs check. +# The label is removed once used, so each new commit needs a new review. + +on: + workflow_run: + workflows: [Docs] + types: [completed] + pull_request_target: + types: [closed] + +permissions: {} + +# Publishing and removing the preview of the same pull request run one at a time, +# so a preview published while its pull request closes is still removed. +concurrency: + group: >- + ${{ github.workflow }}-${{ github.event.workflow_run.head_repository.full_name || github.event.pull_request.head.repo.full_name }}:${{ github.event.workflow_run.head_branch || github.event.pull_request.head.ref }} + cancel-in-progress: false + +jobs: + publish: + if: >- + github.event_name == 'workflow_run' && + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + permissions: + actions: read + contents: write + pull-requests: write + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + ROOT_URL: ${{ vars.DOCS_SITE_URL || 'https://openenv.github.io/OpenEnv' }} + steps: + - name: Find the pull request + id: pr + env: + HEAD_OWNER: ${{ github.event.workflow_run.head_repository.owner.login }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + run: | + pr=$(gh api -X GET "repos/$REPO/pulls" -f state=open -f head="$HEAD_OWNER:$HEAD_BRANCH" \ + | jq --arg sha "$HEAD_SHA" 'map(select(.head.sha == $sha)) | first // empty') + if [ -z "$pr" ]; then + echo "No open pull request at $HEAD_SHA (closed or pushed again)." + exit 0 + fi + echo "number=$(jq -r .number <<<"$pr")" >> "$GITHUB_OUTPUT" + jq -r --arg repo "$REPO" ' + (.head.repo.full_name == $repo or (.author_association | IN("OWNER", "MEMBER", "COLLABORATOR"))) as $member + | any(.labels[]; .name == "docs-preview") as $label + | "trusted=\($member or $label)\nlabel_only=\(($member | not) and $label)" + ' <<<"$pr" >> "$GITHUB_OUTPUT" + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: steps.pr.outputs.trusted == 'true' + + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + if: steps.pr.outputs.trusted == 'true' + with: + name: docs-site + path: site + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Publish the preview + if: steps.pr.outputs.trusted == 'true' + env: + NUMBER: ${{ steps.pr.outputs.number }} + run: docs/pages/publish.sh "pr-preview/pr-$NUMBER" site + + # The label approves one commit: later pushes need a maintainer to add it again. + - name: Remove the docs-preview label + if: steps.pr.outputs.label_only == 'true' + env: + NUMBER: ${{ steps.pr.outputs.number }} + run: gh api -X DELETE "repos/$REPO/issues/$NUMBER/labels/docs-preview" >/dev/null + + - name: Comment on the pull request + if: steps.pr.outputs.number != '' + env: + NUMBER: ${{ steps.pr.outputs.number }} + TRUSTED: ${{ steps.pr.outputs.trusted }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + run: | + marker="" + if [ "$TRUSTED" = true ]; then + body="$marker + The docs for this pull request are available at $ROOT_URL/pr-preview/pr-$NUMBER/ (commit ${HEAD_SHA:0:7}). The preview may take a minute to update and is removed when the pull request closes." + else + body="$marker + The docs for this pull request built successfully. A maintainer can publish a preview of this commit by adding the \`docs-preview\` label and re-running the Docs check." + fi + id=$(gh api --paginate "repos/$REPO/issues/$NUMBER/comments" \ + --jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -n 1) + if [ -n "$id" ]; then + gh api -X PATCH "repos/$REPO/issues/comments/$id" -f body="$body" >/dev/null + else + gh api "repos/$REPO/issues/$NUMBER/comments" -f body="$body" >/dev/null + fi + + remove: + if: github.event_name == 'pull_request_target' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + # Checks out main, not the pull request. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Remove the preview + env: + NUMBER: ${{ github.event.pull_request.number }} + run: docs/pages/publish.sh "pr-preview/pr-$NUMBER" diff --git a/.github/workflows/upload_pr_documentation.yml b/.github/workflows/upload_pr_documentation.yml deleted file mode 100644 index 53c067b76..000000000 --- a/.github/workflows/upload_pr_documentation.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Upload PR Documentation - -on: - workflow_run: - workflows: ["Build PR Documentation"] - types: - - completed - -jobs: - build: - uses: huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml@7b35a31ae9844db8b177ef3ca869184a79d791f8 # main - with: - package_name: openenv - repo_owner: openenv - secrets: - hf_token: ${{ secrets.HF_DOC_BUILD_PUSH }} - comment_bot_app_id: ${{ secrets.COMMENT_BOT_APP_ID }} - comment_bot_secret_pem: ${{ secrets.COMMENT_BOT_SECRET_PEM }} diff --git a/docs/README.md b/docs/README.md index afbab3d9e..656e0c3c8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -26,6 +26,29 @@ doc-builder preview openenv docs/source Then open the URL printed in the terminal and navigate to `/index` (usually `http://localhost:5173/index`). +## Publishing to GitHub Pages + +The docs are built with doc-builder in GitHub Actions and published to GitHub Pages from the `gh-pages` branch, with no Hugging Face token: + +| Trigger | Published at | +|---|---| +| Push to `main` | `https://openenv.github.io/OpenEnv/main/` | +| Release tag `vX.Y.Z` | `https://openenv.github.io/OpenEnv/vX.Y.Z/` | +| Pull request | `https://openenv.github.io/OpenEnv/pr-preview/pr-N/`, linked from a comment on the PR and removed when it closes | + +The site root redirects to `main`, and the version picker in the header lists `main` and every published release. To publish an older release, run the **Docs** workflow from `main` with its tag as `version`. + +Pull requests from outside contributors build without write access and get a preview only after a maintainer adds the `docs-preview` label and re-runs the PR's **Docs** check, since previews are served from the docs domain. The label is removed once the preview is published, so each new commit needs a new review. + +How it fits together: + +- [`docs.yml`](../.github/workflows/docs.yml) builds the docs and publishes `main` and releases. +- [`docs_pr_preview.yml`](../.github/workflows/docs_pr_preview.yml) publishes and removes PR previews. It runs from `main` and only copies the files the PR build uploaded. +- [`docs_builder_update.yml`](../.github/workflows/docs_builder_update.yml) checks every week whether `huggingface/doc-builder` moved ahead of the commit pinned in `docs.yml` and keeps an issue open until the pin is updated. +- doc-builder renders each page as a fragment that huggingface.co wraps in its own layout, so [`docs/pages/`](pages/) adds that layout. `build_site.py` wraps each page with a sidebar from `_toctree.yml`, an "On this page" list, the version picker and redirect pages from `_redirects.yml`. `build_css.mjs` compiles the doc-builder stylesheet, which doc-builder leaves empty in production builds. `shell.css` styles the layout and the code highlighting. `publish.sh` updates one folder of `gh-pages`. + +To build the site locally, clone [doc-builder](https://github.com/huggingface/doc-builder) at the commit pinned in `docs.yml` next to this repo and run the steps of the `build` job. + ## Adding an Environment to the Docs Every environment page is generated from the environment's own `README.md`. There are three steps: diff --git a/docs/pages/apple-touch-icon.png b/docs/pages/apple-touch-icon.png new file mode 100644 index 000000000..c1da695f3 Binary files /dev/null and b/docs/pages/apple-touch-icon.png differ diff --git a/docs/pages/build_css.mjs b/docs/pages/build_css.mjs new file mode 100644 index 000000000..9b23865bd --- /dev/null +++ b/docs/pages/build_css.mjs @@ -0,0 +1,47 @@ +// Compile the doc-builder kit stylesheet for the standalone GitHub Pages site. +// +// doc-builder empties every CSS file in production builds (kit/postcss.config.cjs) +// because huggingface.co injects its own Tailwind. Outside the Hub we need that +// CSS back, so this script runs the kit's own `src/app.css` through Tailwind, +// scanning the already built pages so only the classes in use are emitted. +// +// Usage: node build_css.mjs +// The kit's node_modules must be installed (`npm ci` inside the kit). + +import { readFileSync, writeFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import path from "node:path"; + +const [kitArg, siteArg, outArg] = process.argv.slice(2); +if (!kitArg || !siteArg || !outArg) { + console.error("usage: node build_css.mjs "); + process.exit(2); +} +const kitDir = path.resolve(kitArg); +const siteDir = path.resolve(siteArg); +const outFile = path.resolve(outArg); + +// Resolve postcss and plugins from the kit's node_modules, not from this repo. +const kitRequire = createRequire(path.join(kitDir, "package.json")); +const postcss = kitRequire("postcss"); +const tailwind = kitRequire("@tailwindcss/postcss"); +const autoprefixer = kitRequire("autoprefixer"); + +const entry = path.join(kitDir, "src", "app.css"); +let css = readFileSync(entry, "utf8"); + +// The kit scans `./routes`, which only exists while doc-builder builds. +// Scan the built HTML and JS chunks instead. +const sourceLine = '@source "./routes";'; +if (!css.includes(sourceLine)) { + console.error(`expected ${sourceLine} in ${entry}; the kit changed, update this script`); + process.exit(1); +} +css = css.replace(sourceLine, `@source "${siteDir.replaceAll("\\", "/")}";`); + +const result = await postcss([tailwind({ base: kitDir }), autoprefixer]).process(css, { + from: entry, + to: outFile, +}); +writeFileSync(outFile, result.css); +console.log(`wrote ${outFile} (${(result.css.length / 1024).toFixed(0)} KiB)`); diff --git a/docs/pages/build_site.py b/docs/pages/build_site.py new file mode 100644 index 000000000..a3ac30cd7 --- /dev/null +++ b/docs/pages/build_site.py @@ -0,0 +1,314 @@ +"""Turn a doc-builder HTML build into a standalone static site for GitHub Pages. + +doc-builder renders each page as a fragment that huggingface.co wraps in its own +shell (navbar, sidebar, styles). This script adds that shell: a full HTML +document per page with a sidebar built from `_toctree.yml`, an "On this page" +list, the stylesheet compiled by `build_css.mjs`, and redirect pages from +`_redirects.yml`. + +Usage: + python docs/pages/build_site.py \ + --site-url https://openenv.github.io/OpenEnv/main --version-label main \ + --versions-url https://openenv.github.io/OpenEnv/versions.json +""" + +import argparse +import dataclasses +import html +import json +import re +import shutil +from pathlib import Path +from urllib.parse import urlparse + +import yaml + +REPO_URL = "https://github.com/openenv/OpenEnv" +SHELL_DIR = Path(__file__).parent + +METADATA_RE = re.compile(r'') +CSS_PRELOAD_RE = re.compile(r'\n?') +PARAGRAPH_RE = re.compile(r"]*>(.*?)

", re.S) +# Icons and social card, copied to the site root. +ASSETS = ["favicon.svg", "favicon.png", "apple-touch-icon.png", "og-image.png"] + + +@dataclasses.dataclass +class Site: + url: str # e.g. https://openenv.github.io/OpenEnv/main + base: str # URL path of the site, e.g. /OpenEnv/main + toctree: list + version: str + versions_url: str | None + noindex: bool + + +def page_url(base: str, local: str) -> str: + return f"{base}/" if local == "index" else f"{base}/{local}" + + +def render_sidebar( + sections: list, base: str, current: str, nested: bool = False +) -> tuple[str, bool]: + """Returns the sidebar HTML for `sections` and whether it contains `current`. + + Top-level sections follow `isExpanded`, groups inside them open only around the + current page. + """ + items, has_current = [], False + for section in sections: + if "sections" in section: + inner, inner_current = render_sidebar( + section["sections"], base, current, nested=True + ) + has_current |= inner_current + is_open = inner_current or (not nested and section.get("isExpanded", True)) + items.append( + f"
  • " + f"{html.escape(section['title'])}{inner}
  • " + ) + else: + is_current = section["local"] == current + has_current |= is_current + items.append( + f'
  • " + f"{html.escape(section['title'])}
  • " + ) + return f"
      {''.join(items)}
    ", has_current + + +def render_toc(sections: list) -> str: + items = [] + for section in sections: + sub = render_toc(section["sections"]) if section.get("depth", 2) < 3 else "" + items.append( + f'
  • {html.escape(section["title"])}{sub}
  • ' + ) + return f"
      {''.join(items)}
    " if items else "" + + +# The OpenEnv cube, drawn like favicon.svg. +LOGO = """""" + +# doc-builder's "Copy page" menu links to the page URL + ".md" and fetches the page URL +# with "Accept: text/plain", which huggingface.co answers with markdown. GitHub Pages +# serves files, so give the index page its /index URL (doc-builder's route for it) and +# send that fetch to the page's .md file. Runs before the page hydrates. +MARKDOWN_SCRIPT = """""" + +VERSION_SCRIPT = """""" + + +def render_version(version: str, versions_url: str | None, local: str) -> str: + """Version picker when the site lists its versions, a plain label otherwise.""" + if not versions_url: + return f'{html.escape(version)}' + page = "" if local in {"index", "404"} else local + return ( + f'" + ) + + +def page_description(fragment: str) -> str: + """First paragraph of the page as plain text, for search and link previews.""" + for paragraph in PARAGRAPH_RE.findall(fragment): + text = " ".join(html.unescape(re.sub(r"<[^>]+>", "", paragraph)).split()) + if text: + return text if len(text) <= 200 else text[:197].rsplit(" ", 1)[0] + "..." + return "" + + +def render_page(fragment: str, local: str, site: Site) -> str: + match = METADATA_RE.search(fragment) + metadata = json.loads(html.unescape(match.group(1))) if match else {} + title = metadata.get("title", "OpenEnv") + if "OpenEnv" not in title: + title = f"{title} | OpenEnv" + title = html.escape(title) + description = html.escape(page_description(fragment)) + base = site.base + sidebar, _ = render_sidebar(site.toctree, base, local) + toc = render_toc(metadata.get("sections", [])) + toc_block = ( + f'' if toc else "" + ) + # The kit's CSS files are empty in production builds, build_css.mjs compiles the real one. + fragment = CSS_PRELOAD_RE.sub("", fragment) + return f""" + + + + +{title} + +{'' if site.noindex else ""} + + + + + + + + + + + + + + + +{MARKDOWN_SCRIPT} + + + + +
    + +
    +
    +{fragment} +
    + +
    +{toc_block} +
    +{VERSION_SCRIPT if site.versions_url else ""} + + +""" + + +def redirect_page(target: str) -> str: + return f""" + +Redirecting + + +Moved to {target} +""" + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument( + "build_dir", type=Path, help="doc-builder output, e.g. build/openenv/main/en" + ) + parser.add_argument("output_dir", type=Path) + parser.add_argument( + "--site-url", required=True, help="e.g. https://openenv.github.io/OpenEnv" + ) + parser.add_argument( + "--version-label", default="main", help="e.g. main, v0.15.0, PR #12" + ) + parser.add_argument( + "--versions-url", help="versions.json listing the published versions" + ) + parser.add_argument( + "--noindex", action="store_true", help="keep search engines out (PR previews)" + ) + args = parser.parse_args() + site_url = args.site_url.rstrip("/") + base = urlparse(site_url).path + # doc-builder writes to /openenv//en and links pages under the + # same path on huggingface.co. + version = args.build_dir.resolve().parent.name + doc_builder_base = f"/docs/openenv/{version}/en" + hub_docs_url = f"https://huggingface.co/docs/openenv/{version}" + + shutil.rmtree(args.output_dir, ignore_errors=True) + shutil.copytree(args.build_dir, args.output_dir) + out = args.output_dir + site = Site( + url=site_url, + base=base, + toctree=yaml.safe_load((out / "_toctree.yml").read_text()), + version=args.version_label, + versions_url=args.versions_url, + noindex=args.noindex, + ) + + for path in out.rglob("*"): + if path.suffix in {".md", ".txt"}: + text = path.read_text(encoding="utf-8") + text = text.replace(hub_docs_url, site_url).replace( + doc_builder_base, site_url + ) + path.write_text(text, encoding="utf-8") + if path.suffix not in {".html", ".js"}: + continue + text = path.read_text(encoding="utf-8").replace(doc_builder_base, base) + if path.suffix == ".html": + local = path.relative_to(out).with_suffix("").as_posix() + text = render_page(text, local, site) + path.write_text(text, encoding="utf-8") + + redirects = yaml.safe_load((out / "_redirects.yml").read_text()) or {} + for source, target in redirects.items(): + page = out / f"{source}.html" + if not page.exists(): + page.parent.mkdir(parents=True, exist_ok=True) + page.write_text(redirect_page(page_url(base, target)), encoding="utf-8") + + (out / "404.html").write_text( + render_page( + "

    Page not found

    This page does not exist. " + f'Go back to the OpenEnv docs.

    ', + "404", + site, + ), + encoding="utf-8", + ) + for name in ["shell.css", *ASSETS]: + shutil.copy(SHELL_DIR / name, out / name) + (out / ".nojekyll").touch() + print(f"site written to {out}") + + +if __name__ == "__main__": + main() diff --git a/docs/pages/favicon.png b/docs/pages/favicon.png new file mode 100644 index 000000000..64143a1b5 Binary files /dev/null and b/docs/pages/favicon.png differ diff --git a/docs/pages/favicon.svg b/docs/pages/favicon.svg new file mode 100644 index 000000000..f420b091f --- /dev/null +++ b/docs/pages/favicon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docs/pages/og-image.png b/docs/pages/og-image.png new file mode 100644 index 000000000..8282ae979 Binary files /dev/null and b/docs/pages/og-image.png differ diff --git a/docs/pages/publish.sh b/docs/pages/publish.sh new file mode 100755 index 000000000..692ecb456 --- /dev/null +++ b/docs/pages/publish.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# Publish a built docs site to a folder of the gh-pages branch, or remove that folder. +# +# publish.sh main site/ # docs for main +# publish.sh v0.15.0 site/ # docs for a release +# publish.sh pr-preview/pr-123 site/ # PR preview +# publish.sh pr-preview/pr-123 # remove a PR preview +# +# Run from a checkout of this repo whose credentials can push. gh-pages is kept as +# a single commit so it does not grow with every publish. --force-with-lease makes +# concurrent publishes retry on top of each other instead of overwriting. +set -euo pipefail + +dest=$1 +site=${2:-} +if [[ ! "$dest" =~ ^(main|v[0-9]+\.[0-9]+\.[0-9]+|pr-preview/pr-[0-9]+)$ ]]; then + echo "refusing to publish to '$dest'" >&2 + exit 1 +fi +if [ -n "$site" ]; then + site=$(cd "$site" && pwd) +fi + +pages=$(mktemp -d)/gh-pages +git config user.name "github-actions[bot]" +git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + +for attempt in 1 2 3 4 5; do + git worktree remove --force "$pages" 2>/dev/null || true + if git ls-remote --exit-code --heads origin gh-pages >/dev/null; then + git fetch --quiet --depth 1 origin gh-pages + lease=$(git rev-parse FETCH_HEAD) + git worktree add --quiet --detach "$pages" FETCH_HEAD + else + lease="" + git worktree add --quiet --detach "$pages" + git -C "$pages" rm -rq --ignore-unmatch . + fi + + rm -rf "${pages:?}/$dest" + if [ -n "$site" ]; then + mkdir -p "$(dirname "$pages/$dest")" + cp -R "$site" "$pages/$dest" + fi + + # Root files: version list for the version picker, redirect to main, shared 404. + python3 - "$pages" <<'EOF' +import json, re, shutil, sys +from pathlib import Path + +pages = Path(sys.argv[1]) +releases = [p.name for p in pages.iterdir() if re.fullmatch(r"v\d+\.\d+\.\d+", p.name)] +releases.sort(key=lambda v: [int(x) for x in v[1:].split(".")], reverse=True) +versions = (["main"] if (pages / "main").is_dir() else []) + releases +(pages / "versions.json").write_text(json.dumps(versions) + "\n") +(pages / "index.html").write_text( + '\n\nOpenEnv docs\n' + '\nOpenEnv docs\n' +) +if (pages / "main" / "404.html").exists(): + shutil.copy(pages / "main" / "404.html", pages / "404.html") +(pages / ".nojekyll").touch() +EOF + + git -C "$pages" add -A + tree=$(git -C "$pages" write-tree) + if [ -n "$lease" ] && [ "$tree" = "$(git rev-parse "$lease^{tree}")" ]; then + echo "gh-pages already up to date" + exit 0 + fi + commit=$(git commit-tree "$tree" -m "Publish docs ($dest)") + if git push --force-with-lease="refs/heads/gh-pages:$lease" origin "$commit:refs/heads/gh-pages"; then + echo "updated $dest" + exit 0 + fi + echo "gh-pages moved, retrying ($attempt)" + sleep $((attempt * 5)) +done +echo "could not publish $dest" >&2 +exit 1 diff --git a/docs/pages/shell.css b/docs/pages/shell.css new file mode 100644 index 000000000..7ce751c10 --- /dev/null +++ b/docs/pages/shell.css @@ -0,0 +1,519 @@ +/* Shell around the doc-builder pages: header, sidebar, "On this page" list, + footer and code colors. The page content itself is styled by docs.css + (build_css.mjs), adjusted below. The look follows the OpenEnv logo, a + wireframe cube: monochrome, hairline borders and nearly square corners. */ + +:root { + --shell-bg: #ffffff; + --shell-fg: #0a0a0a; + --shell-text: #3f3f3f; + --shell-muted: #6b6b6b; + --shell-border: #e6e6e6; + --shell-code-border: #d4d4d4; + --shell-hover: #f5f5f5; + --hl-keyword: #cf222e; + --hl-string: #0a3069; + --hl-number: #0550ae; + --hl-comment: #6e7781; + --hl-title: #8250df; + --hl-builtin: #953800; + /* doc-builder's grays are slightly blue, use neutral ones. */ + --color-gray-50: oklch(98.5% 0 0); + --color-gray-100: oklch(97% 0 0); + --color-gray-200: oklch(92.2% 0 0); + --color-gray-300: oklch(87% 0 0); + --color-gray-400: oklch(70.8% 0 0); + --color-gray-500: oklch(55.6% 0 0); + --color-gray-600: oklch(43.9% 0 0); + --color-gray-700: oklch(37.1% 0 0); + --color-gray-800: oklch(26.9% 0 0); + --color-gray-900: oklch(20.5% 0 0); + --color-gray-950: oklch(14.5% 0 0); +} + +html.dark { + --shell-bg: #000000; + --shell-fg: #f2f2f2; + --shell-text: #b8b8b8; + --shell-muted: #8f8f8f; + --shell-border: #242424; + --shell-code-border: #333333; + --shell-hover: #0d0d0d; + --hl-keyword: #ff7b72; + --hl-string: #a5d6ff; + --hl-number: #79c0ff; + --hl-comment: #8b949e; + --hl-title: #d2a8ff; + --hl-builtin: #ffa657; +} + +/* Keep anchor targets below the sticky header. */ +html { + scroll-padding-top: 4rem; +} + +html, +body { + margin: 0; + background: var(--shell-bg); + color: var(--shell-fg); + font-family: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif; +} + +/* Header */ + +.site-header { + position: sticky; + top: 0; + z-index: 20; + display: flex; + align-items: center; + gap: 1rem; + height: 3.5rem; + padding: 0 1rem; + background: var(--shell-bg); + border-bottom: 1px solid var(--shell-border); +} + +.site-header a { + color: var(--shell-fg); + text-decoration: none; +} + +/* Regular weight, like the wordmark in the logo. */ +.site-title { + display: flex; + align-items: center; + gap: 0.55rem; + font-size: 1.2rem; + font-weight: 400; +} + +.site-title svg { + width: 1.5rem; + height: 1.5rem; +} + +.version-select, +.version-badge { + border: 1px solid var(--shell-border); + border-radius: 2px; + background: var(--shell-bg); + color: var(--shell-muted); + padding: 0.1rem 0.5rem; + font-size: 0.85rem; +} + +.version-select { + width: auto; + padding-right: 2rem; +} + +.site-header .spacer { + flex: 1; +} + +.site-header button { + border: 1px solid var(--shell-border); + border-radius: 2px; + background: none; + color: var(--shell-fg); + padding: 0.15rem 0.5rem; + font-size: 1rem; +} + +.menu-button { + display: none; +} + +/* Layout */ + +.site-layout { + display: flex; + align-items: flex-start; +} + +.site-nav, +.page-toc { + position: sticky; + top: 3.5rem; + flex-shrink: 0; + max-height: calc(100vh - 3.5rem); + overflow-y: auto; + box-sizing: border-box; + font-size: 0.94rem; +} + +.site-main { + flex: 1; + min-width: 0; + padding: 1.5rem 1.5rem 4rem; +} + +/* About 85 characters per line. */ +.site-main .prose.prose-doc { + max-width: 46rem; + color: var(--shell-text); +} + +/* Sidebar */ + +.site-nav { + width: 270px; + padding: 1rem 0.75rem 2rem; + border-right: 1px solid var(--shell-border); +} + +.site-nav ul, +.page-toc ul { + list-style: none; + margin: 0; + padding: 0; +} + +.site-nav ul ul { + padding-left: 0.75rem; +} + +.site-nav summary { + cursor: pointer; + list-style: none; + padding: 0.3rem 0.5rem; +} + +.site-nav summary::-webkit-details-marker { + display: none; +} + +.site-nav summary::after { + content: "+"; + float: right; + color: var(--shell-muted); + font-weight: 400; +} + +.site-nav details[open] > summary::after { + content: "\2212"; +} + +/* Sections: small capitals. Groups inside them: like a page, one step quieter. */ +.site-nav > ul > li > details > summary { + margin-top: 0.75rem; + color: var(--shell-fg); + font-size: 0.72rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.08em; +} + +.site-nav details details > summary { + color: var(--shell-muted); + font-weight: 500; +} + +/* Pages hang from a thin line, like the edge of the cube. */ +.site-nav a { + display: block; + padding: 0.25rem 0.75rem; + border-left: 1px solid var(--shell-border); + color: var(--shell-muted); + text-decoration: none; +} + +.site-nav a:hover { + color: var(--shell-fg); + border-left-color: var(--shell-muted); +} + +.site-nav a[aria-current="page"] { + border-left: 2px solid var(--shell-fg); + padding-left: calc(0.75rem - 1px); + color: var(--shell-fg); + font-weight: 600; +} + +/* On this page */ + +.page-toc { + width: 250px; + padding: 1.5rem 1rem; +} + +.page-toc p { + margin: 0 0 0.5rem; + font-weight: 600; +} + +.page-toc > ul { + border-left: 1px solid var(--shell-border); + padding-left: 0.75rem; +} + +.page-toc ul ul { + padding-left: 0.75rem; +} + +.page-toc a { + display: block; + padding: 0.15rem 0; + color: var(--shell-muted); + text-decoration: none; +} + +.page-toc a:hover { + color: var(--shell-fg); +} + +/* Footer */ + +.site-footer { + display: flex; + flex-wrap: wrap; + gap: 0.5rem 1.5rem; + max-width: 46rem; + margin: 4rem auto 0; + padding-top: 1rem; + border-top: 1px solid var(--shell-border); + color: var(--shell-muted); + font-size: 0.85rem; +} + +.site-footer a { + color: var(--shell-muted); +} + +.site-footer a:hover { + color: var(--shell-fg); +} + +/* Content: headings */ + +.prose.prose-doc :is(h1, h2, h3, h4, h5, th, strong) { + color: var(--shell-fg); +} + +.prose.prose-doc h1 { + font-size: 2rem; + font-weight: 600; + letter-spacing: -0.02em; + line-height: 1.2; +} + +/* Each section starts on a hairline, like an edge of the cube. */ +.prose.prose-doc h2 { + margin-top: 2.75rem; + padding-top: 1.25rem; + border-top: 1px solid var(--shell-border); + font-size: 1.375rem; + letter-spacing: -0.01em; +} + +.prose.prose-doc h3 { + font-size: 1.125rem; +} + +.prose.prose-doc > p > em { + color: var(--shell-muted); +} + +/* Content: links and code */ + +/* Links in the text color, with a thin underline that thickens on hover. */ +.prose.prose-doc a:not(.header-link) { + color: var(--shell-fg); + text-decoration-thickness: 1px; + text-underline-offset: 3px; +} + +.prose.prose-doc a:not(.header-link):hover { + text-decoration-thickness: 2px; +} + +/* Inline code outlined instead of filled. */ +.prose.prose-doc :not(pre) > code { + border: 1px solid var(--shell-code-border); + border-radius: 2px; + padding: 0.05em 0.3em; + background: none; + color: var(--shell-fg); +} + +.prose.prose-doc pre, +.prose.prose-doc .code-block pre { + border: 1px solid var(--shell-border); + border-radius: 2px; +} + +html.dark .prose.prose-doc pre { + background: #0a0a0a; +} + +/* Content: tables, cards and buttons with hairlines and nearly square corners */ + +.prose.prose-doc table { + display: table; + width: auto; + border-collapse: collapse; + border: 1px solid var(--shell-border); +} + +.prose.prose-doc :is(th, td) { + border-bottom: 1px solid var(--shell-border); + padding: 0.5rem 0.75rem; +} + +.prose.prose-doc :is(.rounded, .rounded-md, .rounded-lg, .rounded-xl) { + border-radius: 2px; +} + +.prose.prose-doc .shadow { + box-shadow: none; +} + +.prose.prose-doc :is(div, a).border { + border-color: var(--shell-border); +} + +.prose.prose-doc div.border:hover { + border-color: var(--shell-fg); +} + +/* Notes, tips and important notes in monochrome, warnings keep their color. + doc-builder sets these colors with !important. */ +.prose.prose-doc :is(.note, .tip, .important) { + border-left: 2px solid var(--shell-fg) !important; + border-radius: 0; + background: var(--shell-hover) !important; + color: var(--shell-fg) !important; +} + +.prose.prose-doc :is(.note, .tip, .important) a { + color: var(--shell-fg) !important; +} + +/* Content: API reference, square boxes without color gradients */ + +.prose.prose-doc .docstring { + border-width: 1px 0 0 1px; + border-color: var(--shell-border); + border-top-left-radius: 0; +} + +.prose.prose-doc .docstring .rounded-xl { + background-image: none; + color: var(--shell-fg); +} + +.prose.prose-doc .docstring .md\:text-lg.rounded-xl { + border: 1px solid var(--shell-border); +} + +/* "Parameters" and "Returns" labels use a dark gray meant for light mode. */ +html.dark .prose.prose-doc .docstring .text-gray-800 { + color: var(--shell-muted); +} + +/* Home page: the cube next to the introduction, drawn like the logo. */ +.prose.prose-doc .hero { + min-height: 150px; + padding-right: 170px; + background: no-repeat right center / 140px + url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='none' stroke='%230a0a0a' stroke-linejoin='round'%3E%3Cpath stroke-width='1.5' opacity='.35' d='M66.5 84.3V204.3M97 100.7V220.7M36 108L127.5 157M36 148L127.5 197M158 100.7V220.7M188.5 84.3V204.3M127.5 157L219 108M127.5 197L219 148M66.5 51.7L158 100.7M97 35.3L188.5 84.3M66.5 84.3L158 35.3M97 100.7L188.5 51.7'/%3E%3Cpath stroke-width='4' d='M127.5 19L219 68V188L127.5 237L36 188V68ZM36 68L127.5 117L219 68M127.5 117V237'/%3E%3C/svg%3E"); +} + +html.dark .prose.prose-doc .hero { + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='none' stroke='%23f2f2f2' stroke-linejoin='round'%3E%3Cpath stroke-width='1.5' opacity='.35' d='M66.5 84.3V204.3M97 100.7V220.7M36 108L127.5 157M36 148L127.5 197M158 100.7V220.7M188.5 84.3V204.3M127.5 157L219 108M127.5 197L219 148M66.5 51.7L158 100.7M97 35.3L188.5 84.3M66.5 84.3L158 35.3M97 100.7L188.5 51.7'/%3E%3Cpath stroke-width='4' d='M127.5 19L219 68V188L127.5 237L36 188V68ZM36 68L127.5 117L219 68M127.5 117V237'/%3E%3C/svg%3E"); +} + +.prose.prose-doc .hero__subtitle { + font-size: 1.2rem; + color: var(--shell-fg); +} + +/* doc-builder's "Connect to MCP Client" entry points to the huggingface.co docs server, + which does not serve these docs. */ +a[href="https://huggingface.co/mcp"] { + display: none; +} + +/* Code highlighting */ + +.hljs-keyword, +.hljs-selector-tag, +.hljs-meta .hljs-keyword { + color: var(--hl-keyword); +} + +.hljs-string, +.hljs-regexp, +.hljs-attr { + color: var(--hl-string); +} + +.hljs-number, +.hljs-literal, +.hljs-variable, +.hljs-params { + color: var(--hl-number); +} + +.hljs-comment, +.hljs-quote { + color: var(--hl-comment); + font-style: italic; +} + +.hljs-title, +.hljs-section, +.hljs-name { + color: var(--hl-title); +} + +.hljs-built_in, +.hljs-type, +.hljs-symbol { + color: var(--hl-builtin); +} + +@media (max-width: 1200px) { + .page-toc { + display: none; + } +} + +@media (max-width: 768px) { + .menu-button { + display: inline-block; + } + + .site-nav { + display: none; + position: fixed; + top: 3.5rem; + left: 0; + bottom: 0; + z-index: 10; + width: 100%; + max-height: none; + background: var(--shell-bg); + } + + body.nav-open .site-nav { + display: block; + } + + .site-main { + padding: 1rem 1rem 3rem; + } + + /* Code blocks line up with the text instead of bleeding into the margin. */ + .prose.prose-doc .code-block { + margin-inline: 0; + } + + .prose.prose-doc .hero { + padding-right: 0; + background-image: none !important; + min-height: 0; + } +} diff --git a/tests/scripts/test_docs_pages_build_site.py b/tests/scripts/test_docs_pages_build_site.py new file mode 100644 index 000000000..03280b5ba --- /dev/null +++ b/tests/scripts/test_docs_pages_build_site.py @@ -0,0 +1,60 @@ +"""Regression checks for the GitHub Pages docs site built from doc-builder output.""" + +import importlib.util +import sys +from pathlib import Path + +import pytest + +spec = importlib.util.spec_from_file_location( + "build_site", Path(__file__).parents[2] / "docs" / "pages" / "build_site.py" +) +build_site = importlib.util.module_from_spec(spec) +spec.loader.exec_module(build_site) + + +@pytest.mark.parametrize("version", ["main", "v1.2.3"]) +def test_rewrites_doc_builder_paths_for_every_version(tmp_path, monkeypatch, version): + build = tmp_path / "build" / "openenv" / version / "en" + (build / "_app").mkdir(parents=True) + hub_base = f"/docs/openenv/{version}/en" + (build / "_toctree.yml").write_text( + "- title: Get Started\n sections:\n - local: index\n title: Overview\n" + ) + (build / "_redirects.yml").write_text("old-page: index\n") + (build / "index.html").write_text( + '' + "

    OpenEnv runs agentic environments.

    " + f'core' + f'' + ) + (build / "_app" / "start.js").write_text(f'const base = "{hub_base}";') + (build / "llms.txt").write_text( + f"- [Overview](https://huggingface.co/docs/openenv/{version}/index.md)\n" + ) + out = tmp_path / "site" + site_url = f"https://example.github.io/OpenEnv/{version}" + monkeypatch.setattr( + sys, "argv", ["build_site.py", str(build), str(out), "--site-url", site_url] + ) + + build_site.main() + + for path in out.rglob("*"): + if path.suffix in {".html", ".js", ".md", ".txt"}: + assert "/docs/openenv/" not in path.read_text(), path + page = (out / "index.html").read_text() + assert f'href="/OpenEnv/{version}/reference/core#x"' in page + assert f'import("/OpenEnv/{version}/_app/start.js")' in page + assert 'class="site-nav"' in page + assert f'"/OpenEnv/{version}"' in (out / "_app" / "start.js").read_text() + assert f"{site_url}/index.md" in (out / "llms.txt").read_text() + assert f"url=/OpenEnv/{version}/" in (out / "old-page.html").read_text() + assert ( + '' in page + ) + assert f'' in page + assert 'name="robots"' not in page + # Copy page / View as Markdown use the .md files, not huggingface.co's Accept header. + assert 'input = page + ".md"' in page + assert (out / "favicon.svg").exists() and (out / "og-image.png").exists()