X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=inline;f=tools%2Fcheckdocs.py;h=05f5279498e1c84c3190dd505ed1edbf31390a20;hb=066f96acd2ed844c60e32aa2037e6270ca82821e;hp=bc53b4cbab5cbc41d7f71cd9869cf1ea4721ca77;hpb=5e0cbfb01373c18e521217342fd8a9159cc186b1;p=lttng-docs.git diff --git a/tools/checkdocs.py b/tools/checkdocs.py index bc53b4c..05f5279 100755 --- a/tools/checkdocs.py +++ b/tools/checkdocs.py @@ -72,7 +72,7 @@ def _get_toc_ids(path): def _check_file_links(toc_ids, path, c): ilinkp = re.compile(r'\[[^\]]+\]\(([^)]+)\)', flags=re.M) - elinkp = re.compile(r'href="([^"]+)"') + elinkp = re.compile(r']+|\s*)>') ret = True @@ -92,9 +92,26 @@ def _check_file_links(toc_ids, path, c): _perror(path, 'Dead internal link: "{}"'.format(link)) ret = False + hrefp = re.compile(r'href="([^"]+)"') + classesp = re.compile(r'class="([^"]+)"') + for link in elinks: - if link.startswith('#'): - _pwarn(path, 'External link starts with #: "{}"'.format(link)) + href = hrefp.search(link) + classes = classesp.search(link) + + if classes is None: + _pwarn(path, 'External link has no "ext" class: "{}"'.format(link)) + else: + classes = classes.group(1).split(' ') + + if 'int' not in classes and 'ext' not in classes: + _pwarn(path, 'External link has no "ext" class: "{}"'.format(link)) + + if href is not None: + if href.group(1).startswith('#'): + _pwarn(path, 'External link starts with #: "{}"'.format(href)) + else: + _perror(path, 'External link with no "href": "{}"'.format(link)) ret = False return ret