module_formatter fixes
This commit is contained in:
parent
06cfc52afd
commit
62d038dca4
4 changed files with 31 additions and 102 deletions
|
@ -115,15 +115,6 @@ def rst_fmt(text, fmt):
|
||||||
def rst_xline(width, char="="):
|
def rst_xline(width, char="="):
|
||||||
return char * width
|
return char * width
|
||||||
|
|
||||||
|
|
||||||
# FIXME: path should be configurable
|
|
||||||
env = Environment(loader=FileSystemLoader('../ansible/hacking/templates/'),
|
|
||||||
variable_start_string="@{",
|
|
||||||
variable_end_string="}@",
|
|
||||||
)
|
|
||||||
|
|
||||||
env.globals['xline'] = rst_xline
|
|
||||||
|
|
||||||
def load_examples_section(text):
|
def load_examples_section(text):
|
||||||
return text.split('***BREAK***')
|
return text.split('***BREAK***')
|
||||||
|
|
||||||
|
@ -165,6 +156,11 @@ def main():
|
||||||
dest="module_dir",
|
dest="module_dir",
|
||||||
default=MODULEDIR,
|
default=MODULEDIR,
|
||||||
help="Ansible modules/ directory")
|
help="Ansible modules/ directory")
|
||||||
|
p.add_argument("-T", "--template-dir",
|
||||||
|
action="store",
|
||||||
|
dest="template_dir",
|
||||||
|
default="hacking/templates",
|
||||||
|
help="directory containing Jinja2 templates")
|
||||||
p.add_argument("-t", "--type",
|
p.add_argument("-t", "--type",
|
||||||
action='store',
|
action='store',
|
||||||
dest='type',
|
dest='type',
|
||||||
|
@ -208,7 +204,16 @@ def main():
|
||||||
print "Need module_dir"
|
print "Need module_dir"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# TODO: make template dir configurable
|
if not args.template_dir:
|
||||||
|
print "Need template_dir"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
env = Environment(loader=FileSystemLoader(args.template_dir),
|
||||||
|
variable_start_string="@{",
|
||||||
|
variable_end_string="}@",
|
||||||
|
)
|
||||||
|
|
||||||
|
env.globals['xline'] = rst_xline
|
||||||
|
|
||||||
if args.type == 'latex':
|
if args.type == 'latex':
|
||||||
env.filters['jpfunc'] = latex_ify
|
env.filters['jpfunc'] = latex_ify
|
||||||
|
@ -241,7 +246,6 @@ def main():
|
||||||
if fname.endswith(".swp"):
|
if fname.endswith(".swp"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# FIXME: html/manpage/latex
|
|
||||||
print " processing module source ---> %s" % fname
|
print " processing module source ---> %s" % fname
|
||||||
|
|
||||||
doc = get_docstring(fname, verbose=args.verbose)
|
doc = get_docstring(fname, verbose=args.verbose)
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
%--- @{ module | upper }@ ---- from @{ filename }@ ---
|
|
||||||
|
|
||||||
%: -- module header
|
|
||||||
\mods{@{module}@}{@{docuri}@}{
|
|
||||||
{% for desc in description -%}
|
|
||||||
@{ desc | jpfunc }@
|
|
||||||
{% endfor -%}
|
|
||||||
{% if version_added is defined -%}
|
|
||||||
(\I{* new in version @{ version_added }@})
|
|
||||||
{% endif -%}
|
|
||||||
}
|
|
||||||
|
|
||||||
%: -- module options
|
|
||||||
|
|
||||||
{% if options is defined -%}
|
|
||||||
\begin{xlist}{abcdefghijklmno}
|
|
||||||
{% for o in options -%}
|
|
||||||
{% for opt, v in o.iteritems() -%}
|
|
||||||
|
|
||||||
{% if v['required'] -%}
|
|
||||||
\item[\man\,\C{@{ opt }@}]
|
|
||||||
{% else -%}
|
|
||||||
\item[\opt\,\C{@{ opt }@}]
|
|
||||||
{% endif -%}
|
|
||||||
|
|
||||||
{# -------- option description ----------#}
|
|
||||||
{% for desc in v.description -%}
|
|
||||||
@{ desc | jpfunc }@
|
|
||||||
{% endfor %}
|
|
||||||
{% if v['choices'] -%}
|
|
||||||
\B{Choices}:\,
|
|
||||||
{% for choice in v['choices'] -%}\C{@{ choice }@}{% if not loop.last %},{% else %}.{% endif %}
|
|
||||||
{% endfor -%}
|
|
||||||
{% endif -%}
|
|
||||||
{% if v['default'] -%}
|
|
||||||
(default \C{@{ v['default'] }@})
|
|
||||||
{% endif -%}
|
|
||||||
{% if v['version_added'] is defined -%}
|
|
||||||
(\I{* version @{ v['version_added'] }@})
|
|
||||||
{% endif -%}
|
|
||||||
{% endfor -%}
|
|
||||||
{% endfor -%}
|
|
||||||
\end{xlist}
|
|
||||||
{% endif -%}
|
|
||||||
|
|
||||||
{% if notes is defined -%}
|
|
||||||
{# -------- notes ----------#}
|
|
||||||
{% for note in notes -%}
|
|
||||||
\I{@{ note | jpfunc }@}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif -%}
|
|
||||||
|
|
||||||
{#-------------------------------------------
|
|
||||||
|
|
||||||
{% if examples is defined -%}
|
|
||||||
{% for e in examples -%}
|
|
||||||
\begin{extymeta}
|
|
||||||
@{ e['code'] }@
|
|
||||||
\end{extymeta}
|
|
||||||
{% endfor -%}
|
|
||||||
{% endif -%}
|
|
||||||
----------------------------------- #}
|
|
||||||
|
|
||||||
{% if extradata is defined -%}
|
|
||||||
%--- BEGIN-EXTRADATA
|
|
||||||
\begin{extymeta}
|
|
||||||
@{ extradata -}@
|
|
||||||
\end{extymeta}
|
|
||||||
%----- END-EXTRADATA
|
|
||||||
{% endif -%}
|
|
|
@ -13,24 +13,19 @@
|
||||||
."
|
."
|
||||||
{% if options is defined -%}
|
{% if options is defined -%}
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
{% for o in options -%}{% for opt, v in o.iteritems() -%}
|
{% for (k,v) in options.iteritems() %}
|
||||||
.IP @{opt}@
|
.IP @{ k }@
|
||||||
{% for desc in v.description -%}
|
{% for desc in v.description -%}@{ desc | jpfunc }@{% endfor -%}
|
||||||
@{ desc | jpfunc }@
|
{% if v.get('choices') %}
|
||||||
{% endfor -%}
|
|
||||||
{% if v['required'] %}(required){% endif -%}
|
|
||||||
{% if v['choices'] -%}
|
|
||||||
." .SS Choices
|
|
||||||
.IR Choices :
|
.IR Choices :
|
||||||
{% for choice in v['choices'] -%}@{ choice }@{% if not loop.last %},{% else %}.{% endif -%}
|
{% for choice in v.get('choices',[]) -%}@{ choice }@{% if not loop.last %},{%else%}.{%endif-%}{% endfor -%}{% endif %}
|
||||||
{% endfor -%}
|
{% if v.get('required') %}(required){% endif -%}
|
||||||
{% endif %}
|
{% if v.get('default') %} (default: @{ v.get('default') }@){% endif -%}
|
||||||
{#---------------------------------------------- #}
|
{#---------------------------------------------- #}
|
||||||
{% if v['version_added'] is defined -%}
|
{% if v.get('version_added') -%}
|
||||||
(Added in Ansible version @{ v['version_added'] }@.)
|
(Added in Ansible version @{ v.get('version_added') }@.)
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% endfor -%}
|
{% endfor %}
|
||||||
{% endfor -%}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
."
|
."
|
||||||
."
|
."
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.. _@{ module }@:
|
.. _@{ module }@:
|
||||||
|
|
||||||
@{ module }@
|
@{ module }@
|
||||||
````````
|
``````````````````````````````
|
||||||
|
|
||||||
{# ------------------------------------------
|
{# ------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>parameter</td>
|
<th class="head">parameter</th>
|
||||||
<td>required</td>
|
<th class="head">required</th>
|
||||||
<td>default</td>
|
<th class="head">default</th>
|
||||||
<td>choices</td>
|
<th class="head">choices</th>
|
||||||
<td>comments</td>
|
<th class="head">comments</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for (k,v) in options.iteritems() %}
|
{% for (k,v) in options.iteritems() %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Add table
Reference in a new issue