mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Various tweaking to get the module formatter to work for 'make docs' in the docs project. Likely the templates for other module formatting types will have to change
by the time I'm done.
This commit is contained in:
@@ -53,7 +53,7 @@ options:
|
||||
with B(bold), etc. work too.
|
||||
- remove:
|
||||
required: false
|
||||
choices: [ yes, no, maybe, perhaps ]
|
||||
choices: [ yes, no ]
|
||||
default: "maybe"
|
||||
aliases: [ kill, killme, delete ]
|
||||
description:
|
||||
@@ -90,7 +90,6 @@ def html_ify(text):
|
||||
t = _MODULE.sub("<span class='module'>" + r"\1" + "</span>", t)
|
||||
t = _URL.sub("<a href='" + r"\1" + "'>" + r"\1" + "</a>", t)
|
||||
t = _CONST.sub("<code>" + r"\1" + "</code>", t)
|
||||
|
||||
return t
|
||||
|
||||
def man_ify(text):
|
||||
@@ -121,7 +120,8 @@ def rst_xline(width, char="="):
|
||||
return char * width
|
||||
|
||||
|
||||
env = Environment(loader=FileSystemLoader('templates'),
|
||||
# FIXME: path should be configurable
|
||||
env = Environment(loader=FileSystemLoader('../ansible/hacking/templates/'),
|
||||
variable_start_string="@{",
|
||||
variable_end_string="}@",
|
||||
)
|
||||
@@ -207,6 +207,8 @@ def main():
|
||||
print "Need module_dir"
|
||||
sys.exit(1)
|
||||
|
||||
# TODO: make template dir configurable
|
||||
|
||||
if args.type == 'latex':
|
||||
env.filters['jpfunc'] = latex_ify
|
||||
template = env.get_template('latex.j2')
|
||||
@@ -221,6 +223,7 @@ def main():
|
||||
outputname = "ansible.%s.man"
|
||||
if args.type == 'rst':
|
||||
env.filters['jpfunc'] = rst_ify
|
||||
env.filters['html_ify'] = html_ify
|
||||
env.filters['fmt'] = rst_fmt
|
||||
env.filters['xline'] = rst_xline
|
||||
template = env.get_template('rst.j2')
|
||||
|
||||
@@ -19,15 +19,26 @@
|
||||
{% endfor %}
|
||||
|
||||
{% if options is defined -%}
|
||||
@{ xline(10, "=") }@ @{xline(10)}@ @{xline(10)}@ @{xline(60)}@
|
||||
@{ "parameter" | fmt('%-10s')}@ @{ "required" | fmt('%-10s')}@ @{ "default" | fmt('%-10s')}@ @{ "comments" | fmt('%-60s')}@
|
||||
@{ xline(10, "=") }@ @{xline(10)}@ @{xline(10)}@ @{xline(60)}@ {% for o in options -%}
|
||||
{% for opt, v in o.iteritems() %}
|
||||
{% if v['required'] %}{% set required = 'yes' %}{% else %}{% set required = ' ' %}{% endif -%}
|
||||
@{opt |fmt("%-10s") }@ @{ required|fmt('%-10s') }@ @{ v['default']|fmt('%-10s') }@ {% for desc in v.description -%}@{ desc | jpfunc }@{% endfor -%}
|
||||
{% endfor -%}
|
||||
{% endfor %}
|
||||
@{ xline(10, "=") }@ @{xline(10)}@ @{xline(10)}@ @{xline(60)}@
|
||||
.. raw:: html
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>parameter</td>
|
||||
<td>required</td>
|
||||
<td>default</td>
|
||||
<td>choices</td>
|
||||
<td>comments</td>
|
||||
</tr>
|
||||
{% for (k,v) in options.iteritems() %}
|
||||
<tr>
|
||||
<td>@{ k }@</td>
|
||||
<td>@{ v.get('required',False) }@</td>
|
||||
<td>@{ v['default'] }@</td>
|
||||
<td><ul>{% for choice in v.get('choices',[]) -%}<li>@{ choice }@</li>{% endfor -%}</ul></td>
|
||||
<td>{% for desc in v.description -%}@{ desc | html_ify }@{% endfor -%}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
FIXME: examples!
|
||||
FIXME: include the examples here!
|
||||
|
||||
Reference in New Issue
Block a user