/hacking/templates/rst.j2

https://github.com/ajanthanm/ansible · Jinja · 107 lines · 79 code · 22 blank · 6 comment · 21 complexity · 6d2ac7dcbfa7ca633c63daf83a855b0e MD5 · raw file

  1. .. _@{ module }@:
  2. {% if short_description %}
  3. {% set title = module + ' - ' + short_description|convert_symbols_to_format %}
  4. {% else %}
  5. {% set title = module %}
  6. {% endif %}
  7. {% set title_len = title|length %}
  8. @{ title }@
  9. @{ '+' * title_len }@
  10. {% if author %}
  11. :Author: @{ author }@
  12. {% endif %}
  13. .. contents::
  14. :local:
  15. :depth: 1
  16. {# ------------------------------------------
  17. #
  18. # Please note: this looks like a core dump
  19. # but it isn't one.
  20. #
  21. --------------------------------------------#}
  22. Synopsis
  23. --------
  24. {% if version_added is defined -%}
  25. .. versionadded:: @{ version_added }@
  26. {% endif %}
  27. {% for desc in description -%}
  28. @{ desc | convert_symbols_to_format }@
  29. {% endfor %}
  30. {% if options -%}
  31. Options
  32. -------
  33. .. raw:: html
  34. <table border=1 cellpadding=4>
  35. <tr>
  36. <th class="head">parameter</th>
  37. <th class="head">required</th>
  38. <th class="head">default</th>
  39. <th class="head">choices</th>
  40. <th class="head">comments</th>
  41. </tr>
  42. {% for k in option_keys %}
  43. {% set v = options[k] %}
  44. <tr>
  45. <td>@{ k }@</td>
  46. <td>{% if v.get('required', False) %}yes{% else %}no{% endif %}</td>
  47. <td>{% if v['default'] %}@{ v['default'] }@{% endif %}</td>
  48. {% if v.get('type', 'not_bool') == 'bool' %}
  49. <td><ul><li>yes</li><li>no</li></ul></td>
  50. {% else %}
  51. <td><ul>{% for choice in v.get('choices',[]) -%}<li>@{ choice }@</li>{% endfor -%}</ul></td>
  52. {% endif %}
  53. <td>{% for desc in v.description -%}@{ desc | html_ify }@{% endfor -%}{% if v['version_added'] %} (added in Ansible @{v['version_added']}@){% endif %}</td>
  54. </tr>
  55. {% endfor %}
  56. </table>
  57. {% endif %}
  58. {% if requirements %}
  59. {% for req in requirements %}
  60. .. note:: Requires @{ req | convert_symbols_to_format }@
  61. {% endfor %}
  62. {% endif %}
  63. {% if examples or plainexamples %}
  64. Examples
  65. --------
  66. .. raw:: html
  67. {% for example in examples %}
  68. {% if example['description'] %}<p>@{ example['description'] | html_ify }@</p>{% endif %}
  69. <p>
  70. <pre>
  71. @{ example['code'] | escape | indent(4, True) }@
  72. </pre>
  73. </p>
  74. {% endfor %}
  75. <br/>
  76. {% if plainexamples %}
  77. ::
  78. @{ plainexamples | indent(4, True) }@
  79. {% endif %}
  80. {% endif %}
  81. {% if notes %}
  82. {% for note in notes %}
  83. .. note:: @{ note | convert_symbols_to_format }@
  84. {% endfor %}
  85. {% endif %}