diff mercurial/minirst.py @ 15861:ee8f5e4ce7b8

minirst: simplify and standardize field list formatting The default width of field lists is changed from 12 to 14 to align minirst with the rst2html tool. Shrinking the width of the left column to fit the content is removed, to keep formatting simple and uniform.
author Olav Reinert <seroton10@gmail.com>
date Wed, 11 Jan 2012 18:08:25 +0100
parents 87bb6b7644f6
children e740746ea557
line wrap: on
line diff
--- a/mercurial/minirst.py	Wed Jan 11 16:53:51 2012 +0100
+++ b/mercurial/minirst.py	Wed Jan 11 18:08:25 2012 +0100
@@ -162,28 +162,24 @@
         i += 1
     return blocks
 
-_fieldwidth = 12
+_fieldwidth = 14
 
 def updatefieldlists(blocks):
-    """Find key and maximum key width for field lists."""
+    """Find key for field lists."""
     i = 0
     while i < len(blocks):
         if blocks[i]['type'] != 'field':
             i += 1
             continue
 
-        keywidth = 0
         j = i
         while j < len(blocks) and blocks[j]['type'] == 'field':
             m = _fieldre.match(blocks[j]['lines'][0])
             key, rest = m.groups()
             blocks[j]['lines'][0] = rest
             blocks[j]['key'] = key
-            keywidth = max(keywidth, len(key))
             j += 1
 
-        for block in blocks[i:j]:
-            block['keywidth'] = keywidth
         i = j + 1
 
     return blocks
@@ -492,19 +488,13 @@
             m = _bulletre.match(block['lines'][0])
             subindent = indent + m.end() * ' '
     elif block['type'] == 'field':
-        keywidth = block['keywidth']
         key = block['key']
-
         subindent = indent + _fieldwidth * ' '
         if len(key) + 2 > _fieldwidth:
             # key too large, use full line width
             key = key.ljust(width)
-        elif keywidth + 2 < _fieldwidth:
-            # all keys are small, add only two spaces
-            key = key.ljust(keywidth + 2)
-            subindent = indent + (keywidth + 2) * ' '
         else:
-            # mixed sizes, use fieldwidth for this one
+            # key fits within field width
             key = key.ljust(_fieldwidth)
         block['lines'][0] = key + block['lines'][0]
     elif block['type'] == 'option':