Handle !define in JSON #if fields - fixes docs

This commit is contained in:
Gordon Williams 2022-01-11 13:23:12 +00:00
parent 0eee205e88
commit 1eb760cadb

View File

@ -382,10 +382,19 @@ for jsondata in detail:
if "ifndef" in jsondata:
desc.append("\n\n**Note:** This is not available in "+common.get_ifdef_description(jsondata["ifndef"]));
if "#if" in jsondata:
d = jsondata["#if"].replace("||", " and ").replace("&&", " with ")
d = jsondata["#if"];
dprefix = "This is only available in ";
if re.match('^!defined\((.+?)\) && !defined\((.+?)\)$', d):
dprefix = "This is not available in ";
d = re.sub('^!defined\((.+?)\) && !defined\((.+?)\)$', "defined(\\1) or defined(\\2)", d)
if re.match('^!defined\((.+?)\)$', d):
dprefix = "This is not available in ";
d = re.sub('^!defined\((.+?)\)$', "defined(\\1)", d)
d = re.sub('!defined\(', "not defined(", d)
d = d.replace("||", " and ").replace("&&", " with ")
d = re.sub('defined\((.+?)\)', replace_with_ifdef_description, d)
d = re.sub('(.*)_COUNT>=(.*)', "devices with more than \\2 \\1 peripherals", d)
desc.append("\n\n**Note:** This is only available in "+d);
desc.append("\n\n**Note:** "+dprefix+d);
html_description(desc, jsondata["name"])