Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions .github/workflows/reference-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,20 @@ jobs:
# underlying types (e.g. `map[string]CELExpression` -> #map[string]celexpression,
# which never gets a heading), keeping the readable type text.
sed -i.bak -E 's/_Underlying type:_ _\[(map\[[^]]*\][^]]*)\]\(#[^)]*\)_/_Underlying type:_ _\1_/g' "$TARGET_FILE"
# Repoint the PullPolicy link. crd-ref-docs templates a kubernetes.io URL for
# every k8s.io type, but PullPolicy is a type alias with no section of its own,
# so #pullpolicy-v1-core does not exist and the link lands a reader nowhere.
# knownTypes cannot override it (see scripts/crd-ref-docs-config.yaml).
sed -i.bak -E 's|https://kubernetes\.io/docs/reference/generated/kubernetes-api/v?[0-9.]+/#pullpolicy-v1-core|https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy|g' "$TARGET_FILE"
rm -f "$TARGET_FILE.bak"

# A sed that silently stops matching would quietly reintroduce the broken
# anchor, so fail the run instead of opening a PR that carries it.
if grep -q '#pullpolicy-v1-core' "$TARGET_FILE"; then
echo "Error: PullPolicy anchor rewrite did not match in $TARGET_FILE"
exit 1
fi

rm "./out.md"
echo "API docs generated successfully at $TARGET_FILE"

Expand Down
11 changes: 9 additions & 2 deletions scripts/crd-ref-docs-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,12 @@ render:
# knownTypes entry for them is silently ignored. Entries for PullPolicy and
# metav1.Duration used to live here and never took effect. When a generated
# kubernetes.io anchor is broken (for example #pullpolicy-v1-core, which is a
# type alias with no section of its own), rewrite it in the post-processing
# step of .github/workflows/reference-docs.yaml instead.
# type alias with no section of its own), add a sed to the post-processing
# block in the "Generate API docs" step of .github/workflows/reference-docs.yaml
# instead. Do not patch the generated api-*.md files by hand: the next regen
# reverts the edit, and the regen runs nightly.
#
# Reserve those rewrites for links that are genuinely wrong for a reader.
# Links that merely redirect (git.k8s.io, for one) belong in the exclude list
# in docs-link-checking/lychee.toml, not here: rewriting them pins a URL that
# can rot, which is worse than the redirect.