summaryrefslogtreecommitdiff
path: root/docs/tools
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
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
Diffstat (limited to 'docs/tools')
-rw-r--r--docs/tools/dump_ast_matchers.py25
-rw-r--r--docs/tools/dump_format_style.py17
2 files changed, 22 insertions, 20 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
diff --git a/docs/tools/dump_format_style.py b/docs/tools/dump_format_style.py
index 3d61227f73617..5feb793a4d705 100644
--- a/docs/tools/dump_format_style.py
+++ b/docs/tools/dump_format_style.py
@@ -6,7 +6,6 @@
import collections
import os
import re
-import urllib2
CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
FORMAT_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Format/Format.h')
@@ -32,7 +31,7 @@ def indent(text, columns, indent_first_line=True):
return s
return indent + s
-class Option:
+class Option(object):
def __init__(self, name, type, comment):
self.name = name
self.type = type
@@ -50,7 +49,7 @@ class Option:
2)
return s
-class NestedStruct:
+class NestedStruct(object):
def __init__(self, name, comment):
self.name = name
self.comment = comment.strip()
@@ -59,7 +58,7 @@ class NestedStruct:
def __str__(self):
return '\n'.join(map(str, self.values))
-class NestedField:
+class NestedField(object):
def __init__(self, name, comment):
self.name = name
self.comment = comment.strip()
@@ -69,7 +68,7 @@ class NestedField:
self.name,
doxygen2rst(indent(self.comment, 2, indent_first_line=False)))
-class Enum:
+class Enum(object):
def __init__(self, name, comment):
self.name = name
self.comment = comment.strip()
@@ -78,7 +77,7 @@ class Enum:
def __str__(self):
return '\n'.join(map(str, self.values))
-class EnumValue:
+class EnumValue(object):
def __init__(self, name, comment):
self.name = name
self.comment = comment
@@ -101,7 +100,7 @@ def clean_comment_line(line):
return line[4:] + '\n'
def read_options(header):
- class State:
+ class State(object):
BeforeStruct, Finished, InStruct, InNestedStruct, InNestedFieldComent, \
InFieldComment, InEnum, InEnumMemberComment = range(8)
state = State.BeforeStruct
@@ -180,9 +179,9 @@ def read_options(header):
'std::vector<std::string>',
'std::vector<IncludeCategory>',
'std::vector<RawStringFormat>']:
- if enums.has_key(option.type):
+ if option.type in enums:
option.enum = enums[option.type]
- elif nested_structs.has_key(option.type):
+ elif option.type in nested_structs:
option.nested_struct = nested_structs[option.type]
else:
raise Exception('Unknown type: %s' % option.type)