1 #! /usr/bin/env python3
2 import sys, os, re, urllib.request
5 clang_www_dir = os.path.dirname(__file__)
6 default_issue_list_path = os.path.join(clang_www_dir, 'cwg_index.html')
7 issue_list_url = "https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html"
8 output = os.path.join(clang_www_dir, 'cxx_dr_status.html')
9 dr_test_dir = os.path.join(clang_www_dir, '../test/CXX/drs')
12 def __init__(self, section, issue, url, status, title):
13 self.section, self.issue, self.url, self.status, self.title = \
14 section, issue, url, status, title
16 return '%s (%s): %s' % (self.issue, self.status, self.title)
20 section, issue_link, status, liaison, title = [
21 col.split('>', 1)[1].split('</TD>')[0]
22 for col in dr.split('</TR>', 1)[0].split('<TD')[1:]
24 except Exception as ex:
25 print(f"Parse error: {ex}\n{dr}", file=sys.stderr)
27 _, url, issue = issue_link.split('"', 2)
29 issue = int(issue.split('>', 1)[1].split('<', 1)[0])
30 title = title.replace('<issue_title>', '').replace('</issue_title>', '').replace('\r\n', '\n').strip()
31 return DR(section, issue, url, status, title)
34 status_re = re.compile(r'\bdr([0-9]+): (.*)')
36 for test_cpp in os.listdir(dr_test_dir):
37 if not test_cpp.endswith('.cpp'):
39 test_cpp = os.path.join(dr_test_dir, test_cpp)
41 for match in re.finditer(status_re, open(test_cpp, 'r').read()):
42 dr_number = int(match.group(1))
43 if dr_number in status_map:
44 print("error: Comment for dr{} encountered more than once. Duplicate found in {}".format(dr_number, test_cpp))
46 status_map[dr_number] = match.group(2)
49 print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
54 if not path and os.path.exists(default_issue_list_path):
55 path = default_issue_list_path
58 print('Fetching issue list from {}'.format(issue_list_url))
59 with urllib.request.urlopen(issue_list_url) as f:
60 buffer = f.read().decode('utf-8')
62 print('Opening issue list from file {}'.format(path))
63 with open(path, 'r') as f:
65 except Exception as ex:
66 print('Unable to read the core issue list', file=sys.stderr)
67 print(ex, file=sys.stderr)
70 return sorted((parse(dr) for dr in buffer.split('<TR>')[2:]),
71 key = lambda dr: dr.issue)
74 issue_list_path = None
75 if len(sys.argv) == 1:
77 elif len(sys.argv) == 2:
78 issue_list_path = sys.argv[1]
80 print('Usage: {} [<path to cwg_index.html>]'.format(sys.argv[0]), file=sys.stderr)
83 status_map = collect_tests()
84 drs = get_issues(issue_list_path)
85 out_file = open(output, 'w')
88 <!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
91 <META http-equiv="Content-Type" content="text/html; charset=utf-8">
92 <title>Clang - C++ Defect Report Status</title>
93 <link type="text/css" rel="stylesheet" href="menu.css">
94 <link type="text/css" rel="stylesheet" href="content.css">
95 <style type="text/css">
96 .none { background-color: #FFCCCC }
97 .partial { background-color: #FFE0B0 }
98 .unreleased { background-color: #FFFF99 }
99 .full { background-color: #CCFF99 }
100 .na { background-color: #DDDDDD }
101 .open * { color: #AAAAAA }
102 //.open { filter: opacity(0.2) }
103 tr:target { background-color: #FFFFBB }
104 th { background-color: #FFDDAA }
109 <!--#include virtual="menu.html.incl"-->
113 <!--*************************************************************************-->
114 <h1>C++ Defect Report Support in Clang</h1>
115 <!--*************************************************************************-->
117 <h2 id="cxxdr">C++ defect report implementation status</h2>
119 <p>This page tracks which C++ defect reports are implemented within Clang.</p>
121 <table width="689" border="1" cellspacing="0">
126 <th>Available in Clang?</th>
131 def availability(issue):
132 status = status_map.get(issue, 'unknown')
134 unresolved_status = ''
135 if status.endswith(' open'):
137 unresolved_status = 'open'
138 elif status.endswith(' drafting'):
140 unresolved_status = 'drafting'
141 elif status.endswith(' review'):
143 unresolved_status = 'review'
146 if status.endswith(' c++11'):
148 avail_suffix = ' (C++11 onwards)'
149 elif status.endswith(' c++14'):
151 avail_suffix = ' (C++14 onwards)'
152 elif status.endswith(' c++17'):
154 avail_suffix = ' (C++17 onwards)'
155 elif status.endswith(' c++20'):
157 avail_suffix = ' (C++20 onwards)'
158 if status == 'unknown':
160 avail_style = ' class="none"'
161 elif re.match('^[0-9]+\.?[0-9]*', status):
162 avail = 'Clang %s' % status
163 if float(status) > latest_release:
164 avail_style = ' class="unreleased"'
166 avail_style = ' class="full"'
167 elif status == 'yes':
169 avail_style = ' class="full"'
170 elif status == 'partial':
172 avail_style = ' class="partial"'
175 avail_style = ' class="none"'
178 avail_style = ' class="na"'
179 elif status == 'na lib':
180 avail = 'N/A (Library DR)'
181 avail_style = ' class="na"'
182 elif status == 'na abi':
183 avail = 'N/A (ABI constraint)'
184 avail_style = ' class="na"'
185 elif status.startswith('sup '):
186 dup = status.split(' ', 1)[1]
187 if dup.startswith('P'):
188 avail = 'Superseded by <a href="https://wg21.link/%s">%s</a>' % (dup, dup)
189 avail_style = ' class="na"'
191 avail = 'Superseded by <a href="#%s">%s</a>' % (dup, dup)
193 _, avail_style, _ = availability(int(dup))
195 print("issue %s marked as sup %s" % (issue, dup), file=sys.stderr)
196 avail_style = ' class="none"'
197 elif status.startswith('dup '):
198 dup = int(status.split(' ', 1)[1])
199 avail = 'Duplicate of <a href="#%s">%s</a>' % (dup, dup)
200 _, avail_style, _ = availability(dup)
202 assert False, 'unknown status %s for issue %s' % (status, dr.issue)
203 return (avail + avail_suffix, avail_style, unresolved_status)
207 if dr.status in ('concepts',):
208 # This refers to the old ("C++0x") concepts feature, which was not part
209 # of any C++ International Standard or Technical Specification.
212 elif dr.status == 'extension':
213 row_style = ' class="open"'
217 elif dr.status in ('open', 'drafting', 'review'):
218 row_style = ' class="open"'
219 avail, avail_style, unresolved_status = availability(dr.issue)
220 if avail == 'Unknown':
221 avail = 'Not resolved'
224 assert unresolved_status == dr.status, \
225 "Issue %s is marked '%s', which differs from CWG index status '%s'" \
226 % (dr.issue, unresolved_status, dr.status)
229 avail, avail_style, unresolved_status = availability(dr.issue)
230 assert not unresolved_status, \
231 "Issue %s is marked '%s', even though it is resolved in CWG index" \
232 % (dr.issue, unresolved_status)
234 if not avail.startswith('Sup') and not avail.startswith('Dup'):
235 count[avail] = count.get(avail, 0) + 1
239 <td><a href="https://cplusplus.github.io/CWG/issues/%s.html">%s</a></td>
242 <td%s align="center">%s</td>
243 </tr>''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
245 for status, num in sorted(count.items()):
246 print("%s: %s" % (status, num), file=sys.stderr)