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 version number formatting in edge cases #357

Merged
merged 17 commits into from
Dec 17, 2024
20 changes: 15 additions & 5 deletions docs/_templates/product-v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
"EPSG:3577": "GDA94 / Australian Albers (EPSG:3577)",
} %}

{# Macros #}

{% macro format_version_number(version_number) -%} {# If the version number starts with a number, add a 'v' to it e.g. "v1.0.0". #}
{%- if (version_number|string)[0].isdigit() -%}
{{ "v" ~ version_number }}
{%- else -%}
{{ version_number }}
{%- endif -%}
{%- endmacro %}

{# Computed values #}

{% set access_links_maps_list = page.data.access_links_maps | selectattr("link", "!=", None) | list %}
Expand Down Expand Up @@ -90,17 +100,17 @@

{% set bands_table_list = page.tables.bands_table | selectattr("name", "!=", None) | list %}

{% set page_title = page.data.short_name if page.data.is_latest_version else "v{}. {}".format(page.data.version_number, page.data.short_name) %}
{% set page_title = page.data.short_name if page.data.is_latest_version else format_version_number(page.data.version_number) ~ ". " ~ page.data.short_name %}

{% set display_title = page.data.short_name if page.data.is_latest_version else "{} v{}".format(page.data.short_name, page.data.version_number) %}
{% set display_title = page.data.short_name if page.data.is_latest_version else page.data.short_name ~ " " ~ format_version_number(page.data.version_number) %}

{% set product_ids_label = "Product IDs" if product_ids_list | length > 1 else "Product ID" %}

{% set parent_products_label = "Parent products" if parent_products_list | length > 1 else "Parent product" %}

{% set collections_label = "Collections" if collections_list | length > 1 else "Collection" %}

{% set currency_report_url = "https://mgmt.sandbox.dea.ga.gov.au/public-dashboards/d22241dbfca54b1fa9f73938ef26e645?orgId=1#:~:text={}".format(page.data.short_name | urlencode) %}
{% set currency_report_url = "https://mgmt.sandbox.dea.ga.gov.au/public-dashboards/d22241dbfca54b1fa9f73938ef26e645?orgId=1#:~:text=" ~ (page.data.short_name | urlencode) %}

{% set lineage_type = lineage_type_terms.get(page.data.lineage_type, page.data.lineage_type) %}

Expand Down Expand Up @@ -765,11 +775,11 @@

.. list-table::

* - v{{ page.data.version_number }}
* - {{ format_version_number(page.data.version_number) }}
- \-
- Current version
{% for item in previous_versions_list %}
* - v{{ item.version_number }}
* - {{ format_version_number(item.version_number) }}
- of
- `{{ item.title }} </data/version-history/{{ item.slug }}/>`_
{% endfor %}
Expand Down
Loading