[clang] 2fbe3f9 - [Clang] make_cxx_dr_status download the issue list automatically
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 6 01:40:12 PST 2022
Author: Corentin Jabot
Date: 2022-12-06T10:40:06+01:00
New Revision: 2fbe3f9e7941858e9c856474737b5a1420448eb8
URL: https://github.com/llvm/llvm-project/commit/2fbe3f9e7941858e9c856474737b5a1420448eb8
DIFF: https://github.com/llvm/llvm-project/commit/2fbe3f9e7941858e9c856474737b5a1420448eb8.diff
LOG: [Clang] make_cxx_dr_status download the issue list automatically
if none is provided
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D139212
Added:
Modified:
clang/www/cxx_dr_status.html
clang/www/make_cxx_dr_status
Removed:
################################################################################
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 06783c0ff41b..d5f52b3bc9d6 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1,9 +1,8 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE html>
<!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
<html>
<head>
- <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Clang - C++ Defect Report Status</title>
<link type="text/css" rel="stylesheet" href="menu.css">
<link type="text/css" rel="stylesheet" href="content.css">
diff --git a/clang/www/make_cxx_dr_status b/clang/www/make_cxx_dr_status
index 922a3810ec9a..1b4fdb6c6184 100755
--- a/clang/www/make_cxx_dr_status
+++ b/clang/www/make_cxx_dr_status
@@ -1,18 +1,12 @@
#! /usr/bin/env python3
-import sys, os, re
+import sys, os, re, urllib.request
-index = 'cwg_index.html'
+
+default_issue_list_path = 'cwg_index.html'
+issue_list_url = "https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html"
output = 'cxx_dr_status.html'
dr_test_dir = '../test/CXX/drs'
-if len(sys.argv) == 1:
- pass
-elif len(sys.argv) == 2:
- index = sys.argv[1]
-else:
- print('Usage: make_drs [<path to cwg_index.html>]', file=sys.stderr)
- sys.exit(1)
-
class DR:
def __init__(self, section, issue, url, status, title):
self.section, self.issue, self.url, self.status, self.title = \
@@ -31,29 +25,61 @@ def parse(dr):
title = title.replace('<issue_title>', '').replace('</issue_title>', '').replace('\r\n', '\n').strip()
return DR(section, issue, url, status, title)
-status_re = re.compile(r'\bdr([0-9]+): (.*)')
-status_map = {}
-for test_cpp in os.listdir(dr_test_dir):
- if not test_cpp.endswith('.cpp'):
- continue
- test_cpp = os.path.join(dr_test_dir, test_cpp)
- found_any = False;
- for match in re.finditer(status_re, open(test_cpp, 'r').read()):
- status_map[int(match.group(1))] = match.group(2)
- found_any = True
- if not found_any:
- print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
-
-drs = sorted((parse(dr) for dr in open(index, 'r').read().split('<TR>')[2:]),
- key = lambda dr: dr.issue)
+def collect_tests():
+ status_re = re.compile(r'\bdr([0-9]+): (.*)')
+ status_map = {}
+ for test_cpp in os.listdir(dr_test_dir):
+ if not test_cpp.endswith('.cpp'):
+ continue
+ test_cpp = os.path.join(dr_test_dir, test_cpp)
+ found_any = False;
+ for match in re.finditer(status_re, open(test_cpp, 'r').read()):
+ status_map[int(match.group(1))] = match.group(2)
+ found_any = True
+ if not found_any:
+ print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
+ return status_map
+
+def get_issues(path):
+ buffer = None
+ if not path and os.path.exists(default_issue_list_path):
+ path = default_issue_list_path
+ try:
+ if path is None:
+ print('Fetching issue list from {}'.format(issue_list_url))
+ with urllib.request.urlopen(issue_list_url) as f:
+ buffer = f.read().decode('utf-8')
+ else:
+ print('Opening issue list from file {}'.format(path))
+ with open(path, 'r') as f:
+ buffer = f.read()
+ except Exception as ex:
+ print('Unable to read the core issue list', file=sys.stderr)
+ print(ex, file=sys.stderr)
+ sys.exit(1)
+
+ return sorted((parse(dr) for dr in buffer.split('<TR>')[2:]),
+ key = lambda dr: dr.issue)
+
+
+issue_list_path = None
+if len(sys.argv) == 1:
+ pass
+elif len(sys.argv) == 2:
+ issue_list_path = sys.argv[1]
+else:
+ print('Usage: {} [<path to cwg_index.html>]'.format(sys.argv[0]), file=sys.stderr)
+ sys.exit(1)
+
+status_map = collect_tests()
+drs = get_issues(issue_list_path)
out_file = open(output, 'w')
out_file.write('''\
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE html>
<!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
<html>
<head>
- <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Clang - C++ Defect Report Status</title>
<link type="text/css" rel="stylesheet" href="menu.css">
<link type="text/css" rel="stylesheet" href="content.css">
@@ -95,7 +121,7 @@ latest_release = 15
def availability(issue):
status = status_map.get(issue, 'unknown')
-
+
unresolved_status = ''
if status.endswith(' open'):
status = status[:-5]
@@ -173,10 +199,12 @@ for dr in drs:
# This refers to the old ("C++0x") concepts feature, which was not part
# of any C++ International Standard or Technical Specification.
continue
+
elif dr.status == 'extension':
row_style = ' class="open"'
avail = 'Extension'
avail_style = ''
+
elif dr.status in ('open', 'drafting', 'review'):
row_style = ' class="open"'
avail, avail_style, unresolved_status = availability(dr.issue)
@@ -187,16 +215,15 @@ for dr in drs:
assert unresolved_status == dr.status, \
"Issue %s is marked '%s', which
diff ers from CWG index status '%s'" \
% (dr.issue, unresolved_status, dr.status)
- if not avail.startswith('Sup') and not avail.startswith('Dup'):
- count[avail] = count.get(avail, 0) + 1
else:
row_style = ''
avail, avail_style, unresolved_status = availability(dr.issue)
assert not unresolved_status, \
"Issue %s is marked '%s', even though it is resolved in CWG index" \
% (dr.issue, unresolved_status)
- if not avail.startswith('Sup') and not avail.startswith('Dup'):
- count[avail] = count.get(avail, 0) + 1
+
+ if not avail.startswith('Sup') and not avail.startswith('Dup'):
+ count[avail] = count.get(avail, 0) + 1
out_file.write('''
<tr%s id="%s">
More information about the cfe-commits
mailing list