Skip to content

Commit 754bee9

Browse files
committed
linkchecker: detect absolute links with missing leading slash
When an absolute link is missing the leading slash (it starts with "docs/foo" instead of "/docs/foo/"), print a more specific error instead of the generic catch-all warning. Without the leading slash, these are treated as relative paths and so lead to non-existing pages. Also, while we're at it, fix the instance it detects.
1 parent 0556bd8 commit 754bee9

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

content/en/docs/setup/production-environment/container-runtimes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ There are two cgroup drivers available:
113113

114114
### cgroupfs driver {#cgroupfs-cgroup-driver}
115115

116-
The `cgroupfs` driver is the [default cgroup driver in the kubelet](docs/reference/config-api/kubelet-config.v1beta1).
116+
The `cgroupfs` driver is the [default cgroup driver in the kubelet](/docs/reference/config-api/kubelet-config.v1beta1).
117117
When the `cgroupfs` driver is used, the kubelet and the container runtime directly interface with
118118
the cgroup filesystem to configure cgroups.
119119

scripts/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ Cases handled:
140140
+ /docs/bar : is a redirect entry, or
141141
+ /docs/bar : is something we don't understand
142142
143+
+ [foo](<lang>/docs/bar/...) : leading slash missing for absolute path
144+
145+
+ [foo](docs/bar/...) : leading slash missing for absolute path
146+
143147
```
144148
## lsync.sh
145149

scripts/linkchecker.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
# + /docs/bar : is a redirect entry, or
3535
# + /docs/bar : is something we don't understand
3636
#
37+
# + [foo](<lang>/docs/bar/...) : leading slash missing for absolute path
38+
#
39+
# + [foo](docs/bar/...) : leading slash missing for absolute path
40+
#
3741
# + {{ < api-reference page="" anchor="" ... > }}
3842
# + {{ < api-reference page="" > }}
3943

@@ -334,6 +338,11 @@ def check_target(page, anchor, target):
334338
return new_record("WARNING", msg, target)
335339
return new_record("ERROR", "Missing link for [%s]" % anchor, target)
336340

341+
# absolute link missing leading slash
342+
if (target.startswith("docs/") or target.startswith(LANG + "/docs/")):
343+
return new_record("ERROR", "Missing leading slash. Try \"/%s\"" %
344+
target, target)
345+
337346
msg = "Link may be wrong for the anchor [%s]" % anchor
338347
return new_record("WARNING", msg, target)
339348

0 commit comments

Comments
 (0)