patch for whitespace in help output

David Goodger <[email protected]> Tue, 26 Aug 2003 18:13:57 -0400
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
With a Docutils front end, I noticed that a newline was missing:

     $ html.py --help
     Usage
     =====
       html.py [options] [<source> [<destination>]]

     Generates (X)HTML documents from standalone reStructuredText
     sources.  Reads from <source> (default is stdin) and writes to
     <destination> (default is stdout).
     options
     =======

There should be a blank line before the "options" title.  (I'd also
like to be able to customize the title to get "Options" with a capital
"O", but that's for another day.)

Here's my fix to help.HelpFormatter.format_description, to return a
newline-terminated string.  That makes it consistent with the existing
format_usage and format_heading methods.  The newline added in
option_parser.OptionContainer.format_help has to be removed to
compensate.

I can check these in in a jiffy (and update Python's CVS also), just
say the word.

Index: lib/help.py
===================================================================
RCS file: /cvsroot/optik/optik/lib/help.py,v
retrieving revision 1.5
diff -u -r1.5 help.py
--- lib/help.py	27 May 2003 02:09:07 -0000	1.5
+++ lib/help.py	26 Aug 2003 21:54:26 -0000
@@ -63,7 +63,7 @@
          indent = " "*self.current_indent
          return textwrap.fill(description, desc_width,
                               initial_indent=indent,
-                             subsequent_indent=indent)
+                             subsequent_indent=indent) + "\n"

      def format_option (self, option):
          # The help for each option consists of two parts:

Index: lib/option_parser.py
===================================================================
RCS file: /cvsroot/optik/optik/lib/option_parser.py,v
retrieving revision 1.56
diff -u -r1.56 option_parser.py
--- lib/option_parser.py	15 Jul 2003 00:01:59 -0000	1.56
+++ lib/option_parser.py	26 Aug 2003 22:06:19 -0000
@@ -256,7 +256,7 @@

      def format_help (self, formatter):
          if self.description:
-            desc = self.format_description(formatter) + "\n"
+            desc = self.format_description(formatter)
          else:
              desc = ""
          return desc + self.format_option_help(formatter)

-- 
David Goodger    http://starship.python.net/~goodger
For hire: http://starship.python.net/~goodger/cv
Docutils: http://docutils.sourceforge.net/
(includes reStructuredText: http://docutils.sf.net/rst.html)



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf