[PATCH 14 of 35] cmdutil: better document command()

Gregory Szorc gregory.szorc at gmail.com
Mon May 5 00:51:19 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1399254304 25200
#      Sun May 04 18:45:04 2014 -0700
# Branch stable
# Node ID ca7af5ec72526886c534970251a47e3f706f1203
# Parent  c2cc0594c04637822287e69274ff6512256978b0
cmdutil: better document command()

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2408,18 +2408,34 @@ def _performrevert(repo, parents, ctx, r
 
     copied = copies.pathcopies(repo[parent], ctx)
 
     for f in add[0] + undelete[0] + revert[0]:
         if f in copied:
             repo.dirstate.copy(copied[f], f)
 
 def command(table):
-    '''returns a function object bound to table which can be used as
-    a decorator for populating table as a command table'''
+    """Returns a function object to be used as a decorator for making commands.
+
+    This function receives a command table as its argument. The table should
+    be a commandtable instance, but a regular dict will be accepted for
+    backwards compatibility.
+
+    The returned function can be used as a decorator for adding commands
+    to that command table. This function accepts multiple arguments to define
+    a command.
+
+    The first argument is the command name.
+
+    The options argument is an iterable of tuples defining command arguments.
+    See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
+
+    The synopsis argument defines a short, one line summary of how to use the
+    command. This shows up in the help output.
+    """
 
     def cmd(name, options=(), synopsis=None):
         def decorator(func):
             if synopsis:
                 table[name] = func, list(options), synopsis
             else:
                 table[name] = func, list(options)
             return func


More information about the Mercurial-devel mailing list