[PATCH 08 of 10] help: generate and use rst for disabled extension command

Erik Zielke ez at aragost.com
Wed Nov 17 17:11:07 UTC 2010


# HG changeset patch
# User Erik Zielke <ez at aragost.com>
# Date 1290013170 -3600
# Node ID a4013a91f8548451ac22019e2c9543c168ecb5dc
# Parent  a6aca1a96f79cfae79eff0bca75461ee8ec10483
help: generate and use rst for disabled extension command

diff -r a6aca1a96f79 -r a4013a91f854 doc/gendoc.py
--- a/doc/gendoc.py	Wed Nov 17 17:59:25 2010 +0100
+++ b/doc/gendoc.py	Wed Nov 17 17:59:30 2010 +0100
@@ -27,7 +27,7 @@
     # print options
     section(ui, _("Options"))
     helpconfig = helpmod.createhelpconfig('', False, False, False, None,
-                                          False, None)
+                                          False, None, False)
 
     for optstr, desc in helpmod.getopts(globalopts, helpconfig):
         ui.write("%s\n    %s\n\n" % (optstr, desc))
diff -r a6aca1a96f79 -r a4013a91f854 mercurial/commands.py
--- a/mercurial/commands.py	Wed Nov 17 17:59:25 2010 +0100
+++ b/mercurial/commands.py	Wed Nov 17 17:59:30 2010 +0100
@@ -1871,7 +1871,8 @@
     """
     textwidth = ui.termwidth() - 2
     helpconfig = help.createhelpconfig(name, ui.verbose, ui.quiet, True,
-                                       table, ui.debugflag, globalopts)
+                                       table, ui.debugflag, globalopts,
+                                        ui.config('ui', 'strict'))
 
     def helpcmd(name):
         if with_version:
@@ -1971,16 +1972,12 @@
         ui.write('\n')
 
     def helpextcmd(name):
-        cmd, ext, mod = extensions.disabledcmd(name, ui.config('ui', 'strict'))
-        doc = gettext(mod.__doc__).splitlines()[0]
-
-        msg = help.listexts(_("'%s' is provided by the following "
-                              "extension:") % cmd, {ext: doc}, len(ext),
-                            indent=4)
-        ui.write(minirst.format(msg, textwidth))
-        ui.write('\n\n')
-        ui.write(_('use "hg help extensions" for information on enabling '
-                   'extensions\n'))
+        helpextcmdrst = help.generatehelpextcmdrst(helpconfig)
+        formatted, pruned = minirst.format(helpextcmdrst, textwidth,
+                                   keep=helpconfig['keep'])
+        ui.write(formatted)
+        ui.write('\n')
+
 
     help.addtopichook('revsets', revset.makedoc)
 
diff -r a6aca1a96f79 -r a4013a91f854 mercurial/help.py
--- a/mercurial/help.py	Wed Nov 17 17:59:25 2010 +0100
+++ b/mercurial/help.py	Wed Nov 17 17:59:30 2010 +0100
@@ -266,7 +266,7 @@
     return ''.join(versionlines)
 
 def createhelpconfig(name, verbose, quiet, cmdline, commandtable, debugflag,
-                     globalopts):
+                     globalopts, strict):
     helpconfig = {'name': name,
                   'cmdline': cmdline,
                   'keep': [],
@@ -275,7 +275,8 @@
                   'commandtable': commandtable,
                   'debugflag': debugflag,
                   'extrainfo': False,
-                  'globalopts': globalopts
+                  'globalopts': globalopts,
+                  'strict': strict
                   }
     if verbose:
         helpconfig['keep'].append('verbose')
@@ -447,6 +448,22 @@
     return ''.join(lines)
 
 
+def generatehelpextcmdrst(helpconfig):
+    """Returns rst help for the disabled extension cmd with the given name"""
+    cmd, ext, mod = extensions.disabledcmd(helpconfig['name'],
+                                           helpconfig['strict'])
+    lines = []
+    doc = gettext(mod.__doc__).splitlines()[0]
+
+    msg = listexts(_("'%s' is provided by the following "
+                          "extension:") % cmd, {ext: doc}, len(ext),
+                       indent=4)
+    lines.append(msg)
+    lines.append('\n\n')
+    lines.append(_('use "hg help extensions" for information on enabling '
+               'extensions\n'))
+    return ''.join(lines)
+
 helptable = [
     (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
     (["dates"], _("Date Formats"), loaddoc('dates')),



More information about the Mercurial-devel mailing list