Repository: ansible/ansible

Issue:
ansible-doc repeats module description for every parameter (v2 regression)
**Issue Type**: Bug Report
**Ansible Version**:

```
ansible 2.0.0 (devel 18adfc6d1a) last updated 2015/09/22 09:37:04 (GMT +300)
  lib/ansible/modules/core: (detached HEAD 59afecace4) last updated 2015/09/19 10:16:59 (GMT +300)
  lib/ansible/modules/extras: (detached HEAD dee690d7f4) last updated 2015/09/19 10:16:59 (GMT +300)
```

**Summary**:
ansible-doc repeats the module description instead of showing parameter descriptions

**Steps to Reproduce**
1. `ansible-doc command`

**Expected Results**

```
> COMMAND

  The [command] module takes the command name followed by a list of
  space-delimited arguments. The given command will be executed on all
  selected nodes. It will not be processed through the shell, so
  variables like `$HOME' and operations like `"<"', `">"', `"|"', and
  `"&"' will not work (use the [shell] module if you need these
  features).

Options (= is mandatory):

- chdir
        cd into this directory before running the command [Default:
        None]

- creates
        a filename, when it already exists, this step will *not* be
        run. [Default: None]

- executable
        change the shell used to execute the command. Should be an
        absolute path to the executable. [Default: None]

= free_form
        the command module takes a free form command to run.  There is
        no parameter actually named 'free form'. See the examples!
        [Default: None]

- removes
        a filename, when it does not exist, this step will *not* be
        run. [Default: None]

- warn
        if command warnings are on in ansible.cfg, do not warn about
        this particular line if set to no/false. [Default: True]
...
```

**Actual Results**

```
> COMMAND

  The [command] module takes the command name followed by a list of
  space-delimited arguments. The given command will be executed on all
  selected nodes. It will not be processed through the shell, so
  variables like `$HOME' and operations like `"<"', `">"', `"|"', and
  `"&"' will not work (use the [shell] module if you need these
  features).

Options (= is mandatory):

- chdir
        The [command] module takes the command name followed by a list
        of space-delimited arguments. The given command will be
        executed on all selected nodes. It will not be processed
        through the shell, so variables like `$HOME' and operations
        like `"<"', `">"', `"|"', and `"&"' will not work (use the
        [shell] module if you need these features). [Default: None]

- creates
        The [command] module takes the command name followed by a list
        of space-delimited arguments. The given command will be
        executed on all selected nodes. It will not be processed
        through the shell, so variables like `$HOME' and operations
        like `"<"', `">"', `"|"', and `"&"' will not work (use the
        [shell] module if you need these features). [Default: None]

- executable
        The [command] module takes the command name followed by a list
        of space-delimited arguments. The given command will be
        executed on all selected nodes. It will not be processed
        through the shell, so variables like `$HOME' and operations
        like `"<"', `">"', `"|"', and `"&"' will not work (use the
        [shell] module if you need these features). [Default: None]
...
```



Discussion:
Git bisect blames 2b28cdc0dd33c34d77b213dd8b3e2e586e0dfec4


Resolving patch:
diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py
--- a/lib/ansible/cli/doc.py
+++ b/lib/ansible/cli/doc.py
@@ -255,10 +255,10 @@ def get_man_text(doc):
 
             text.append("%s %s" % (opt_leadin, o))
 
-            if isinstance(doc['description'], list):
-                desc = " ".join(doc['description'])
+            if isinstance(opt['description'], list):
+                desc = " ".join(opt['description'])
             else:
-                desc = doc['description']
+                desc = opt['description']
 
             if 'choices' in opt:
                 choices = ", ".join(str(i) for i in opt['choices'])


Test patch: