aboutsummaryrefslogtreecommitdiffstats
path: root/tools/check_links.py
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-05-19 12:36:04 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-19 12:52:04 +0200
commit6d882fd26c01d118a584b2a3aecd5f08fa5e11e1 (patch)
treedaa277cb6ebeb1f3093920262a25e87629fd5fd2 /tools/check_links.py
parentac61eb2b125ee9891ae3290f770e6ee36c07535d (diff)
tools/check_links.py: detect absolute links
Detect absolute links to our repo. These are not checked and long and inconsistent with majority of links.
Diffstat (limited to 'tools/check_links.py')
-rwxr-xr-xtools/check_links.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/check_links.py b/tools/check_links.py
index 848329e04..aea62a5ae 100755
--- a/tools/check_links.py
+++ b/tools/check_links.py
@@ -24,6 +24,14 @@ for doc in docs:
for match in link_re.finditer(line):
links += [(doc, match.group(1), i + 1, match.start(1))]
+errors = []
+
+for link in links:
+ (doc, link, line, col) = link
+ for prefix in ['https://github.com/google/syzkaller/blob/master', 'https://github.com/google/syzkaller/tree/master']:
+ if link.startswith(prefix):
+ errors += ['%s:%d:%d: Replace absolute link with %s.' % (doc, line, col, link[len(prefix):])]
+
def filter_link(args):
(doc, link, line, col) = args
if link.startswith('http'):
@@ -44,8 +52,6 @@ def fix_link(args):
links = list(map(fix_link, links))
-errors = []
-
def check_link(args):
(doc, link, line, col) = args
path = os.path.dirname(doc)
@@ -61,13 +67,14 @@ def check_link(args):
for link in links:
if not check_link(link):
- errors += [link]
+ (doc, link, line, col) = link
+ errors += ['%s:%d:%d: Broken link %s.' % (doc, line, col, link)]
if len(errors) == 0:
- print('%d links checked: OK' % (len(links),))
+ print('%d links checked: OK' % len(links))
sys.exit(0)
-for (doc, link, line, col) in errors:
- print('%s:%d:%d: Broken link %s.' % (doc, line, col, link))
+for error in errors:
+ print(error)
sys.exit(2)