Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion blog/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ plugins:
copyright: "Copyright © 2024 The Knative Authors"

extra:
homepage: https://knative.dev/docs
homepage: https://knative.dev
# social:
# - icon: fontawesome/brands/twitter
# link: https://twitter.com/KnativeProject
Expand Down
100 changes: 36 additions & 64 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set -x
# 1) Make a release-NN branch as normal.
# 2) Update VERSIONS below (on main) to include the new version, and remove the oldest
# Order matters :-), Most recent first.
VERSIONS=("1.18" "1.17") # Docs version, results in the url e.g. knative.dev/docs-1.9/..
VERSIONS=("1.19" "1.18" "1.17") # Docs version, results in the url e.g. knative.dev/v1.9-docs/..
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not quite ready to release 1.19 -- the OpenTelemetry changes came in late and we've had to push some bug fixes.

# 4) PR the result to main.
# 5) Party.

Expand All @@ -41,55 +41,45 @@ readonly SITE=$PWD/site
rm -rf site/

if [ "$BUILD_VERSIONS" == "no" ]; then
# HEAD to /docs if we're not doing versioning.
mkdocs build -f mkdocs.yml -d site/docs
# Build to root if we're not doing versioning
mkdocs build -f mkdocs.yml -d site
Comment on lines 43 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, this "tiny build for preview" seems to potentially be the part that's messing things up. I wonder if we want to remove it for now, and leave a TODO to optimize this later. (The preview version is also not importing the serving/eventing reference docs, and makes it hard to reason about these sorts of changes from the preview.)

else
# Versioning: pre-release (HEAD): docs => development/
cp -r . $TEMP/docs-main
# Build latest version to /docs
cp -r . "$TEMP/docs-main"
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/main/docs/serving-api.md -s > "$TEMP/docs-main/docs/serving/reference/serving-api.md"
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/main/docs/eventing-api.md -s > "$TEMP/docs-main/docs/eventing/reference/eventing-api.md"
pushd "$TEMP/docs-main"; mkdocs build -f mkdocs.yml -d $SITE/development; popd

# Latest release branch to /docs
git clone --depth 1 -b ${DOCS_BRANCHES[0]} https://github.com/${GIT_SLUG} "$TEMP/docs-$latest"

if [ ${latest#*1.} -gt 6 ]; then
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[0]}/docs/serving-api.md -s > "$TEMP/docs-$latest/docs/serving/reference/serving-api.md"
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/eventing/reference/eventing-api.md"
else
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[0]}/docs/serving-api.md -s > "$TEMP/docs-$latest/docs/reference/api/serving-api.md"
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/reference/api/eventing-api.md"
fi

pushd "$TEMP/docs-$latest"; KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d $SITE/docs; popd

# Previous release branches release-$version to /v$version-docs
versionjson=""

# Create docs directory structure
mkdir -p "$SITE/docs"

# Build latest docs to /docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were building the next-release docs to /development/... and the most-recent-release docs to /docs/.... I think you've changed this to build the next-release docs to /docs/..., and not publish docs for the current release anywhere.

pushd "$TEMP/docs-main"
KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d "$SITE/docs"
popd

# Build versioned docs to /vX.Y-docs/
for i in "${!previous[@]}"; do
version=${previous[$i]}
versionjson+="{\"version\": \"v$version-docs\", \"title\": \"v$version\", \"aliases\": [\"\"]},"

echo "Building for previous version $version"
git clone --depth 1 -b ${DOCS_BRANCHES[$i+1]} https://github.com/${GIT_SLUG} "$TEMP/docs-$version"
if [ ${version#*1.} -gt 6 ]; then
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[i+1]}/docs/serving-api.md -s > "$TEMP/docs-$version/docs/serving/reference/serving-api.md"
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[i+1]}/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/eventing/reference/eventing-api.md"
else
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[i+1]}/docs/serving-api.md -s > "$TEMP/docs-$version/docs/reference/api/serving-api.md"
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[i+1]}/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/reference/api/eventing-api.md"
fi
pushd "$TEMP/docs-$version"; KNATIVE_VERSION="${VERSIONS[i+1]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[i+1]}" VERSION_WARNING=true mkdocs build -d "$SITE/v$version-docs"; popd

version="${previous[$i]}"
branch="${DOCS_BRANCHES[$((i+1))]}"
git clone --depth 1 -b "$branch" "https://github.com/$GIT_SLUG" "$TEMP/docs-$version"

