From 9043ad1d529ea2753fb9b45cd4c8b8078220a3ad Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 24 Dec 2014 09:25:02 -0500 Subject: [PATCH] update wrapcomments.py now handle @image tags correctly --- contrib/utilities/wrapcomments.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/contrib/utilities/wrapcomments.py b/contrib/utilities/wrapcomments.py index 8ee0ec6b73..52cf0b120c 100755 --- a/contrib/utilities/wrapcomments.py +++ b/contrib/utilities/wrapcomments.py @@ -12,7 +12,7 @@ import sys import string wrapper = textwrap.TextWrapper() -# take an array of lines and wrap them to 78 columns and let each lines start +# take an array of lines and wrap them to 78 columns and let each line start # with @p startwith def wrap_block(lines, startwith): longline = " ".join(lines) @@ -87,12 +87,16 @@ def format_block(lines, infostr=""): idx = string.find(lines[0],"/**") start = lines[0][:idx]+" * " - out = [lines[0]] + out = [lines[0].rstrip()] idx = 1 endidx = len(lines)-1 curlines = [] - ops_startline = ["
  • ", "@param", "@returns", "@warning", "@ingroup", "@author", "@date", "@related", "@deprecated"] + ops_startline = ["
  • ", "@param", "@returns", "@warning", "@ingroup", "@author", "@date", "@related", "@deprecated", "@image"] + + # subset of ops_startline that does not want stuff from the next line appended + # to this. + ops_also_end_paragraph = ["@image"] ops_separate_line = ["
      ", "
    ", "", "@{", "@}", "
    "] @@ -115,7 +119,10 @@ def format_block(lines, infostr=""): for it in ops_startline: if it in thisline: print ("%s warning %s not at start of line"%(infostr, it), file=sys.stderr) - curlines.append(lines[idx]) + if one_in(ops_startline, lines[idx]): + out.append(lines[idx].rstrip()) + else: + curlines.append(lines[idx]) elif one_in(["@code", "@verbatim", "@f["], lines[idx]): if curlines!=[]: out.extend(wrap_block(remove_junk(curlines), start)) @@ -295,6 +302,18 @@ lineO = [" /**", \ " */"] assert(format_block(lineI)==lineO) +lineI = [" /** ", \ + " * bla", \ + " * @image testing.png", \ + " * blub", \ + " */"] +lineO = [" /**", \ + " * bla", \ + " * @image testing.png", \ + " * blub", \ + " */"] +assert(format_block(lineI)==lineO) + # now open the file and do the work -- 2.39.5