From e4338d0ca3263a6d647298cc0edf6d09883de960 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sun, 30 Sep 2012 15:06:18 +0200 Subject: [PATCH] module_formatter now also uses Jinja2 trim_blocks - Updated man template accordingly - seem to have left in illegal char in facter DOCUMENTATION... --- hacking/module_formatter.py | 1 + hacking/templates/man.j2 | 38 +++++++++++++++++++------------------ library/facter | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/hacking/module_formatter.py b/hacking/module_formatter.py index 1722d507f54..daac30a5a12 100755 --- a/hacking/module_formatter.py +++ b/hacking/module_formatter.py @@ -221,6 +221,7 @@ def main(): env = Environment(loader=FileSystemLoader(args.template_dir), variable_start_string="@{", variable_end_string="}@", + trim_blocks=True, ) env.globals['xline'] = rst_xline diff --git a/hacking/templates/man.j2 b/hacking/templates/man.j2 index 7ec644f26ec..c5ebd7801d7 100644 --- a/hacking/templates/man.j2 +++ b/hacking/templates/man.j2 @@ -4,56 +4,58 @@ @{ module }@ \- @{ short_description }@ ." ------ DESCRIPTION .SH DESCRIPTION -{% for desc in description -%} +{% for desc in description %} .PP @{ desc | jpfunc }@ {% endfor %} ." ------ OPTIONS ." ." -{% if options -%} +{% if options %} .SH OPTIONS {% for (k,v) in options.iteritems() %} + .IP @{ k }@ -{% for desc in v.description -%}@{ desc | jpfunc }@{% endfor -%} +{% for desc in v.description %}@{ desc | jpfunc }@{% endfor %} {% if v.get('choices') %} + .IR Choices : -{% for choice in v.get('choices',[]) -%}@{ choice }@{% if not loop.last %},{%else%}.{%endif-%}{% endfor -%}{% endif %} -{% if v.get('required') %}(required){% endif -%} -{% if v.get('default') %} (default: @{ v.get('default') }@){% endif -%} +{% for choice in v.get('choices',[]) %}@{ choice }@{% if not loop.last %},{%else%}.{%endif%}{% endfor %}{% endif %} +{% if v.get('required') %}(required){% endif %} +{% if v.get('default') %} (default: @{ v.get('default') }@){% endif %} {#---------------------------------------------- #} -{% if v.get('version_added') -%} +{% if v.get('version_added') %} (Added in Ansible version @{ v.get('version_added') }@.) -{% endif -%} +{% endif %} {% endfor %} {% endif %} ." ." ." ------ NOTES -{% if notes -%} +{% if notes %} .SH NOTES -{% for note in notes -%} +{% for note in notes %} .PP @{ note | jpfunc }@ -{% endfor -%} -{% endif -%} +{% endfor %} +{% endif %} ." ." ." ------ EXAMPLES -{% if examples is defined -%} +{% if examples is defined %} .SH EXAMPLES -{% for e in examples -%} +{% for e in examples %} .PP .nf @{ e['code'] }@ .fi -{% endfor -%} -{% endif -%} +{% endfor %} +{% endif %} ." ------- AUTHOR -{% if author is defined -%} +{% if author is defined %} .SH AUTHOR @{ author }@ -{% endif -%} +{% endif %} .SH SEE ALSO .IR ansible (1), .I http://ansible.github.com/modules.html#@{docuri}@ diff --git a/library/facter b/library/facter index f274a35df45..e4baac035e4 100755 --- a/library/facter +++ b/library/facter @@ -23,7 +23,7 @@ DOCUMENTATION = ''' --- module: facter -short_description: Runs the discovery program ‘facter’ on the remote system +short_description: Runs the discovery program I(facter) on the remote system description: - Runs the discovery program I(facter) on the remote system, returning JSON data that can be useful for inventory purposes.