checkdocs.py: check missing "ext" CSS classes
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 13 Oct 2014 20:31:26 +0000 (16:31 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 13 Oct 2014 20:31:26 +0000 (16:31 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
contents/getting-started/tracing-the-linux-kernel.md
contrib-guide.md
tools/checkdocs.py

index 5f62d056ac4da07884dd4300117077082a3f52ff..95a2836d3c8e62ed40ff235bf427add7098536e1 100644 (file)
@@ -17,7 +17,7 @@ lttng list --kernel
 <p>
     <span class="t">Tip:</span>You can avoid using <code>sudo</code> in
     the previous and following commands if your user is part of the
-    <a href="/docs/#doc-lttng-sessiond"><code>tracing</code> group</a>.
+    <a href="/docs/#doc-lttng-sessiond" class="int"><code>tracing</code> group</a>.
 </p>
 </div>
 
index 1eed3df336958aab06f06abdefad1170741e6d7c..0293c4d83c899824e5c8255ddbb3866f7d337e59 100644 (file)
@@ -93,6 +93,11 @@ The LTTng Documentation is
 <a href="https://github.com/lttng/lttng-docs" class="ext">public</a>.
 ```
 
+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
 
index bc53b4cbab5cbc41d7f71cd9869cf1ea4721ca77..2400253c2c529cb5d7a6f9b12e349b5b528ab79c 100755 (executable)
@@ -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'<a\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
This page took 0.038843 seconds and 4 git commands to generate.