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

Fix module/role level version_added rendering #41

Merged
merged 3 commits into from
Sep 25, 2022
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
2 changes: 2 additions & 0 deletions changelogs/fragments/41-version_added.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Avoid collection names with ``_`` in them appear wrongly escaped in the HTML output (https://github.com/ansible-community/antsibull-docs/pull/41)."
18 changes: 11 additions & 7 deletions src/antsibull_docs/data/docsite/macros/version_added.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ ansible-core
{%- endif -%}
{%- endmacro %}

{% macro version_added_rst(version_added, version_added_collection=None) -%}
{% macro version_added_rst(version_added, version_added_collection=None, do_not_escape_first_word=False) -%}
{%- if version_added_collection == 'ansible.builtin' -%}
@{ ansible_name(version_added) }@ @{ version_added | rst_escape }@
@{ ansible_name(version_added) }@ @{ version_added | rst_escape }@
{%- elif version_added_collection and do_not_escape_first_word -%}
@{ version_added_collection }@ @{ version_added | rst_escape }@
{%- elif version_added_collection -%}
@{ version_added_collection | rst_escape }@ @{ version_added | rst_escape }@
@{ version_added_collection | rst_escape }@ @{ version_added | rst_escape }@
{%- elif do_not_escape_first_word -%}
@{ version_added }@
{%- else -%}
@{ version_added | rst_escape }@
@{ version_added | rst_escape }@
{%- endif -%}
{%- endmacro %}

{% macro version_added_html(version_added, version_added_collection=None) -%}
{%- if version_added_collection == 'ansible.builtin' -%}
@{ ansible_name(version_added) }@ @{ version_added | escape }@
@{ ansible_name(version_added) }@ @{ version_added | escape }@
{%- elif version_added_collection -%}
@{ version_added_collection | escape }@ @{ version_added | escape }@
@{ version_added_collection | escape }@ @{ version_added | escape }@
{%- else -%}
@{ version_added | escape }@
@{ version_added | escape }@
{%- endif -%}
{%- endmacro %}
2 changes: 1 addition & 1 deletion src/antsibull_docs/data/docsite/plugin.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
.. version_added

{% if doc['version_added'] is still_relevant(collection=doc['version_added_collection'] or collection) -%}
.. versionadded:: @{ version_added_rst(doc['version_added'], doc['version_added_collection'] or collection) }@
.. versionadded:: @{ version_added_rst(doc['version_added'], doc['version_added_collection'] or collection, do_not_escape_first_word=true) }@
{% endif %}

.. contents::
Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_docs/data/docsite/role.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
.. version_added

{% if ep_doc['version_added'] is still_relevant(collection=collection) -%}
.. versionadded:: @{ version_added_rst(ep_doc['version_added'], collection) }@
.. versionadded:: @{ version_added_rst(ep_doc['version_added'], collection, do_not_escape_first_word=true) }@
{% endif %}

.. Deprecated
Expand Down