[PATCH 1 of 4] minirst: generate tables as a list of joined lines

Olav Reinert seroton10 at gmail.com
Fri Jun 1 06:41:45 CDT 2012


# HG changeset patch
# User Olav Reinert <seroton10 at gmail.com>
# Date 1338544703 -7200
# Node ID c6807e0e37c7f9c3be1551c4d66658dbb9711f85
# Parent  f694ab54b66097ce96a9fa22c0869abcca3182cc
minirst: generate tables as a list of joined lines

diff -r f694ab54b660 -r c6807e0e37c7 mercurial/commands.py
--- a/mercurial/commands.py	Wed May 30 14:31:51 2012 -0500
+++ b/mercurial/commands.py	Fri Jun 01 11:58:23 2012 +0200
@@ -3324,7 +3324,8 @@
                          ('extensioncommands', _('Extension Commands'))):
             if matches[t]:
                 ui.write('%s:\n\n' % title)
-                ui.write(minirst.format(minirst.maketable(matches[t], 1)))
+                rst = ''.join(minirst.maketable(matches[t], 1))
+                ui.write(minirst.format(rst))
         return
 
     if name and name != 'shortlist':
diff -r f694ab54b660 -r c6807e0e37c7 mercurial/help.py
--- a/mercurial/help.py	Wed May 30 14:31:51 2012 -0500
+++ b/mercurial/help.py	Fri Jun 01 11:58:23 2012 +0200
@@ -58,9 +58,9 @@
     rst = minirst.maketable(data, 1)
 
     if multioccur:
-        rst += _("\n[+] marked option can be specified multiple times\n")
+        rst.append(_("\n[+] marked option can be specified multiple times\n"))
 
-    return rst
+    return ''.join(rst)
 
 # list all option lists
 def opttext(optlist, width, verbose):
diff -r f694ab54b660 -r c6807e0e37c7 mercurial/minirst.py
--- a/mercurial/minirst.py	Wed May 30 14:31:51 2012 -0500
+++ b/mercurial/minirst.py	Fri Jun 01 11:58:23 2012 +0200
@@ -658,7 +658,7 @@
     return lines
 
 def maketable(data, indent=0, header=False):
-    '''Generate an RST table for the given table data'''
+    '''Generate an RST table for the given table data as a list of lines'''
 
     widths = [max(encoding.colwidth(e) for e in c) for c in zip(*data)]
     indent = ' ' * indent
@@ -674,4 +674,4 @@
     if header and len(data) > 1:
         out.insert(2, div)
     out.append(div)
-    return ''.join(out)
+    return out
diff -r f694ab54b660 -r c6807e0e37c7 tests/test-minirst.py
--- a/tests/test-minirst.py	Wed May 30 14:31:51 2012 -0500
+++ b/tests/test-minirst.py	Fri Jun 01 11:58:23 2012 +0200
@@ -237,7 +237,8 @@
          ['1', '2', '3'],
          ['foo', 'bar', 'baz this list is very very very long man']]
 
-table = minirst.maketable(data, 2, True)
+rst = minirst.maketable(data, 2, True)
+table = ''.join(rst)
 
 print table
 


More information about the Mercurial-devel mailing list