← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/maascli-help-formatting into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/maascli-help-formatting into lp:maas with lp:~jtv/maas/api-docstrings-touchup as a prerequisite.

Commit message:
Pre-format some help text I mistakenly thought would be formatted on display.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/maascli-help-formatting/+merge/129484

I thought I could pass an unformatted string (just one long line per paragraph) to the arguments parser here, and the argparse.HelpFormatter would format it.  But we're not using that formatter; we're overriding it to use the raw formatter instead, so that parameter documentation blocks in docstrings won't get wrapped together.


Jeroen
-- 
https://code.launchpad.net/~jtv/maas/maascli-help-formatting/+merge/129484
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/maascli-help-formatting into lp:maas.
=== modified file 'src/maascli/api.py'
--- src/maascli/api.py	2012-10-12 17:35:23 +0000
+++ src/maascli/api.py	2012-10-12 17:35:23 +0000
@@ -21,6 +21,10 @@
 import json
 from operator import itemgetter
 import sys
+from textwrap import (
+    dedent,
+    fill,
+    )
 from urlparse import (
     urljoin,
     urlparse,
@@ -310,6 +314,23 @@
             register_handler(profile, represent_as, parser)
 
 
+profile_help = '\n\n'.join(
+    map(fill, map(dedent, [
+    """\
+        This is a profile.  Any commands you issue on this
+        profile will operate on the MAAS region server.
+        """,
+    """\
+        The command information you see here comes from the
+        region server's API; it may differ for different
+        profiles.  If you believe the API may have changed,
+        use the command's 'refresh' sub-command to fetch the
+        latest version of this help information from the
+        server.
+        """,
+    ])))
+
+
 def register_api_commands(parser):
     """Register all profiles as subcommands on `parser`."""
     with ProfileConfig.open() as config:
@@ -320,13 +341,5 @@
                 description=(
                     "Issue commands to the MAAS region controller at %(url)s."
                     % profile),
-                epilog=(
-                    "This is a profile.  Any commands you issue on this "
-                    "profile will operate on the MAAS region server.\n"
-                    "The command information you see here comes from the "
-                    "region server's API; it may differ for different "
-                    "profiles.  If you believe the API may have changed, "
-                    "use the command's 'refresh' sub-command to fetch the "
-                    "latest version of this help information from the "
-                    "server."))
+                epilog=profile_help)
             register_resources(profile, profile_parser)


Follow ups