scripts:Unique error enum update for 1/25/2017
Hadn't had a spec update in quite a while so this one was huge.
Also the format of the spec itself changed which required a number of
changes to the spec parser. The spec script is still broken for the
online spec which is not valid xhtml. For this update I downloaded the
spec source and hand-edited the broken parts so that the spec parser
could deal with it. Will figure out a better solution going forward,
though.
Here's the beast of a command line for this update:
python spec.py -spec test_xhtml_spec_039.html -update -remap 214-180,3:\
269-220,3:361-289:371-299:373-301:409-334,10:470-404,12:483-416,6:\
768-625,10:948-754,2:951-756,4:970-760,8:979-769:989-778,4:1031-812,16:\
1048-828,16:1158-936:1160-937,10:1171-947,12:1189-965:1190-966,2:\
1192-968:1251-1027,33:1371-1141:1408-1175,3:1412-1178:1414-1179,2:\
1417-1181:1419-1182,15:1435-1198,2:1627-1343,7:1646-1359,2:1668-1366,2:\
1720-1383:1783-1395:1871-1449:1878-1455,16:1977-1554,5:2012-1565,9:\
1992-1559,4:1997-1563,2:2202-1615:2222-1635,2:1047-1741:2313-1844,7:\
2361-1878,5:2370-1883,6:956-2161,13:1650-2201:1672-2214:1696-2229,2:\
1729-2249,2:1759-2267,2:1793-2288,2:1982-2304,6:1990-2313:1999-2314,13:\
2366-2327,4:1159-2348:968-2524:1413-2533:1418-2534:983-772,4:2512-1680:\
2587-2040:1996-2547:1170-2525:969-2173
diff --git a/layers/spec.py b/layers/spec.py
index bcece95..671bd27 100644
--- a/layers/spec.py
+++ b/layers/spec.py
@@ -124,39 +124,40 @@
implicit_count = 0
for tag in self.root.iter(): # iterate down tree
# Grab most recent section heading and link
- if tag.tag in ['{http://www.w3.org/1999/xhtml}h2', '{http://www.w3.org/1999/xhtml}h3']:
- if tag.get('class') != 'title':
- continue
- #print "Found heading %s" % (tag.tag)
+ if tag.tag in ['h2', 'h3', 'h4']:
+ #if tag.get('class') != 'title':
+ # continue
+ print "Found heading %s" % (tag.tag)
prev_heading = "".join(tag.itertext())
# Insert a space between heading number & title
sh_list = prev_heading.rsplit('.', 1)
prev_heading = '. '.join(sh_list)
- prev_link = tag[0].get('id')
- #print "Set prev_heading %s to have link of %s" % (prev_heading.encode("ascii", "ignore"), prev_link.encode("ascii", "ignore"))
- elif tag.tag == '{http://www.w3.org/1999/xhtml}a': # grab any intermediate links
+ prev_link = tag.get('id')
+ print "Set prev_heading %s to have link of %s" % (prev_heading.encode("ascii", "ignore"), prev_link.encode("ascii", "ignore"))
+ elif tag.tag == 'a': # grab any intermediate links
if tag.get('id') != None:
prev_link = tag.get('id')
#print "Updated prev link to %s" % (prev_link)
- elif tag.tag == '{http://www.w3.org/1999/xhtml}pre' and tag.get('class') == 'programlisting':
+ elif tag.tag == 'div' and tag.get('class') == 'listingblock':
# Check and see if this is API function
code_text = "".join(tag.itertext()).replace('\n', '')
code_text_list = code_text.split()
if len(code_text_list) > 1 and code_text_list[1].startswith('vk'):
api_function = code_text_list[1].strip('(')
- #print "Found API function: %s" % (api_function)
- elif tag.tag == '{http://www.w3.org/1999/xhtml}div' and tag.get('class') == 'sidebar':
+ print "Found API function: %s" % (api_function)
+ #elif tag.tag == '{http://www.w3.org/1999/xhtml}div' and tag.get('class') == 'sidebar':
+ elif tag.tag == 'div' and tag.get('class') == 'content':
# parse down sidebar to check for valid usage cases
valid_usage = False
implicit = False
for elem in tag.iter():
- if elem.tag == '{http://www.w3.org/1999/xhtml}strong' and None != elem.text and 'Valid Usage' in elem.text:
+ if elem.tag == 'div' and None != elem.text and 'Valid Usage' in elem.text:
valid_usage = True
if '(Implicit)' in elem.text:
implicit = True
else:
implicit = False
- elif valid_usage and elem.tag == '{http://www.w3.org/1999/xhtml}li': # grab actual valid usage requirements
+ elif valid_usage and elem.tag == 'li': # grab actual valid usage requirements
error_msg_str = "%s '%s' which states '%s' (%s#%s)" % (error_msg_prefix, prev_heading, "".join(elem.itertext()).replace('\n', ''), spec_url, prev_link)
# Some txt has multiple spaces so split on whitespace and join w/ single space
error_msg_str = " ".join(error_msg_str.split())
@@ -188,11 +189,13 @@
file_contents.append('// parameter to the PFN_vkDebugReportCallbackEXT function')
enum_decl = ['enum UNIQUE_VALIDATION_ERROR_CODE {\n VALIDATION_ERROR_UNDEFINED = -1,']
error_string_map = ['static std::unordered_map<int, char const *const> validation_error_map{']
+ enum_value = 0
for enum in sorted(self.val_error_dict):
#print "Header enum is %s" % (enum)
- enum_decl.append(' %s = %d,' % (enum, int(enum.split('_')[-1])))
+ enum_value = int(enum.split('_')[-1])
+ enum_decl.append(' %s = %d,' % (enum, enum_value))
error_string_map.append(' {%s, "%s"},' % (enum, self.val_error_dict[enum]['error_msg']))
- enum_decl.append(' %sMAX_ENUM = %d,' % (validation_error_enum_name, int(enum.split('_')[-1]) + 1))
+ enum_decl.append(' %sMAX_ENUM = %d,' % (validation_error_enum_name, enum_value + 1))
enum_decl.append('};')
error_string_map.append('};\n')
file_contents.extend(enum_decl)