Update repo_health.yml
This commit is contained in:
52
.github/workflows/repo_health.yml
vendored
52
.github/workflows/repo_health.yml
vendored
@@ -700,36 +700,36 @@ jobs:
|
|||||||
# Docs index link integrity (docs/docs-index.md)
|
# Docs index link integrity (docs/docs-index.md)
|
||||||
if [ -f 'docs/docs-index.md' ]; then
|
if [ -f 'docs/docs-index.md' ]; then
|
||||||
missing_links="$(python3 - <<'PY'
|
missing_links="$(python3 - <<'PY'
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
idx = 'docs/docs-index.md'
|
idx = 'docs/docs-index.md'
|
||||||
base = os.getcwd()
|
base = os.getcwd()
|
||||||
|
|
||||||
bad = []
|
bad = []
|
||||||
pat = re.compile(r'\[[^\]]+\]\(([^)]+)\)')
|
pat = re.compile(r'\[[^\]]+\]\(([^)]+)\)')
|
||||||
|
|
||||||
with open(idx, 'r', encoding='utf-8') as f:
|
with open(idx, 'r', encoding='utf-8') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
for m in pat.findall(line):
|
for m in pat.findall(line):
|
||||||
link = m.strip()
|
link = m.strip()
|
||||||
if link.startswith('http://') or link.startswith('https://') or link.startswith('#') or link.startswith('mailto:'):
|
if link.startswith('http://') or link.startswith('https://') or link.startswith('#') or link.startswith('mailto:'):
|
||||||
continue
|
continue
|
||||||
if link.startswith('/'):
|
if link.startswith('/'):
|
||||||
rel = link.lstrip('/')
|
rel = link.lstrip('/')
|
||||||
else:
|
else:
|
||||||
rel = os.path.normpath(os.path.join(os.path.dirname(idx), link))
|
rel = os.path.normpath(os.path.join(os.path.dirname(idx), link))
|
||||||
rel = rel.split('#', 1)[0]
|
rel = rel.split('#', 1)[0]
|
||||||
rel = rel.split('?', 1)[0]
|
rel = rel.split('?', 1)[0]
|
||||||
if not rel:
|
if not rel:
|
||||||
continue
|
continue
|
||||||
p = os.path.join(base, rel)
|
p = os.path.join(base, rel)
|
||||||
if not os.path.exists(p):
|
if not os.path.exists(p):
|
||||||
bad.append(rel)
|
bad.append(rel)
|
||||||
|
|
||||||
print('\n'.join(sorted(set(bad))))
|
print('\n'.join(sorted(set(bad))))
|
||||||
PY
|
PY
|
||||||
)"
|
)"
|
||||||
if [ -n "${missing_links}" ]; then
|
if [ -n "${missing_links}" ]; then
|
||||||
extended_findings+=("docs/docs-index.md contains broken relative links")
|
extended_findings+=("docs/docs-index.md contains broken relative links")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user