summaryrefslogtreecommitdiff
path: root/docs/tools/dump_ast_matchers.py
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
commit676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch)
tree02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /docs/tools/dump_ast_matchers.py
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
Diffstat (limited to 'docs/tools/dump_ast_matchers.py')
-rw-r--r--docs/tools/dump_ast_matchers.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/docs/tools/dump_ast_matchers.py b/docs/tools/dump_ast_matchers.py
index d38977548fd95..c96c1ca27acb6 100644
--- a/docs/tools/dump_ast_matchers.py
+++ b/docs/tools/dump_ast_matchers.py
@@ -5,7 +5,10 @@
import collections
import re
-import urllib2
+try:
+ from urllib.request import urlopen
+except ImportError:
+ from urllib2 import urlopen
MATCHERS_FILE = '../../include/clang/ASTMatchers/ASTMatchers.h'
@@ -38,11 +41,11 @@ def esc(text):
text = re.sub(r'>', '&gt;', text)
def link_if_exists(m):
name = m.group(1)
- url = 'http://clang.llvm.org/doxygen/classclang_1_1%s.html' % name
+ url = 'https://clang.llvm.org/doxygen/classclang_1_1%s.html' % name
if url not in doxygen_probes:
try:
- print 'Probing %s...' % url
- urllib2.urlopen(url)
+ print('Probing %s...' % url)
+ urlopen(url)
doxygen_probes[url] = True
except:
doxygen_probes[url] = False
@@ -181,9 +184,9 @@ def act_on_decl(declaration, comment, allowed_types):
raise Exception('Inconsistent documentation for: %s' % name)
for result_type in result_types:
add_matcher(result_type, name, 'Matcher<Type>', comment)
- if loc:
- add_matcher('%sLoc' % result_type, '%sLoc' % name, 'Matcher<TypeLoc>',
- comment)
+ # if loc:
+ # add_matcher('%sLoc' % result_type, '%sLoc' % name, 'Matcher<TypeLoc>',
+ # comment)
return
m = re.match(r"""^\s*AST_POLYMORPHIC_MATCHER(_P)?(.?)(?:_OVERLOAD)?\(
@@ -307,14 +310,14 @@ def act_on_decl(declaration, comment, allowed_types):
if not result_types:
if not comment:
# Only overloads don't have their own doxygen comments; ignore those.
- print 'Ignoring "%s"' % name
+ print('Ignoring "%s"' % name)
else:
- print 'Cannot determine result type for "%s"' % name
+ print('Cannot determine result type for "%s"' % name)
else:
for result_type in result_types:
add_matcher(result_type, name, args, comment)
else:
- print '*** Unparsable: "' + declaration + '" ***'
+ print('*** Unparsable: "' + declaration + '" ***')
def sort_table(matcher_type, matcher_map):
"""Returns the sorted html table for the given row map."""
@@ -354,7 +357,7 @@ for line in open(MATCHERS_FILE).read().splitlines():
allowed_types += [m.group(1)]
continue
if line.strip() and line.lstrip()[0] == '/':
- comment += re.sub(r'/+\s?', '', line) + '\n'
+ comment += re.sub(r'^/+\s?', '', line) + '\n'
else:
declaration += ' ' + line
if ((not line.strip()) or