Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling/rendering #289

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelogs/fragments/289-fixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- "Render errors as code blocks of language ``text`` instead of using the default lexer (https://github.com/ansible-community/antsibull-docs/pull/289)."
- "Improve rendering of empty or broken changelogs (https://github.com/ansible-community/antsibull-docs/pull/289)."
- "Remove leading spaces in paragraphs to avoid unintended RST blockquotes (https://github.com/ansible-community/antsibull-docs/pull/289)."
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Environment variables used by the ansible-core configuration are documented in :
.. envvar:: @{ env_var.name }@

{% for paragraph in env_var.description or [] %}
@{ paragraph | replace('\n', '\n ') | rst_ify(plugin_fqcn='', plugin_type='') | indent(4) }@
@{ paragraph | replace('\n', '\n ') | rst_ify(plugin_fqcn='', plugin_type='') | rst_indent(4) }@

{% endfor %}
*Used by:*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{% endif %}

{% for desc in data['details'] %}
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@

{% endfor %}

Expand All @@ -91,7 +91,7 @@
<div class="ansible-option-cell">

{% for desc in data['description'] %}
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@

{% endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- :ansible-option-choices-entry:`@{ choice | antsibull_to_json | rst_escape(escape_ending_whitespace=true) }@`\ :
{% endif %}
{% for par in desc %}
@{ par | rst_ify(role_entrypoint=role_entrypoint) | indent(8) }@
@{ par | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(8) }@

{% endfor %}
{% endfor %}
Expand All @@ -39,9 +39,9 @@
{% else %}
<p><code class="ansible-value literal notranslate ansible-option-choices-entry">@{ choice | antsibull_to_json | escape }@</code>:
{% endif %}
@{ desc | first | default('') | html_ify(role_entrypoint=role_entrypoint) | indent(10, blank=true) }@</p>
@{ desc | first | default('') | html_ify(role_entrypoint=role_entrypoint) | rst_indent(10, blank=true) }@</p>
{% for line in desc[1:] %}
<p>@{ line | html_ify(role_entrypoint=role_entrypoint) | indent(10, blank=true) }@</p>
<p>@{ line | html_ify(role_entrypoint=role_entrypoint) | rst_indent(10, blank=true) }@</p>
{% endfor %}
</li>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Removed in: a future release
{% endif %}


@{ ('Why: ' ~ data['why'] | rst_ify(role_entrypoint=role_entrypoint)) | indent(indent, first=true) }@
@{ ('Why: ' ~ data['why'] | rst_ify(role_entrypoint=role_entrypoint)) | rst_indent(indent, first=true) }@

@{ ('Alternative: ' ~ data['alternative'] | rst_ify(role_entrypoint=role_entrypoint)) | indent(indent, first=true) }@
@{ ('Alternative: ' ~ data['alternative'] | rst_ify(role_entrypoint=role_entrypoint)) | rst_indent(indent, first=true) }@

{% endif %}
{% endmacro %}
Expand All @@ -42,7 +42,7 @@ Removed in: a future release
of @{ data['removed_from_collection'] | html_ify(role_entrypoint=role_entrypoint) }@
{%- endif -%}
</p>
<p>@{ 'Why: ' ~ data['why'] | html_ify(role_entrypoint=role_entrypoint) | indent(2, blank=true) }@</p>
<p>@{ 'Alternative: ' ~ data['alternative'] | html_ify(role_entrypoint=role_entrypoint) | indent(2, blank=true) }@</p>
<p>@{ 'Why: ' ~ data['why'] | html_ify(role_entrypoint=role_entrypoint) | rst_indent(2, blank=true) }@</p>
<p>@{ 'Alternative: ' ~ data['alternative'] | html_ify(role_entrypoint=role_entrypoint) | rst_indent(2, blank=true) }@</p>
{% endif %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{% for i in range(1, loop.depth) %}<div class="ansible-option-indent-desc"></div>{% endfor %}<div class="ansible-option-cell">

{% for desc in value['description'] %}
@{ desc | replace('\n', '\n ') | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
@{ desc | replace('\n', '\n ') | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@

{% endfor %}
{# default / choices #}
Expand All @@ -107,7 +107,7 @@

.. rst-class:: ansible-option-line

:ansible-option-default-bold:`Default:` :ansible-option-default:`@{ value['default'] | antsibull_to_json | rst_escape(escape_ending_whitespace=true) | indent(6, blank=true) }@`
:ansible-option-default-bold:`Default:` :ansible-option-default:`@{ value['default'] | antsibull_to_json | rst_escape(escape_ending_whitespace=true) | rst_indent(6, blank=true) }@`
{% endif %}
{# Configuration #}
{% if plugin_type != 'module' and plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %}
Expand All @@ -126,7 +126,7 @@
{% if value['default'] is none %}
@{ ini['key'] }@ = VALUE
{% else %}
@{ ini['key'] }@ = @{ value['default'] | antsibull_to_ini_value | indent(10, blank=true) }@
@{ ini['key'] }@ = @{ value['default'] | antsibull_to_ini_value | rst_indent(10, blank=true) }@
{% endif %}

{% if ini['version_added'] is still_relevant(collection=ini['version_added_collection'] or collection) %}
Expand Down Expand Up @@ -223,7 +223,7 @@
{# description #}
<td>{% for i in range(1, loop.depth) %}<div class="ansible-option-indent-desc"></div>{% endfor %}<div class="ansible-option-cell">
{% for desc in value['description'] %}
<p>@{ desc | html_ify(role_entrypoint=role_entrypoint) | indent(6, blank=true) }@</p>
<p>@{ desc | html_ify(role_entrypoint=role_entrypoint) | rst_indent(6, blank=true) }@</p>
{% endfor %}
{# default / choices #}
{% if value['type'] == 'bool' %}
Expand All @@ -236,7 +236,7 @@
{% endif %}
{# Show default value, when multiple choice or no choices #}
{% if value['default'] is list or (value['default'] is not none and value['default'] not in value['choices']) %}
<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-value literal notranslate ansible-option-default">@{ value['default'] | antsibull_to_json | escape | indent(6, blank=true) }@</code></p>
<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-value literal notranslate ansible-option-default">@{ value['default'] | antsibull_to_json | escape | rst_indent(6, blank=true) }@</code></p>
{% endif %}
{# Configuration #}
{% if plugin_type != 'module' and plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
{% for i in range(1, loop.depth) %}<div class="ansible-option-indent-desc"></div>{% endfor %}<div class="ansible-option-cell">

{% for desc in value['description'] %}
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@

{% endfor %}
{% if value['returned'] %}

.. rst-class:: ansible-option-line

:ansible-option-returned-bold:`Returned:` @{ value['returned'] | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
:ansible-option-returned-bold:`Returned:` @{ value['returned'] | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@
{% endif %}
{# Show possible choices and highlight details #}
{% if value['choices'] %}
Expand All @@ -97,7 +97,7 @@
.. rst-class:: ansible-option-line
.. rst-class:: ansible-option-sample

:ansible-option-sample-bold:`Sample:` :ansible-rv-sample-value:`@{ value['sample'] | antsibull_to_json | rst_escape(escape_ending_whitespace=true) | indent(6, blank=true) }@`
:ansible-option-sample-bold:`Sample:` :ansible-rv-sample-value:`@{ value['sample'] | antsibull_to_json | rst_escape(escape_ending_whitespace=true) | rst_indent(6, blank=true) }@`
{% endif %}


Expand Down Expand Up @@ -147,18 +147,18 @@
{# description #}
<td>{% for i in range(1, loop.depth) %}<div class="ansible-option-indent-desc"></div>{% endfor %}<div class="ansible-option-cell">
{% for desc in value['description'] %}
<p>@{ desc | html_ify(role_entrypoint=role_entrypoint) | indent(6, blank=true) }@</p>
<p>@{ desc | html_ify(role_entrypoint=role_entrypoint) | rst_indent(6, blank=true) }@</p>
{% endfor %}
{% if value['returned'] %}
<p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> @{ value['returned'] | html_ify(role_entrypoint=role_entrypoint) | indent(6, blank=true) }@</p>
<p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> @{ value['returned'] | html_ify(role_entrypoint=role_entrypoint) | rst_indent(6, blank=true) }@</p>
{% endif %}
{# Show possible choices and highlight details #}
{% if value['choices'] %}
<p class="ansible-option-line"><strong class="ansible-option-choices">Can only return:</strong></p>
@{ choices_html(value['choices'], has_no_default=True, role_entrypoint=role_entrypoint) }@
{% endif %}
{% if value['sample'] is not none %}
<p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-value literal notranslate ansible-option-sample">@{ value['sample'] | antsibull_to_json | escape | indent(6, blank=true) }@</code></p>
<p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-value literal notranslate ansible-option-sample">@{ value['sample'] | antsibull_to_json | escape | rst_indent(6, blank=true) }@</code></p>
{% endif %}
</div></td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The documentation for the @{ plugin_type }@ plugin, @{ plugin_name }@, was malf
The errors were:

{% for error in nonfatal_errors %}
* ::
* .. code-block:: text

@{ error | indent(width=8, first=True) }@

Expand Down
20 changes: 10 additions & 10 deletions src/antsibull_docs/data/docsite/ansible-docsite/plugin.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ DEPRECATED
{% if doc['deprecated']['removed_from_collection'] and doc['deprecated']['removed_from_collection'] != collection %}
of @{ doc['deprecated']['removed_from_collection'] | rst_ify }@
{% endif %}
:Why: @{ doc['deprecated']['why'] | rst_ify | indent(6) }@
:Alternative: @{ doc['deprecated']['alternative'] | rst_ify | indent(14) }@
:Why: @{ doc['deprecated']['why'] | rst_ify | rst_indent(6) }@
:Alternative: @{ doc['deprecated']['alternative'] | rst_ify | rst_indent(14) }@
{% endif %}

{% if plugin_type == 'callback' %}
Expand All @@ -133,7 +133,7 @@ Synopsis
.. Description

{% for desc in doc['description'] -%}
- @{ desc | rst_ify | indent(width=2) }@
- @{ desc | rst_ify | rst_indent(width=2) }@
{% endfor %}

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

{% for req in doc['requirements'] %}
- @{ req | rst_ify | indent(width=2) }@
- @{ req | rst_ify | rst_indent(width=2) }@
{% endfor %}

{% endif %}
Expand Down Expand Up @@ -289,7 +289,7 @@ Notes
{% endif %}
{% if doc['notes'] %}
{% for note in doc['notes'] %}
- @{ note | rst_ify | indent(width=5) }@
- @{ note | rst_ify | rst_indent(width=5) }@
{% endfor %}
{% endif %}
{% endif %}
Expand All @@ -305,22 +305,22 @@ See Also
{% for item in doc['seealso'] %}
{% if item.module is defined and item.description %}
@{ reference_plugin_rst(item['module'], 'module') }@
@{ item['description'] | rst_ify | indent(7) }@
@{ item['description'] | rst_ify | rst_indent(7) }@
{% elif item.module is defined %}
@{ reference_plugin_rst(item['module'], 'module') }@
The official documentation on the **@{ item['module'] }@** module.
{% elif item.plugin is defined and item.plugin_type is defined and item.description %}
@{ reference_plugin_rst(item['plugin'], item['plugin_type']) }@ @{ item['plugin_type'] }@ plugin
@{ item['description'] | rst_ify | indent(7) }@
@{ item['description'] | rst_ify | rst_indent(7) }@
{% elif item.plugin is defined and item.plugin_type is defined %}
@{ reference_plugin_rst(item['plugin'], item['plugin_type']) }@ @{ item['plugin_type'] }@ plugin
The official documentation on the **@{ item['plugin'] }@** @{ item['plugin_type'] }@ plugin.
{% elif item.name is defined and item.link is defined and item.description %}
`@{ item['name'] }@ <@{ item['link'] }@>`_
@{ item['description'] | rst_ify | indent(7) }@
@{ item['description'] | rst_ify | rst_indent(7) }@
{% elif item.ref is defined and item.description %}
:ref:`@{ item['ref'] }@`
@{ item['description'] | rst_ify | indent(7) }@
@{ item['description'] | rst_ify | rst_indent(7) }@
{% endif %}
{% endfor %}
{% endif %}
Expand Down Expand Up @@ -450,7 +450,7 @@ There were some errors parsing the documentation for this plugin. Please file a
The errors were:

{% for error in nonfatal_errors %}
* ::
* .. code-block:: text

@{ error | indent(width=8, first=True) }@

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

{% macro list_plugins(plugin_type) %}
{% for name, desc in plugin_maps[plugin_type].items() | sort %}
* :ansplugin:`@{ name }@ @{ plugin_type }@ <@{ collection_name }@.@{ name }@#@{ plugin_type }@>` -- @{ desc | rst_ify(plugin_fqcn=collection_name ~ '.' ~ name, plugin_type=plugin_type) | indent(width=2) }@
* :ansplugin:`@{ name }@ @{ plugin_type }@ <@{ collection_name }@.@{ name }@#@{ plugin_type }@>` -- @{ desc | rst_ify(plugin_fqcn=collection_name ~ '.' ~ name, plugin_type=plugin_type) | rst_indent(width=2) }@
{% endfor %}
{% if breadcrumbs %}

Expand Down Expand Up @@ -54,7 +54,7 @@ Description
**Author@{ 's' if (collection_authors | length) > 1 else '' }@:**

{% for author in collection_authors %}
* @{ author | indent(2) }@
* @{ author | rst_indent(2) }@
{% endfor %}
{% endif %}

Expand Down
20 changes: 10 additions & 10 deletions src/antsibull_docs/data/docsite/ansible-docsite/role.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ DEPRECATED
{% else %}
:Removed in: a future release
{% endif %}
:Why: @{ ep_doc['deprecated']['why'] | rst_ify(role_entrypoint=entry_point) | indent(6) }@
:Alternative: @{ ep_doc['deprecated']['alternative'] | rst_ify(role_entrypoint=entry_point) | indent(14) }@
:Why: @{ ep_doc['deprecated']['why'] | rst_ify(role_entrypoint=entry_point) | rst_indent(6) }@
:Alternative: @{ ep_doc['deprecated']['alternative'] | rst_ify(role_entrypoint=entry_point) | rst_indent(14) }@
{% endif %}

Synopsis
Expand All @@ -106,7 +106,7 @@ Synopsis
.. Description

{% for desc in ep_doc['description'] -%}
- @{ desc | rst_ify(role_entrypoint=entry_point) | indent(width=2) }@
- @{ desc | rst_ify(role_entrypoint=entry_point) | rst_indent(width=2) }@
{% endfor %}

.. Requirements
Expand All @@ -117,7 +117,7 @@ Requirements
The below requirements are needed on the remote host and/or the local controller node.

{% for req in ep_doc['requirements'] %}
- @{ req | rst_ify(role_entrypoint=entry_point) | indent(width=2) }@
- @{ req | rst_ify(role_entrypoint=entry_point) | rst_indent(width=2) }@
{% endfor %}

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

.. note::
{% for note in ep_doc['notes'] %}
- @{ note | rst_ify(role_entrypoint=entry_point) | indent(width=5) }@
- @{ note | rst_ify(role_entrypoint=entry_point) | rst_indent(width=5) }@
{% endfor %}
{% endif %}

Expand All @@ -169,22 +169,22 @@ See Also
{% for item in ep_doc['seealso'] %}
{% if item.module is defined and item.description %}
@{ reference_plugin_rst(item['module'], 'module') }@
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | indent(7) }@
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | rst_indent(7) }@
{% elif item.module is defined %}
@{ reference_plugin_rst(item['module'], 'module') }@
The official documentation on the **@{ item['module'] }@** module.
{% elif item.plugin is defined and item.plugin_type is defined and item.description %}
@{ reference_plugin_rst(item['plugin'], item['plugin_type']) }@ @{ item['plugin_type'] }@ plugin
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | indent(7) }@
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | rst_indent(7) }@
{% elif item.plugin is defined and item.plugin_type is defined %}
@{ reference_plugin_rst(item['plugin'], item['plugin_type']) }@ @{ item['plugin_type'] }@ plugin
The official documentation on the **@{ item['plugin'] }@** @{ item['plugin_type'] }@ plugin.
{% elif item.name is defined and item.link is defined and item.description %}
`@{ item['name'] }@ <@{ item['link'] }@>`_
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | indent(7) }@
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | rst_indent(7) }@
{% elif item.ref is defined and item.description %}
:ref:`@{ item['ref'] }@`
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | indent(7) }@
@{ item['description'] | rst_ify(role_entrypoint=entry_point) | rst_indent(7) }@
{% endif %}
{% endfor %}
{% endif %}
Expand Down Expand Up @@ -228,7 +228,7 @@ There were some errors parsing the documentation for this role. Please file a b
The errors were:

{% for error in nonfatal_errors %}
* ::
* .. code-block:: text

@{ error | indent(width=8, first=True) }@

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
{% endif %}

{% for desc in data['details'] %}
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@

{% endfor %}

{# description #}
-
{% for desc in data['description'] %}
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | indent(6) }@
@{ desc | rst_ify(role_entrypoint=role_entrypoint) | rst_indent(6) }@

{% endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
{% else %}
<p><code>@{ choice | antsibull_to_json | escape }@</code>:
{% endif %}
@{ desc | first | default('') | html_ify(role_entrypoint=role_entrypoint) | indent(10, blank=true) }@</p>
@{ desc | first | default('') | html_ify(role_entrypoint=role_entrypoint) | rst_indent(10, blank=true) }@</p>
{% for line in desc[1:] %}
<p>@{ line | html_ify(role_entrypoint=role_entrypoint) | indent(10, blank=true) }@</p>
<p>@{ line | html_ify(role_entrypoint=role_entrypoint) | rst_indent(10, blank=true) }@</p>
{% endfor %}
</li>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Removed in: a future release
of @{ data['removed_from_collection'] | html_ify(role_entrypoint=role_entrypoint) }@
{%- endif -%}
</p>
<p>@{ 'Why: ' ~ data['why'] | html_ify(role_entrypoint=role_entrypoint) | indent(2, blank=true) }@</p>
<p>@{ 'Alternative: ' ~ data['alternative'] | html_ify(role_entrypoint=role_entrypoint) | indent(2, blank=true) }@</p>
<p>@{ 'Why: ' ~ data['why'] | html_ify(role_entrypoint=role_entrypoint) | rst_indent(2, blank=true) }@</p>
<p>@{ 'Alternative: ' ~ data['alternative'] | html_ify(role_entrypoint=role_entrypoint) | rst_indent(2, blank=true) }@</p>
{% endif %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{# description #}
<td valign="top">
{% for desc in value['description'] %}
<p>@{ desc | html_ify(role_entrypoint=role_entrypoint) | indent(6, blank=true) }@</p>
<p>@{ desc | html_ify(role_entrypoint=role_entrypoint) | rst_indent(6, blank=true) }@</p>
{% endfor %}
{# default / choices #}
{% if value['type'] == 'bool' %}
Expand All @@ -68,7 +68,7 @@
{% endif %}
{# Show default value, when multiple choice or no choices #}
{% if value['default'] is list or (value['default'] is not none and value['default'] not in value['choices']) %}
<p style="margin-top: 8px;"><b style="color: blue;">Default:</b> <code style="color: blue;">@{ value['default'] | antsibull_to_json | escape | indent(6, blank=true) }@</code></p>
<p style="margin-top: 8px;"><b style="color: blue;">Default:</b> <code style="color: blue;">@{ value['default'] | antsibull_to_json | escape | rst_indent(6, blank=true) }@</code></p>
{% endif %}
{# Configuration #}
{% if plugin_type != 'module' and plugin_type != 'role' and (value['ini'] or value['env'] or value['vars'] or value['cli']) %}
Expand Down
Loading