Skip to content

Commit

Permalink
Fix broken list items by indenting all lines but the first.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Nov 2, 2020
1 parent b94d0b8 commit 27966fa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion antsibull/data/docsite/list_of_plugins.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Index of all @{ plugin_type | capitalize }@ Plugins
@{ '-' * (collection_name | length) }@

{% for plugin_name, plugin_desc in plugins.items() | sort %}
* :ref:`@{ collection_name }@.@{ plugin_name }@ <ansible_collections.@{ collection_name }@.@{ plugin_name }@_@{ plugin_type }@>` -- @{ plugin_desc | rst_ify }@
* :ref:`@{ collection_name }@.@{ plugin_name }@ <ansible_collections.@{ collection_name }@.@{ plugin_name }@_@{ plugin_type }@>` -- @{ plugin_desc | rst_ify | add_multiline_indent(2) }@
{% endfor %}

{% endfor %}
6 changes: 3 additions & 3 deletions antsibull/data/docsite/plugin.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Synopsis
.. Description

{% for desc in doc['description'] -%}
- @{ desc | rst_ify }@
- @{ desc | rst_ify | add_multiline_indent(2) }@
{% endfor %}

{% if doc['has_action'] %}
Expand All @@ -120,7 +120,7 @@ The below requirements are needed on the local controller node that executes thi
{% endif %}

{% for req in doc['requirements'] %}
- @{ req | rst_ify }@
- @{ req | rst_ify | add_multiline_indent(2) }@
{% endfor %}

{% endif %}
Expand Down Expand Up @@ -345,7 +345,7 @@ Notes

.. note::
{% for note in doc['notes'] %}
- @{ note | rst_ify }@
- @{ note | rst_ify | add_multiline_indent(5) }@
{% endfor %}
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion antsibull/data/docsite/plugins_by_collection.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Modules
{% endif %}

{% for name, desc in plugins.items() | sort %}
* :ref:`@{ name }@ <ansible_collections.@{ collection_name }@.@{ name }@_@{ category }@>` -- @{ desc | rst_ify }@
* :ref:`@{ name }@ <ansible_collections.@{ collection_name }@.@{ name }@_@{ category }@>` -- @{ desc | rst_ify | add_multiline_indent(2) }@
{% endfor %}
{% endfor %}

Expand Down
3 changes: 2 additions & 1 deletion antsibull/jinja2/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from jinja2 import Environment, FileSystemLoader, PackageLoader

from .filters import do_max, documented_type, html_ify, rst_ify, rst_fmt, rst_xline
from .filters import do_max, documented_type, html_ify, rst_ify, rst_fmt, rst_xline, add_multiline_indent
from .tests import still_relevant, test_list


Expand Down Expand Up @@ -63,6 +63,7 @@ def doc_environment(template_location):
env.filters['html_ify'] = html_ify
env.filters['fmt'] = rst_fmt
env.filters['xline'] = rst_xline
env.filters['add_multiline_indent'] = add_multiline_indent
env.filters['documented_type'] = documented_type
env.tests['list'] = test_list
env.tests['still_relevant'] = still_relevant
Expand Down
10 changes: 10 additions & 0 deletions antsibull/jinja2/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ def rst_xline(width, char="="):
''' return a restructured text line of a given length '''

return char * width


def add_multiline_indent(data, indent):
''' indent all lines after the first by the given amount of spaces '''
if data:
indent = ' ' * indent
lines = str(data).splitlines(True)
lines = [lines[0]] + [indent + line for line in lines[1:]]
data = ''.join(lines)
return data

0 comments on commit 27966fa

Please sign in to comment.