From: Timo Heister Date: Sun, 7 Feb 2016 00:47:56 +0000 (-0500) Subject: wrapcomments.py: numbered list support X-Git-Tag: v8.4.0-rc2~27^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a484da5a09adf59486b2b7847bf2edd7129a0a14;p=dealii.git wrapcomments.py: numbered list support --- diff --git a/contrib/utilities/wrapcomments.py b/contrib/utilities/wrapcomments.py index 61ce6144ea..8a0d93f67f 100755 --- a/contrib/utilities/wrapcomments.py +++ b/contrib/utilities/wrapcomments.py @@ -8,7 +8,7 @@ from __future__ import print_function import textwrap -import sys +import sys, re wrapper = textwrap.TextWrapper() # take an array of lines and wrap them to 78 columns and let each line start @@ -116,7 +116,15 @@ def format_block(lines, infostr=""): if it in thisline and thisline!=it: print ("%s warning %s not in separate line"%(infostr, it), file=sys.stderr) out.append(start + thisline) - elif starts_with_one(["* - ", "* - "],lines[idx].strip()): + elif re.match(r'\*\s+- ',lines[idx].strip()): + # bullet ('-') list + if curlines!=[]: + out.extend(wrap_block(remove_junk(curlines), start)) + curlines=[] + thisline = lines[idx].strip()[2:] + out.append(start + thisline) + elif lines[idx].strip().startswith("* ") and re.match(r'\s*\d+.',lines[idx][3:]): + # numbered list if curlines!=[]: out.extend(wrap_block(remove_junk(curlines), start)) curlines=[] @@ -441,6 +449,7 @@ lineI = [" /**", \ " * - C", \ " * - D", \ " * - E", \ + " * - very indented", \ " */"] lineO = lineI assert(format_block(lineI)==lineO) @@ -472,9 +481,35 @@ lineI = [" /**", \ " * bla", \ " */"] lineO = lineI -#print (lineI, "\n",format_block(lineI)) assert(format_block(lineI)==lineO) +# lists +lineI = [" /**", \ + " * Hello:", \ + " * - a", \ + " * - b", \ + " * the end.", \ + " */"] +lineO = lineI +assert(format_block(lineI)==lineO) + +# numbered lists +lineI = [" /**", \ + " * Hello:", \ + " * 1. a", \ + " * 2. b", \ + " * the end.", \ + " */"] +lineO = lineI +assert(format_block(lineI)==lineO) + + + +#print (lineI) +#print (format_block(lineI)) + + + # now open the file and do the work