From: Philippe Proulx Date: Mon, 13 Oct 2014 20:31:26 +0000 (-0400) Subject: checkdocs.py: check missing "ext" CSS classes X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=cc3ab47f680b518a95b2f4e862537124b0d2c4e2;p=lttng-docs.git checkdocs.py: check missing "ext" CSS classes Signed-off-by: Philippe Proulx --- diff --git a/contents/getting-started/tracing-the-linux-kernel.md b/contents/getting-started/tracing-the-linux-kernel.md index 5f62d05..95a2836 100644 --- a/contents/getting-started/tracing-the-linux-kernel.md +++ b/contents/getting-started/tracing-the-linux-kernel.md @@ -17,7 +17,7 @@ lttng list --kernel

Tip:You can avoid using sudo in the previous and following commands if your user is part of the - tracing group. + tracing group.

diff --git a/contrib-guide.md b/contrib-guide.md index 1eed3df..0293c4d 100644 --- a/contrib-guide.md +++ b/contrib-guide.md @@ -93,6 +93,11 @@ The LTTng Documentation is public. ``` +Sometimes, however, it is necessary to write internal links in plain +HTML, for example in tip blocks, since Markdown code is not processed. +In these cases, add the `int` CSS class as a hint to prevent the static +analyzer from complaining (`tools/checkdocs.py`). + #### abbreviations diff --git a/tools/checkdocs.py b/tools/checkdocs.py index bc53b4c..2400253 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']+>') 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