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

login
register
mail settings
Submitter Gregory Szorc
Date May 5, 2014, 5:51 a.m.
Message ID <ca7af5ec72526886c534.1399269079@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4605/
State Superseded
Commit a039e1f2326f131e743f50492bb089e9b1140bb1
Headers show

Comments

Gregory Szorc - May 5, 2014, 5:51 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1399254304 25200
#      Sun May 04 18:45:04 2014 -0700
# Branch stable
# Node ID ca7af5ec72526886c534970251a47e3f706f1203
# Parent  c2cc0594c04637822287e69274ff6512256978b0
cmdutil: better document command()
Pierre-Yves David - May 8, 2014, 7:19 p.m.
On 05/04/2014 10:51 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@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.

There is no such thing as a commandtable instance… And I did not see any 
reference to that in the rest of the series. Vestige of a dead branch?

for not I would rewrote it:

   This function receives a command table as its argument. The tablee
   should be a dict.

Patch

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