make_cxx_dr_status revision e3a404411fe651097024edece9a72afeef5f6ac3
1#! /usr/bin/env python
2import sys, os, re
3
4index = 'cwg_index.html'
5output = 'cxx_dr_status.html'
6dr_test_dir = '../test/CXX/drs'
7
8if len(sys.argv) == 1:
9  pass
10elif len(sys.argv) == 2:
11  index = sys.argv[1]
12else:
13  print >>sys.stderr, 'Usage: make_drs [<path to cwg_index.html>]'
14  sys.exit(1)
15
16class DR:
17  def __init__(self, section, issue, url, status, title):
18    self.section, self.issue, self.url, self.status, self.title = \
19        section, issue, url, status, title
20  def __repr__(self):
21    return '%s (%s): %s' % (self.issue, self.status, self.title)
22
23def parse(dr):
24  section, issue_link, status, title = [
25      col.split('>', 1)[1].split('</TD>')[0]
26      for col in dr.split('</TR>', 1)[0].split('<TD')[1:]
27  ]
28  _, url, issue = issue_link.split('"', 2)
29  url = url.strip()
30  issue = int(issue.split('>', 1)[1].split('<', 1)[0])
31  title = title.replace('<issue_title>', '').replace('</issue_title>', '').strip()
32  return DR(section, issue, url, status, title)
33
34status_re = re.compile(r'\bdr([0-9]+): (.*)')
35status_map = {}
36for 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, file(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 >> sys.stderr, "warning:%s: no '// dr123: foo' comments in this file" % test_cpp
46
47drs = sorted((parse(dr) for dr in file(index, 'r').read().split('<TR>')[2:]),
48             key = lambda dr: dr.issue)
49out_file = file(output, 'w')
50
51print >> out_file, '''\
52<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
53          "http://www.w3.org/TR/html4/strict.dtd">
54<html>
55<head>
56  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
57  <title>Clang - C++ Defect Report Status</title>
58  <link type="text/css" rel="stylesheet" href="menu.css">
59  <link type="text/css" rel="stylesheet" href="content.css">
60  <style type="text/css">
61    .none { background-color: #FFCCCC }
62    .partial { background-color: #FFE0B0 }
63    .svn  { background-color: #FFFF99 }
64    .full { background-color: #CCFF99 }
65    .na { background-color: #DDDDDD }
66    .open * { color: #AAAAAA }
67    //.open { filter: opacity(0.2) }
68    span:target { background-color: #FFFFBB; outline: #DDDD55 solid thin; }
69    th { background-color: #FFDDAA }
70  </style>
71</head>
72<body>
73
74<!--#include virtual="menu.html.incl"-->
75
76<div id="content">
77
78<!--*************************************************************************-->
79<h1>C++ Defect Report Support in Clang</h1>
80<!--*************************************************************************-->
81<p>Last updated: $Date$</p>
82
83<h2 id="cxxdr">C++ defect report implementation status</h2>
84
85<p>This page tracks which C++ defect reports are implemented within Clang.</p>
86
87<table width="689" border="1" cellspacing="0">
88  <tr>
89    <th>Number</th>
90    <th>Status</th>
91    <th>Issue title</th>
92    <th>Available in Clang?</th>
93  </tr>'''
94
95def availability(issue):
96  status = status_map.get(issue, 'unknown')
97  avail_suffix = ''
98  if status.endswith(' c++11'):
99    status = status[:-6]
100    avail_suffix = ' (C++11 onwards)'
101  if status == 'unknown':
102    avail = 'Unknown'
103    avail_style = ' class="none"'
104  elif status == '3.4':
105    avail = 'SVN'
106    avail_style = ' class="svn"'
107  elif status in ('3.1', '3.2', '3.3'):
108    avail = 'Clang %s' % status
109    avail_style = ' class="full"'
110  elif status == 'yes':
111    avail = 'Yes'
112    avail_style = ' class="full"'
113  elif status == 'partial':
114    avail = 'Partial'
115    avail_style = ' class="partial"'
116  elif status == 'no':
117    avail = 'No'
118    avail_style = ' class="none"'
119  elif status == 'na':
120    avail = 'N/A'
121    avail_style = ' class="na"'
122  elif status.startswith('sup '):
123    dup = status.split(' ', 1)[1]
124    avail = 'Superseded by %s' % dup
125    try:
126      _, avail_style = availability(int(dup))
127    except:
128      print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
129      avail_style = ' class="none"'
130  elif status.startswith('dup '):
131    dup = int(status.split(' ', 1)[1])
132    avail = 'Duplicate of %s' % dup
133    _, avail_style = availability(dup)
134  else:
135    assert False, 'unknown status %s for issue %s' % (status, dr.issue)
136  return (avail + avail_suffix, avail_style)
137
138count = {}
139for dr in drs:
140  if dr.status in ('concepts',):
141    # Yeah, cool story bro.
142    continue
143  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
144    # We may have to deal with these some day, but not yet.
145    row_style = ' class="open"'
146    avail = 'Not resolved'
147    avail_style = ''
148    assert dr.issue not in status_map, "have status for not-ready dr %s" % dr.issue
149  else:
150    row_style = ''
151    avail, avail_style = availability(dr.issue)
152    if not avail.startswith('Sup') and not avail.startswith('Dup'):
153      count[avail] = count.get(avail, 0) + 1
154
155  print >> out_file, '''\
156  <tr%s>
157    <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/%s">%s</a></td>
158    <td>%s</td>
159    <td>%s</td>
160    <td%s align="center">%s</td>
161  </tr>''' % (row_style, dr.url, dr.issue, dr.status, dr.title, avail_style,
162              avail)
163
164for status, num in count.items():
165  print "%s: %s" % (status, num)
166
167print >> out_file, '''\
168</table>
169
170</div>
171</body>
172</html>'''
173