Loading asn2md.py +19 −8 Original line number Diff line number Diff line Loading @@ -43,11 +43,12 @@ RE_DOXY_CLASS = re.compile(r'@class:?\s+([\w-]+)') RE_DOXY_STRIP_SINGLE_TAG = re.compile(r'@(?:brief|url|details)\s+') RE_DOXY_DETAILS = re.compile(r'@details:?\s+[\w-]+') RE_DOXY_STRIP_TAG = re.compile(r'\s*@(?:class|struct):?\s+[\w-]+') RE_DOXY_UNIT = re.compile(r'^\s*@unit:?\s+(.+)\n', re.MULTILINE) RE_DOXY_BRIEF = re.compile(r'^\s*@brief:?\s+(.+)\n', re.MULTILINE) RE_DOXY_CATEGORY = re.compile(r'@category:\s+(.+)\n', re.MULTILINE) RE_DOXY_NOTE = re.compile(r'@note:\s+(.+)\n', re.MULTILINE) RE_DOXY_PARAM = re.compile(r'^\s*@(?:param|field):?\s+([\w-]+)\s*(.*?)\n\s*$', re.MULTILINE | re.DOTALL) RE_DOXY_UNIT = re.compile(r'^\s*@unit:?\s+(.+)\n+', re.MULTILINE) RE_DOXY_BRIEF = re.compile(r'^\s*@brief:?\s+(.+)\n+', re.MULTILINE) RE_DOXY_CATEGORY = re.compile(r'@category:\s+(.+)\n+', re.MULTILINE) RE_DOXY_NOTE = re.compile(r'@note:\s+(.+)\n+', re.MULTILINE) RE_DOXY_PARAM = re.compile(r'^\s*@(?:param|field|value)\s+([\w-]+):?\s*(.*?)\n\s*$', re.MULTILINE | re.DOTALL) RE_DOXY_OPTION = re.compile(r'@(no-auto-fields|no-auto-values)', re.MULTILINE) # RE_TYPE = re.compile(r'(([A-Z][\w-]*)\s*::=[\w \t]+(?:{+(.*?)}+)?.*?)\n\s*\n', re.MULTILINE | re.DOTALL) RE_TYPE = re.compile(r'^\s*([A-Z][\w-]*)?\s*([{} \t:\w-]*?)?::=([\w \t]+.*?)\n\s*\n', re.MULTILINE | re.DOTALL) Loading Loading @@ -158,6 +159,7 @@ def parseModule(mname, content): # parse types def repl_type (m, doc): title = t = m.group(1) auto_fields = True if doc : # non None and not empty def repl_brief (m): nonlocal title Loading @@ -165,6 +167,13 @@ def parseModule(mname, content): return '\n' if o_args.brief_as_title: doc = RE_DOXY_BRIEF.sub(repl_brief, doc, 1) def repl_doxy_option(m): nonlocal auto_fields if m.group(1) == 'no-auto-fields' or m.group(1) == 'no-auto-values': auto_fields = False return '' doc = RE_DOXY_OPTION.sub(repl_doxy_option, doc) doc = parseDoxyComments(doc) + '\n\n' else: doc = '' Loading Loading @@ -218,8 +227,10 @@ def parseModule(mname, content): # keep '--' for the next round pos -= 2 fields += parseInlineComments(typeBody[pos:], 3) if len(fields): ret = ret.strip() + '\n\n' + fTitle + fields ret = ret.strip() + '\n\n' if auto_fields and len(fields): ret += fTitle + fields else: if title: ret = '### {}\n\n'.format(title) Loading Loading
asn2md.py +19 −8 Original line number Diff line number Diff line Loading @@ -43,11 +43,12 @@ RE_DOXY_CLASS = re.compile(r'@class:?\s+([\w-]+)') RE_DOXY_STRIP_SINGLE_TAG = re.compile(r'@(?:brief|url|details)\s+') RE_DOXY_DETAILS = re.compile(r'@details:?\s+[\w-]+') RE_DOXY_STRIP_TAG = re.compile(r'\s*@(?:class|struct):?\s+[\w-]+') RE_DOXY_UNIT = re.compile(r'^\s*@unit:?\s+(.+)\n', re.MULTILINE) RE_DOXY_BRIEF = re.compile(r'^\s*@brief:?\s+(.+)\n', re.MULTILINE) RE_DOXY_CATEGORY = re.compile(r'@category:\s+(.+)\n', re.MULTILINE) RE_DOXY_NOTE = re.compile(r'@note:\s+(.+)\n', re.MULTILINE) RE_DOXY_PARAM = re.compile(r'^\s*@(?:param|field):?\s+([\w-]+)\s*(.*?)\n\s*$', re.MULTILINE | re.DOTALL) RE_DOXY_UNIT = re.compile(r'^\s*@unit:?\s+(.+)\n+', re.MULTILINE) RE_DOXY_BRIEF = re.compile(r'^\s*@brief:?\s+(.+)\n+', re.MULTILINE) RE_DOXY_CATEGORY = re.compile(r'@category:\s+(.+)\n+', re.MULTILINE) RE_DOXY_NOTE = re.compile(r'@note:\s+(.+)\n+', re.MULTILINE) RE_DOXY_PARAM = re.compile(r'^\s*@(?:param|field|value)\s+([\w-]+):?\s*(.*?)\n\s*$', re.MULTILINE | re.DOTALL) RE_DOXY_OPTION = re.compile(r'@(no-auto-fields|no-auto-values)', re.MULTILINE) # RE_TYPE = re.compile(r'(([A-Z][\w-]*)\s*::=[\w \t]+(?:{+(.*?)}+)?.*?)\n\s*\n', re.MULTILINE | re.DOTALL) RE_TYPE = re.compile(r'^\s*([A-Z][\w-]*)?\s*([{} \t:\w-]*?)?::=([\w \t]+.*?)\n\s*\n', re.MULTILINE | re.DOTALL) Loading Loading @@ -158,6 +159,7 @@ def parseModule(mname, content): # parse types def repl_type (m, doc): title = t = m.group(1) auto_fields = True if doc : # non None and not empty def repl_brief (m): nonlocal title Loading @@ -165,6 +167,13 @@ def parseModule(mname, content): return '\n' if o_args.brief_as_title: doc = RE_DOXY_BRIEF.sub(repl_brief, doc, 1) def repl_doxy_option(m): nonlocal auto_fields if m.group(1) == 'no-auto-fields' or m.group(1) == 'no-auto-values': auto_fields = False return '' doc = RE_DOXY_OPTION.sub(repl_doxy_option, doc) doc = parseDoxyComments(doc) + '\n\n' else: doc = '' Loading Loading @@ -218,8 +227,10 @@ def parseModule(mname, content): # keep '--' for the next round pos -= 2 fields += parseInlineComments(typeBody[pos:], 3) if len(fields): ret = ret.strip() + '\n\n' + fTitle + fields ret = ret.strip() + '\n\n' if auto_fields and len(fields): ret += fTitle + fields else: if title: ret = '### {}\n\n'.format(title) Loading