a
b
Title
", + head='x
diff --git a/bin/docs-markdown b/bin/docs-markdown new file mode 100755 index 0000000000000..a61bf653fe201 --- /dev/null +++ b/bin/docs-markdown @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Copyright Materialize, Inc. and contributors. All rights reserved. +# +# Use of this software is governed by the Business Source License +# included in the LICENSE file at the root of this repository. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0. +# +# docs-markdown -- renders a Markdown copy of every page in a built docs site + +exec "$(dirname "$0")"/pyactivate -m materialize.cli.docs_markdown "$@" diff --git a/bin/gen-claude-skill b/bin/gen-claude-skill deleted file mode 100755 index 4625d4e745ccb..0000000000000 --- a/bin/gen-claude-skill +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bash - -# Copyright Materialize, Inc. and contributors. All rights reserved. -# -# Use of this software is governed by the Business Source License included in -# the LICENSE file at the root of this repository. -# -# As of the Change Date specified in that file, in accordance with the Business -# Source License, use of this software will be governed by the Apache License, -# Version 2.0. -# -# gen-claude-skill -- Generate a shared agent skill bundle from the -# documentation. -# -# Usage: bin/gen-claude-skill [OUTPUT_DIR] -# -# Arguments: OUTPUT_DIR Directory to output the skill files. The OUTPUT_DIR -# directory is cleaned before generation. -# Default: .agents/skills/mz-docs. -# For publishing to the website, -# we will output to doc/user/public/markdown-docs directory. -# -# Examples: -# bin/gen-claude-skill # Generate to default location -# bin/gen-claude-skill /path/to/output # Generate to custom location - -set -euo pipefail - -cd "$(dirname "$0")/.." - -# For publishing to the website, we will output to doc/user/public/markdown-docs -# directory. The OUTPUT_DIR directory is cleaned before generation. -OUTPUT_DIR="${1:-.agents/skills/mz-docs}" - -# Ensure output directory exists -mkdir -p "$OUTPUT_DIR" - -echo "Generating agent skill from documentation..." -echo "Output directory: $OUTPUT_DIR" - -# Build documentation with skill output format -cd doc/user -hugo --config config.toml,config.skill.toml \ - --disableKinds 404,sitemap,robotsTXT,taxonomy \ - --destination "../../$OUTPUT_DIR" \ - --cleanDestinationDir \ - --gc \ - --quiet - -cd ../.. - -# Rename the home page to SKILL.md (shared skill convention) -if [[ -f "$OUTPUT_DIR/index.md" ]]; then - mv "$OUTPUT_DIR/index.md" "$OUTPUT_DIR/SKILL.md" -fi - -# Collapse runs of consecutive blank lines down to a single blank line. -# Hugo emits a blank line in place of each stripped shortcode/template -# directive, which produces long runs around
| blocks
-# in pages like ingest-data/mysql/* and self-managed-deployments/*.
-find "$OUTPUT_DIR" -name '*.md' -type f -print0 | while IFS= read -r -d '' f; do
- awk '
- /^[[:space:]]*$/ { if (blank) next; blank = 1; print ""; next }
- { blank = 0; print }
- ' "$f" > "$f.tmp" && mv "$f.tmp" "$f"
-done
-
-# Count generated files
-FILE_COUNT=$(find "$OUTPUT_DIR" -name "*.md" | wc -l | tr -d ' ')
-
-echo "Done! Generated $FILE_COUNT markdown files."
-echo "Skill entry point: $OUTPUT_DIR/SKILL.md"
diff --git a/ci/deploy_website/docs-content-negotiation.js b/ci/deploy_website/docs-content-negotiation.js
new file mode 100644
index 0000000000000..54c616f268f18
--- /dev/null
+++ b/ci/deploy_website/docs-content-negotiation.js
@@ -0,0 +1,31 @@
+// Copyright Materialize, Inc. and contributors. All rights reserved.
+//
+// Use of this software is governed by the Business Source License
+// included in the LICENSE file at the root of this repository.
+//
+// As of the Change Date specified in that file, in accordance with
+// the Business Source License, use of this software will be governed
+// by the Apache License, Version 2.0.
+
+// CloudFront Function (cloudfront-js-2.0, viewer request) for the /docs/*
+// behavior of materialize.com. It serves a page's Markdown rendition, the
+// index.md that bin/docs-markdown writes beside each index.html, to clients
+// that send `Accept: text/markdown`.
+//
+// It must run on viewer request, not origin request: the rewritten URI is
+// then the cache key, so the HTML and Markdown renditions of a page are cached
+// separately. Responses on the behavior must carry `Vary: Accept` (set by its
+// response headers policy) so that caches downstream of CloudFront do the
+// same.
+//
+// This file is not deployed by CI. Publish changes to the function attached
+// to the distribution by hand.
+
+function handler(event) {
+ var request = event.request;
+ var accept = request.headers.accept ? request.headers.accept.value : "";
+ if (request.uri.endsWith("/") && accept.indexOf("text/markdown") !== -1) {
+ request.uri += "index.md";
+ }
+ return request;
+}
diff --git a/ci/deploy_website/website.sh b/ci/deploy_website/website.sh
index 686a70171b5b2..fa3ba50893203 100755
--- a/ci/deploy_website/website.sh
+++ b/ci/deploy_website/website.sh
@@ -40,10 +40,10 @@ cd doc/user
if [[ "$BUILDKITE_ORGANIZATION_SLUG" == "materialize" ]] && [[ "$BUILDKITE_BRANCH" == self-managed-docs/* ]]; then
VERSION=${BUILDKITE_BRANCH#self-managed-docs/}
hugo --gc --baseURL "/docs/self-managed/$VERSION" --destination "public/docs/self-managed/$VERSION"
+ ../../bin/docs-markdown "public/docs/self-managed/$VERSION" --base-url "https://materialize.com/docs/self-managed/$VERSION/"
else
hugo --gc --baseURL /docs --destination public/docs
- # Build skill docs to public/docs/markdown-docs/.
- hugo --gc --baseURL /docs --config config.toml,config.skill.toml --disableKinds 404,sitemap,robotsTXT,taxonomy --destination public/docs/markdown-docs
+ ../../bin/docs-markdown public/docs --base-url https://materialize.com/docs/
fi
hugo deploy --maxDeletes -1
diff --git a/ci/test/lint-docs.sh b/ci/test/lint-docs.sh
index 250f03ad4c05c..860709ee28293 100755
--- a/ci/test/lint-docs.sh
+++ b/ci/test/lint-docs.sh
@@ -17,7 +17,8 @@ set -euo pipefail
git clean -ffdX ci/www/public
try hugo --gc --baseURL https://ci.materialize.com/docs --source doc/user --destination ../../ci/www/public/docs
-try hugo --gc --baseURL https://ci.materialize.com/docs --source doc/user --config config.toml,config.skill.toml --disableKinds 404,sitemap,robotsTXT,taxonomy --destination ../../ci/www/public/docs/markdown-docs
+try bin/docs-markdown ci/www/public/docs --base-url https://ci.materialize.com/docs/
+try bin/pytest -qq misc/python/materialize/cli/docs_markdown_test.py
echo "" > ci/www/public/index.html
try htmltest -s ci/www/public -c doc/user/.htmltest.yml
try ci/test/lint-docs-catalog.sh
diff --git a/ci/test/preview-docs.sh b/ci/test/preview-docs.sh
index 8a122faf50a6f..22a9fbeb0402d 100755
--- a/ci/test/preview-docs.sh
+++ b/ci/test/preview-docs.sh
@@ -22,16 +22,13 @@ cd doc/user
# Build main docs to public/
hugo --gc --environment preview --baseURL "/materialize/$BUILDKITE_PULL_REQUEST"
-
-# Build skill docs to public/markdown-docs/
-hugo --config config.toml,config.skill.toml --gc --baseURL "/materialize/$BUILDKITE_PULL_REQUEST" --disableKinds 404,sitemap,robotsTXT,taxonomy
+../../bin/docs-markdown public --base-url "https://preview.materialize.com/materialize/$BUILDKITE_PULL_REQUEST/"
cat > config.deployment.toml < a Title", + head='x |