Skip to content

Commit

Permalink
Adapt and migrate noter macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Roxedus committed Aug 31, 2024
1 parent f28b769 commit d2f9911
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion roles/generate-jenkins/templates/DOCUMENTATION.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#jinja2: keep_trailing_newline:True
{%- set output_format="!!! \\g<level> \\g<title>\n\n \\g<message>" -%}
{%- set markdown="mkdocs" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set has_latest= true if (development_versions == true and 'latest' in (development_versions_items | map(attribute="tag"))) or (development_versions == false) else false -%}
---
Expand Down
3 changes: 1 addition & 2 deletions roles/generate-jenkins/templates/DOCUMENTATION.j2-CUSTOM
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{%- set output_format="!!! \\g<level> \\g<title>\n\n \\g<message>" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set markdown="gfm" -%}
---
title: {{ project_name }}
---
Expand Down
3 changes: 1 addition & 2 deletions roles/generate-jenkins/templates/ISSUE_TEMPLATE.bug.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{%- set output_format="# \\g<message>" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set markdown="gfm" -%}
# Based on the issue template
name: Bug report
description: Create a report to help us improve
Expand Down
3 changes: 1 addition & 2 deletions roles/generate-jenkins/templates/ISSUE_TEMPLATE.feature.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{%- set output_format="# \\g<message>" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set markdown="gfm" -%}
# Based on the issue template
name: Feature request
description: Suggest an idea for this project
Expand Down
3 changes: 1 addition & 2 deletions roles/generate-jenkins/templates/PULL_REQUEST_TEMPLATE.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{%- set output_format="# \\g<message>" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set markdown="gfm" -%}
{% if project_deprecation_status %}
{% include "README_SNIPPETS/DEPRECATION.j2" | trim %}

Expand Down
4 changes: 1 addition & 3 deletions roles/generate-jenkins/templates/README.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#jinja2: keep_trailing_newline:True
{%- set output_format="# \\g<message>" -%}
{%- set markdown="gfm" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set has_latest= true if (development_versions == true and 'latest' in (development_versions_items | map(attribute="tag"))) or (development_versions == false) else false -%}
{% include "README_SNIPPETS/DO_NOT_EDIT.j2" | trim %}
Expand All @@ -9,8 +9,6 @@
{% include "README_SNIPPETS/DEPRECATION.j2" | trim %}

{% endif %}
{%- set output_format="**\\g<level>**: \\g<message>" -%}
{%- from 'common_macros.j2' import noter with context %}
# [{{ lsio_project_name_short }}/{{ project_name }}]({{ project_github_repo_url }})

{% include "README_SNIPPETS/PROJECT_BADGES.j2" | trim %}
Expand Down
3 changes: 1 addition & 2 deletions roles/generate-jenkins/templates/README.j2-CUSTOM
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{%- set output_format="# \\g<message>" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set markdown="gfm" -%}
{% include "README_SNIPPETS/DO_NOT_EDIT.j2" | trim %}

{% if project_deprecation_status %}
Expand Down
10 changes: 9 additions & 1 deletion roles/generate-jenkins/templates/common_macros.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{% macro noter(text) -%}
{{ text | regex_replace('\?\+(?P<level>\w+)(?>\[(?P<title>[ \'\"\w]+)\])?\(\|(?P<message>.*)\|\)', output_format ) }}
{% set ns = namespace(text=text) %}
{% for match in (text | regex_findall('\?\+(?:\w+)(?:\[(?:[ \'\"\w]+)\])?\(\|(?:.*)\|\)')) %}
{%- set match_obj=(match | regex_replace('\?\+(?P<severity>\w+)(?>\[(?P<title>[ \'\"\w]+)\])?\(\|(?P<message>.*)\|\)','{"message":"\g<message>",
"severity":"\g<severity>", "title":"\g<title>"}')) | from_json -%}
{%- set match_result=match_obj.get("message") | admonition(flavour=markdown, severity=match_obj.get("severity"), title=match_obj.get("title")) -%}
{%- set ns.text=(ns.text | replace(match, match_result)) -%}
{% endfor %}
{{ ns.text }}
{%- endmacro %}
4 changes: 1 addition & 3 deletions roles/generate-jenkins/templates/lite.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{%- set output_format="# \\g<message>" -%}
{%- set markdown="gfm" -%}
{% from 'common_macros.j2' import noter with context %}
{% if project_deprecation_status %}
{% include "README_SNIPPETS/DEPRECATION.j2" | trim %}

{% endif %}
{%- set output_format="**\\g<level>**: \\g<message>" -%}
{%- from 'common_macros.j2' import noter with context %}
# [{{ lsio_project_name_short }}/{{ project_name }}]({{ project_github_repo_url }})

## This readme has been truncated from the full version found [HERE]({{ project_github_repo_url }})
Expand Down
3 changes: 1 addition & 2 deletions roles/generate-jenkins/templates/lite.j2-CUSTOM
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{%- set output_format="# \\g<message>" -%}
{% from 'common_macros.j2' import noter with context %}
{%- set markdown="gfm" -%}
{% if project_deprecation_status %}
{% include "README_SNIPPETS/DEPRECATION.j2" | trim %}

Expand Down

0 comments on commit d2f9911

Please sign in to comment.