From 575459465e7241217244a9ba9e58dd6662e044c0 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Thu, 18 Oct 2012 13:49:19 +0200 Subject: [PATCH] module_formatter: .rst now correctly handles code examples - fixed template (it was the template), adding indentation with Jinja2 - added description of code examples to man-page template (was missing) - fixed fireball, cron, and debug module examples to confrom --- hacking/templates/man.j2 | 4 ++++ hacking/templates/rst.j2 | 8 +++++--- library/cron | 2 +- library/debug | 2 +- library/fireball | 3 +-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hacking/templates/man.j2 b/hacking/templates/man.j2 index a115bfa7264..bde78cb280c 100644 --- a/hacking/templates/man.j2 +++ b/hacking/templates/man.j2 @@ -46,6 +46,10 @@ .SH EXAMPLES {% for e in examples %} .PP +{% if e['description'] %} +@{ e['description'] | jpfunc }@ +{% endif %} + .nf @{ e['code'] }@ .fi diff --git a/hacking/templates/rst.j2 b/hacking/templates/rst.j2 index c85d961b05b..a4b8f8ff991 100644 --- a/hacking/templates/rst.j2 +++ b/hacking/templates/rst.j2 @@ -45,9 +45,11 @@ {% for example in examples %} {% if example['description'] %}

@{ example['description'] | html_ify }@

{% endif %} -

-    @{ example['code'] }@
-    

+

+

+@{ example['code'] | indent(4, True) }@
+    
+

{% endfor %}
diff --git a/library/cron b/library/cron index 6a2290338ef..59b74d27dbf 100644 --- a/library/cron +++ b/library/cron @@ -101,7 +101,7 @@ options: examples: - code: cron name="check dirs" hour="5,2" job="ls -alh > /dev/null" description: Ensure a job that runs at 2 and 5 exists. Creates an entry like "* 5,2 * * ls -alh > /dev/null" - - code: name="an old job" cron job="/some/dir/job.sh" state=absent + - code: cron name="an old job" cron job="/some/dir/job.sh" state=absent description: 'Ensure an old job is no longer present. Removes any job that is preceded by "#Ansible: an old job" in the crontab' requirements: cron author: Dane Summers diff --git a/library/debug b/library/debug index 20d6dcb334c..b36668eba84 100644 --- a/library/debug +++ b/library/debug @@ -48,7 +48,7 @@ options: required: false default: "no" examples: - - code: + - code: | - local_action: debug msg="System $inventory_hostname has uuid $ansible_product_uuid" - local_action: debug msg="System $inventory_hostname lacks a gateway" fail=yes only_if: "is_unset('${ansible_default_ipv4.gateway}')" diff --git a/library/fireball b/library/fireball index c6d88140ff9..af6894fe65a 100755 --- a/library/fireball +++ b/library/fireball @@ -51,8 +51,7 @@ examples: sudo: yes tasks: - action: fireball - - - hosts: devservers + - hosts: devservers connection: fireball tasks: - action: command /usr/bin/anything