docs2json: no errors/warnings with simple anchors
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 21 Mar 2016 21:52:45 +0000 (17:52 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 21 Mar 2016 21:54:47 +0000 (17:54 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
tools/docs2json.py

index 661ef6535b83074ef0568046b8b522cdacba7562..66977ffa14847ca2a2422e43755bbe13f8cd9f80 100755 (executable)
@@ -206,6 +206,7 @@ def _get_sid_from_file(path, c):
 
 _ilink_re = re.compile(r'\[[^\]]+\]\(([^)]+)\)', flags=re.M)
 _elink_re = re.compile(r'<a(?:\s+[^>]+|\s*)>')
+_name_re = re.compile(r'name="([^"]+)"')
 _href_re = re.compile(r'href="([^"]+)"')
 _classes_re = re.compile(r'class="([^"]+)"')
 
@@ -223,8 +224,13 @@ def _register_section_info(registry, toc_ids, path, c):
 
     for link in elinks:
         href = _href_re.search(link)
+        name = _name_re.search(link)
         classes = _classes_re.search(link)
 
+        if name and not href:
+            # simple anchor
+            continue
+
         if classes is None:
             _pwarn(path, 'External link has no "ext" class: "{}"'.format(link))
             classes = []
@@ -240,15 +246,15 @@ def _register_section_info(registry, toc_ids, path, c):
             href = href.group(1)
 
             if href.startswith('#') and 'int' not in classes:
-                _pwarn(path, 'External link starts with #: "{}"'.format(href.group(1)))
+                _pwarn(path, 'External link starts with #: "{}"'.format(href))
 
             if 'int' in classes:
                 ilinks.append(href)
                 continue
 
             section_info.add_out_link(_ExtLink(href))
-        else:
-            _perror(path, 'External link with no "href" attribute: "{}"'.format(link))
+        elif not name:
+            _perror(path, 'External link with no "href" or "name" attribute: "{}"'.format(link))
             ret = False
 
     for link in ilinks:
This page took 0.031353 seconds and 4 git commands to generate.