Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
62d038dc
Commit
62d038dc
authored
Sep 28, 2012
by
Jan-Piet Mens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
module_formatter fixes
parent
06cfc52a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
102 deletions
+31
-102
hacking/module_formatter.py
+15
-11
hacking/templates/latex.j2
+0
-70
hacking/templates/man.j2
+10
-15
hacking/templates/rst.j2
+6
-6
No files found.
hacking/module_formatter.py
View file @
62d038dc
...
...
@@ -115,15 +115,6 @@ def rst_fmt(text, fmt):
def
rst_xline
(
width
,
char
=
"="
):
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
):
return
text
.
split
(
'***BREAK***'
)
...
...
@@ -165,6 +156,11 @@ def main():
dest
=
"module_dir"
,
default
=
MODULEDIR
,
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"
,
action
=
'store'
,
dest
=
'type'
,
...
...
@@ -208,7 +204,16 @@ def main():
print
"Need module_dir"
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'
:
env
.
filters
[
'jpfunc'
]
=
latex_ify
...
...
@@ -241,7 +246,6 @@ def main():
if
fname
.
endswith
(
".swp"
):
continue
# FIXME: html/manpage/latex
print
" processing module source --->
%
s"
%
fname
doc
=
get_docstring
(
fname
,
verbose
=
args
.
verbose
)
...
...
hacking/templates/latex.j2
deleted
100644 → 0
View file @
06cfc52a
%--- @{ 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 -%}
hacking/templates/man.j2
View file @
62d038dc
...
...
@@ -13,24 +13,19 @@
."
{% if options is defined -%}
.SH OPTIONS
{% for o in options -%}{% for opt, v in o.iteritems() -%}
.IP @{opt}@
{% for desc in v.description -%}
@{ desc | jpfunc }@
{% endfor -%}
{% if v['required'] %}(required){% endif -%}
{% if v['choices'] -%}
." .SS Choices
{% for (k,v) in options.iteritems() %}
.IP @{ k }@
{% for desc in v.description -%}@{ desc | jpfunc }@{% endfor -%}
{% if v.get('choices') %}
.IR Choices :
{% for choice in v
['choices'] -%}@{ choice }@{% if not loop.last %},{% else %}.{% endif -
%}
{%
endfor
-%}
{%
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
['version_added'] is defined
-%}
(Added in Ansible version @{ v
['version_added']
}@.)
{% if v
.get('version_added')
-%}
(Added in Ansible version @{ v
.get('version_added')
}@.)
{% endif -%}
{% endfor -%}
{% endfor -%}
{% endfor %}
{% endif %}
."
."
...
...
hacking/templates/rst.j2
View file @
62d038dc
.. _@{ module }@:
@{ module }@
````````
````````
``````````````````````
{# ------------------------------------------
#
...
...
@@ -23,11 +23,11 @@
<table>
<tr>
<t
d>parameter</td
>
<t
d>required</td
>
<t
d>default</td
>
<t
d>choices</td
>
<t
d>comments</td
>
<t
h class="head">parameter</th
>
<t
h class="head">required</th
>
<t
h class="head">default</th
>
<t
h class="head">choices</th
>
<t
h class="head">comments</th
>
</tr>
{% for (k,v) in options.iteritems() %}
<tr>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment