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.pull/41347/head
parent
0556bd8702
commit
754bee9fab
|
@ -113,7 +113,7 @@ There are two cgroup drivers available:
|
|||
|
||||
### cgroupfs driver {#cgroupfs-cgroup-driver}
|
||||
|
||||
The `cgroupfs` driver is the [default cgroup driver in the kubelet](docs/reference/config-api/kubelet-config.v1beta1).
|
||||
The `cgroupfs` driver is the [default cgroup driver in the kubelet](/docs/reference/config-api/kubelet-config.v1beta1).
|
||||
When the `cgroupfs` driver is used, the kubelet and the container runtime directly interface with
|
||||
the cgroup filesystem to configure cgroups.
|
||||
|
||||
|
|
|
@ -140,6 +140,10 @@ Cases handled:
|
|||
+ /docs/bar : is a redirect entry, or
|
||||
+ /docs/bar : is something we don't understand
|
||||
|
||||
+ [foo](<lang>/docs/bar/...) : leading slash missing for absolute path
|
||||
|
||||
+ [foo](docs/bar/...) : leading slash missing for absolute path
|
||||
|
||||
```
|
||||
## lsync.sh
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
# + /docs/bar : is a redirect entry, or
|
||||
# + /docs/bar : is something we don't understand
|
||||
#
|
||||
# + [foo](<lang>/docs/bar/...) : leading slash missing for absolute path
|
||||
#
|
||||
# + [foo](docs/bar/...) : leading slash missing for absolute path
|
||||
#
|
||||
# + {{ < api-reference page="" anchor="" ... > }}
|
||||
# + {{ < api-reference page="" > }}
|
||||
|
||||
|
@ -334,6 +338,11 @@ def check_target(page, anchor, target):
|
|||
return new_record("WARNING", msg, target)
|
||||
return new_record("ERROR", "Missing link for [%s]" % anchor, target)
|
||||
|
||||
# absolute link missing leading slash
|
||||
if (target.startswith("docs/") or target.startswith(LANG + "/docs/")):
|
||||
return new_record("ERROR", "Missing leading slash. Try \"/%s\"" %
|
||||
target, target)
|
||||
|
||||
msg = "Link may be wrong for the anchor [%s]" % anchor
|
||||
return new_record("WARNING", msg, target)
|
||||
|
||||
|
|
Loading…
Reference in New Issue