[docs] Update HowToReleaseLLVM documentation.
[llvm-project.git] / clang / www / make_cxx_dr_status
blob11b17f0444373f824e77d03494b309c72a6a6fa8
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')
11 class DR:
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
15   def __repr__(self):
16     return '%s (%s): %s' % (self.issue, self.status, self.title)
18 def parse(dr):
19   try:
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:]
23     ]
24   except Exception as ex:
25     print(f"Parse error: {ex}\n{dr}", file=sys.stderr)
26     sys.exit(1)
27   _, url, issue = issue_link.split('"', 2)
28   url = url.strip()
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)
33 def collect_tests():
34   status_re = re.compile(r'\bdr([0-9]+): (.*)')
35   status_map = {}
36   for test_cpp in os.listdir(dr_test_dir):
37     if not test_cpp.endswith('.cpp'):
38       continue
39     test_cpp = os.path.join(dr_test_dir, test_cpp)
40     found_any = False;
41     for match in re.finditer(status_re, open(test_cpp, 'r').read()):
42       status_map[int(match.group(1))] = match.group(2)
43       found_any = True
44     if not found_any:
45       print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
46   return status_map
48 def get_issues(path):
49   buffer = None
50   if not path and os.path.exists(default_issue_list_path):
51     path = default_issue_list_path
52   try:
53     if path is None:
54       print('Fetching issue list from {}'.format(issue_list_url))
55       with urllib.request.urlopen(issue_list_url) as f:
56         buffer = f.read().decode('utf-8')
57     else:
58       print('Opening issue list from file {}'.format(path))
59       with open(path, 'r') as f:
60         buffer = f.read()
61   except Exception as ex:
62      print('Unable to read the core issue list', file=sys.stderr)
63      print(ex, file=sys.stderr)
64      sys.exit(1)
66   return sorted((parse(dr) for dr in buffer.split('<TR>')[2:]),
67                 key = lambda dr: dr.issue)
70 issue_list_path  = None
71 if len(sys.argv) == 1:
72   pass
73 elif len(sys.argv) == 2:
74   issue_list_path = sys.argv[1]
75 else:
76   print('Usage: {} [<path to cwg_index.html>]'.format(sys.argv[0]), file=sys.stderr)
77   sys.exit(1)
79 status_map = collect_tests()
80 drs = get_issues(issue_list_path)
81 out_file = open(output, 'w')
82 out_file.write('''\
83 <!DOCTYPE html>
84 <!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
85 <html>
86 <head>
87   <META http-equiv="Content-Type" content="text/html; charset=utf-8">
88   <title>Clang - C++ Defect Report Status</title>
89   <link type="text/css" rel="stylesheet" href="menu.css">
90   <link type="text/css" rel="stylesheet" href="content.css">
91   <style type="text/css">
92     .none { background-color: #FFCCCC }
93     .partial { background-color: #FFE0B0 }
94     .unreleased { background-color: #FFFF99 }
95     .full { background-color: #CCFF99 }
96     .na { background-color: #DDDDDD }
97     .open * { color: #AAAAAA }
98     //.open { filter: opacity(0.2) }
99     tr:target { background-color: #FFFFBB }
100     th { background-color: #FFDDAA }
101   </style>
102 </head>
103 <body>
105 <!--#include virtual="menu.html.incl"-->
107 <div id="content">
109 <!--*************************************************************************-->
110 <h1>C++ Defect Report Support in Clang</h1>
111 <!--*************************************************************************-->
113 <h2 id="cxxdr">C++ defect report implementation status</h2>
115 <p>This page tracks which C++ defect reports are implemented within Clang.</p>
117 <table width="689" border="1" cellspacing="0">
118   <tr>
119     <th>Number</th>
120     <th>Status</th>
121     <th>Issue title</th>
122     <th>Available in Clang?</th>
123   </tr>''')
125 latest_release = 15
127 def availability(issue):
128   status = status_map.get(issue, 'unknown')
130   unresolved_status = ''
131   if status.endswith(' open'):
132     status = status[:-5]
133     unresolved_status = 'open'
134   elif status.endswith(' drafting'):
135     status = status[:-9]
136     unresolved_status = 'drafting'
137   elif status.endswith(' review'):
138     status = status[:-7]
139     unresolved_status = 'review'
141   avail_suffix = ''
142   if status.endswith(' c++11'):
143     status = status[:-6]
144     avail_suffix = ' (C++11 onwards)'
145   elif status.endswith(' c++14'):
146     status = status[:-6]
147     avail_suffix = ' (C++14 onwards)'
148   elif status.endswith(' c++17'):
149     status = status[:-6]
150     avail_suffix = ' (C++17 onwards)'
151   elif status.endswith(' c++20'):
152     status = status[:-6]
153     avail_suffix = ' (C++20 onwards)'
154   if status == 'unknown':
155     avail = 'Unknown'
156     avail_style = ' class="none"'
157   elif re.match('^[0-9]+\.?[0-9]*', status):
158     avail = 'Clang %s' % status
159     if float(status) > latest_release:
160       avail_style = ' class="unreleased"'
161     else:
162       avail_style = ' class="full"'
163   elif status == 'yes':
164     avail = 'Yes'
165     avail_style = ' class="full"'
166   elif status == 'partial':
167     avail = 'Partial'
168     avail_style = ' class="partial"'
169   elif status == 'no':
170     avail = 'No'
171     avail_style = ' class="none"'
172   elif status == 'na':
173     avail = 'N/A'
174     avail_style = ' class="na"'
175   elif status == 'na lib':
176     avail = 'N/A (Library DR)'
177     avail_style = ' class="na"'
178   elif status == 'na abi':
179     avail = 'N/A (ABI constraint)'
180     avail_style = ' class="na"'
181   elif status.startswith('sup '):
182     dup = status.split(' ', 1)[1]
183     if dup.startswith('P'):
184       avail = 'Superseded by <a href="https://wg21.link/%s">%s</a>' % (dup, dup)
185       avail_style = ' class="na"'
186     else:
187       avail = 'Superseded by <a href="#%s">%s</a>' % (dup, dup)
188       try:
189         _, avail_style, _ = availability(int(dup))
190       except:
191         print("issue %s marked as sup %s" % (issue, dup), file=sys.stderr)
192         avail_style = ' class="none"'
193   elif status.startswith('dup '):
194     dup = int(status.split(' ', 1)[1])
195     avail = 'Duplicate of <a href="#%s">%s</a>' % (dup, dup)
196     _, avail_style, _ = availability(dup)
197   else:
198     assert False, 'unknown status %s for issue %s' % (status, dr.issue)
199   return (avail + avail_suffix, avail_style, unresolved_status)
201 count = {}
202 for dr in drs:
203   if dr.status in ('concepts',):
204     # This refers to the old ("C++0x") concepts feature, which was not part
205     # of any C++ International Standard or Technical Specification.
206     continue
208   elif dr.status == 'extension':
209     row_style = ' class="open"'
210     avail = 'Extension'
211     avail_style = ''
213   elif dr.status in ('open', 'drafting', 'review'):
214     row_style = ' class="open"'
215     avail, avail_style, unresolved_status = availability(dr.issue)
216     if avail == 'Unknown':
217       avail = 'Not resolved'
218       avail_style = ''
219     else:
220       assert unresolved_status == dr.status, \
221              "Issue %s is marked '%s', which differs from CWG index status '%s'" \
222              % (dr.issue, unresolved_status, dr.status)
223   else:
224     row_style = ''
225     avail, avail_style, unresolved_status = availability(dr.issue)
226     assert not unresolved_status, \
227            "Issue %s is marked '%s', even though it is resolved in CWG index" \
228            % (dr.issue, unresolved_status)
230   if not avail.startswith('Sup') and not avail.startswith('Dup'):
231     count[avail] = count.get(avail, 0) + 1
233   out_file.write('''
234   <tr%s id="%s">
235     <td><a href="https://cplusplus.github.io/CWG/issues/%s.html">%s</a></td>
236     <td>%s</td>
237     <td>%s</td>
238     <td%s align="center">%s</td>
239   </tr>''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
241 for status, num in sorted(count.items()):
242   print("%s: %s" % (status, num), file=sys.stderr)
244 out_file.write('''\
245 </table>
247 </div>
248 </body>
249 </html>
250 ''')
251 out_file.close()