]> https://gitweb.dealii.org/ - dealii.git/commitdiff
update wrapcomments.py
authorTimo Heister <timo.heister@gmail.com>
Wed, 24 Dec 2014 14:25:02 +0000 (09:25 -0500)
committerTimo Heister <timo.heister@gmail.com>
Thu, 25 Dec 2014 20:59:47 +0000 (15:59 -0500)
now handle @image tags correctly

contrib/utilities/wrapcomments.py

index 8ee0ec6b73c0d50243b767884c1a4d711ea165dd..52cf0b120cc5e95675a3df14134bc3921ddec395 100755 (executable)
@@ -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 = ["<li>", "@param", "@returns", "@warning", "@ingroup", "@author", "@date", "@related", "@deprecated"]
+    ops_startline = ["<li>", "@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 = ["<ol>", "</ol>", "<ul>", "</ul>", "@{", "@}", "<br>"]
 
@@ -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
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.