From 626203a7c98d264165d400db846ceda92d5d7cce Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sat, 3 Nov 2012 18:52:59 -0400 Subject: [PATCH] Module documentation should have options sorted --- hacking/module_formatter.py | 8 +++++++- hacking/templates/rst.j2 | 3 ++- library/facter | 2 +- library/ohai | 2 +- library/ping | 1 + library/raw | 1 + library/setup | 1 + 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hacking/module_formatter.py b/hacking/module_formatter.py index 7e8894830c3..bb84548e905 100755 --- a/hacking/module_formatter.py +++ b/hacking/module_formatter.py @@ -251,7 +251,7 @@ def main(): variable_start_string="@{", variable_end_string="}@", trim_blocks=True, - ) + ) env.globals['xline'] = rst_xline @@ -334,6 +334,12 @@ def main(): if not doc is None: + all_keys = [] + for (k,v) in doc['options'].iteritems(): + all_keys.append(k) + all_keys = sorted(all_keys) + doc['option_keys'] = all_keys + doc['filename'] = fname doc['docuri'] = doc['module'].replace('_', '-') doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d') diff --git a/hacking/templates/rst.j2 b/hacking/templates/rst.j2 index a4b8f8ff991..e83b4e9652d 100644 --- a/hacking/templates/rst.j2 +++ b/hacking/templates/rst.j2 @@ -29,7 +29,8 @@ choices comments - {% for (k,v) in options.iteritems() %} + {% for k in option_keys %} + {% set v = options[k] %} @{ k }@ {% if v.get('required', False) %}yes{% else %}no{% endif %} diff --git a/library/facter b/library/facter index 491eb7ab039..8df12886196 100755 --- a/library/facter +++ b/library/facter @@ -29,7 +29,7 @@ description: (U(https://github.com/puppetlabs/facter)) on the remote system, returning JSON data that can be useful for inventory purposes. version_added: "0.2" -options: [] +options: {} examples: - code: ansible www.example.net -m facter description: "Example command-line invocation" diff --git a/library/ohai b/library/ohai index b283c08bc27..95d764f075e 100755 --- a/library/ohai +++ b/library/ohai @@ -29,7 +29,7 @@ description: returns JSON inventory data. I(Ohai) data is a bit more verbose and nested than I(facter). version_added: "0.6" -options: [] +options: {} examples: - code: ansible webservers -m ohai --tree=/tmp/ohaidata description: "Retrieve I(ohai) data from all Web servers and store in one-file per host" diff --git a/library/ping b/library/ping index 06226a0408a..36f8bcbbaef 100755 --- a/library/ping +++ b/library/ping @@ -27,6 +27,7 @@ description: - A trivial test module, this module always returns 'pong' on successful contact. It does not make sense in playbooks, but is useful from C(/usr/bin/ansible) +options: {} examples: - code: ansible webservers -m ping description: Test 'webservers' status diff --git a/library/raw b/library/raw index 62b48be29d3..39add7372f5 100755 --- a/library/raw +++ b/library/raw @@ -4,6 +4,7 @@ DOCUMENTATION = ''' --- module: raw short_description: Executes a low-down and dirty SSH command +options: {} description: - Executes a low-down and dirty SSH command, not going through the module subsystem. This is useful and should only be done in two cases. The diff --git a/library/setup b/library/setup index 0c4ffae769a..24a0985a1be 100755 --- a/library/setup +++ b/library/setup @@ -30,6 +30,7 @@ DOCUMENTATION = ''' --- module: setup short_description: Gathers facts about remote hosts +options: {} description: - This module is automatically called by playbooks to gather useful variables about remote hosts that can be used in playbooks. It can also be