X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fbertos_utils.py;h=933d9ed5175fec2bfe8fd5a12fac10a96a93533e;hb=3663cfe1d69a9bd57c3c52a33afeaf000d23b10a;hp=ceb75ab4306f106e6e954cba3ce9e51b9eae0d9c;hpb=39f8477d1ca72e8579ae5edcc879f1bd25287555;p=bertos.git diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index ceb75ab4..933d9ed5 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -358,14 +358,23 @@ def getDefinitionBlocks(text): Take a text and return a list of tuple (description, name-value). """ block = [] - block_tmp = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/\s*#define\s+((?:[^/]*?/?)+)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE) - for comment, define in block_tmp: + block_tmp = re.finditer(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/\s*#define\s+((?:[^/]*?/?)+)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE) + for match in block_tmp: # Only the first element is needed - block.append(([re.findall(r"^\s*\* *(.*?)$", line, re.MULTILINE)[0] for line in comment.splitlines()], define)) - for comment, define in re.findall(r"/{3}\s*([^<].*?)\s*#define\s+((?:[^/]*?/?)+)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE): - block.append(([comment], define)) - for define, comment in re.findall(r"#define\s*(.*?)\s*/{3}<\s*(.+?)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE): - block.append(([comment], define)) + comment = match.group(1) + define = match.group(2) + start = match.start() + block.append(([re.findall(r"^\s*\* *(.*?)$", line, re.MULTILINE)[0] for line in comment.splitlines()], define, start)) + for match in re.finditer(r"/{3}\s*([^<].*?)\s*#define\s+((?:[^/]*?/?)+)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE): + comment = match.group(1) + define = match.group(2) + start = match.start() + block.append(([comment], define, start)) + for match in re.finditer(r"#define\s*(.*?)\s*/{3}<\s*(.+?)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE): + comment = match.group(2) + define = match.group(1) + start = match.start() + block.append(([comment], define, start)) return block def loadModuleData(project): @@ -433,7 +442,7 @@ def loadConfigurationInfos(path): "value_list": the name of the enum for enum parameters """ configuration_infos = {} - for comment, define in getDefinitionBlocks(open(path, "r").read()): + for comment, define, start in getDefinitionBlocks(open(path, "r").read()): name, value = formatParamNameValue(define) brief, description, informations = getDescriptionInformations(comment) configuration_infos[name] = {}