# Copy non-versioned content from main branch
mkdir -p "$TEMP/docs-$version/docs/about"
cp -r "$TEMP/docs-main/docs/about" "$TEMP/docs-$version/docs/"
mkdir -p "$TEMP/docs-$version/docs/community"
cp -r "$TEMP/docs-main/docs/community" "$TEMP/docs-$version/docs/"

pushd "$TEMP/docs-$version"
KNATIVE_VERSION="$version.0" SAMPLES_BRANCH="$branch" mkdocs build -d "$SITE/v$version-docs"
popd
done

# Set up the version file to point to the built docs.
cat << EOF > $SITE/versions.json
[
{"version": "docs", "title": "v$latest", "aliases": [""]},
$versionjson
{"version": "development", "title": "(Pre-release)", "aliases": [""]}
]
EOF

# Move non-versioned content to /docs
mkdir -p "$SITE/docs/about"
cp -r "$TEMP/docs-main/docs/about" "$SITE/docs/"
mkdir -p "$SITE/docs/community"
cp -r "$TEMP/docs-main/docs/community" "$SITE/docs/"
fi

# Create the blog
Expand All @@ -107,25 +97,7 @@ cp golang/*.html site/golang/
cat golang/_redirects >> site/_redirects


# Home page is served from docs, so add a redirect.
cat << EOF > site/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting</title>
<noscript>
<meta http-equiv="refresh" content="1; url=docs/" />
</noscript>
<script>
window.location.replace("docs/");
</script>
</head>
<body>
Redirecting to <a href="docs/">docs/</a>...
</body>
</html>
EOF
# Home page is now served directly from root, no redirect needed

# Clean up
rm -rf $TEMP
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
INHERIT: config/nav.yml

site_name: Knative
site_url: https://knative.dev/docs
site_url: https://knative.dev
site_description: Knative Documentation
extra_css:
- stylesheets/extra.css

repo_url: https://github.com/knative/docs
edit_uri: edit/main/docs
edit_uri: edit/main

theme:
name: material
Expand Down
89 changes: 85 additions & 4 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
command = "./hack/build.sh"
command = "hack/build.sh"
publish = "site"

[build.environment]
NODE_VERSION= "14"
PYTHON_VERSION = "3.8"
PYTHON_VERSION = "3.9"
NODE_VERSION = "16"
NPM_VERSION = "8.5.5"

# Deploy Preview context: all deploys generated from a pull/merge request will
# inherit these settings.
Expand All @@ -17,16 +18,96 @@
[context.deploy-preview.environment]
BUILD_VERSIONS="no"

# Handle versioned docs
[[redirects]]
from = "/contributing/"
from = "/v:version-docs/*"
to = "/v:version-docs/:splat"
status = 200

# Redirect old versioned docs to new paths
[[redirects]]
from = "/docs-:version/*"
to = "/v:version-docs/:splat"
status = 301

# Redirect root to /docs for the latest version
[[redirects]]
from = "/"
to = "/docs"
status = 200

# Handle /docs paths
[[redirects]]
from = "/docs"
to = "/docs/"
status = 301

[[redirects]]
from = "/docs/*"
to = "/docs/:splat"
status = 200

# Handle old about and community URLs (root level to /docs/)
[[redirects]]
from = "/about"
to = "/docs/about/"
status = 301

[[redirects]]
from = "/about/*"
to = "/docs/about/:splat"
status = 301

[[redirects]]
from = "/community"
to = "/docs/community/"
status = 301

[[redirects]]
from = "/community/*"
to = "/docs/community/:splat"
status = 301

# Handle blog URLs
[[redirects]]
from = "/blog/*"
to = "/blog/:splat"
status = 200

# Handle old development URLs
[[redirects]]
from = "/development/*"
to = "/docs/:splat"
status = 301

# Handle old API reference URLs
[[redirects]]
from = "/reference/api/*"
to = "/docs/reference/api/:splat"
status = 301

# Handle old serving and eventing reference URLs
[[redirects]]
from = "/serving/reference/*"
to = "/docs/serving/reference/:splat"
status = 301

[[redirects]]
from = "/eventing/reference/*"
to = "/docs/eventing/reference/:splat"
status = 301

# Keep existing contributor redirects
[[redirects]]
from = "/contributing/"
to = "/docs/community/"
status = 301

[[redirects]]
from = "/help/contributing/"
to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md"
status = 301

[[redirects]]
from = "/docs/help/contributor/*"
to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md"
Expand Down