|
14 | 14 | {{ underline * definitions[category]['name']|length }} |
15 | 15 |
|
16 | 16 | {% if definitions[category]['showcontent'] %} |
17 | | -{% for text, pr_issue_numbers in sections[section][category].items() %} |
18 | | -- {{ text + '\n' }} |
| 17 | +{% for text, change_note_refs in sections[section][category].items() %} |
| 18 | +- {{ text }} |
19 | 19 |
|
| 20 | + {{- '\n' * 2 -}} |
| 21 | + |
| 22 | + {#- |
| 23 | + NOTE: Replacing 'e' with 'f' is a hack that prevents Jinja's `int` |
| 24 | + NOTE: filter internal implementation from treating the input as an |
| 25 | + NOTE: infinite float when it looks like a scientific notation (with a |
| 26 | + NOTE: single 'e' char in between digits), raising an `OverflowError`, |
| 27 | + NOTE: subsequently. 'f' is still a hex letter so it won't affect the |
| 28 | + NOTE: check for whether it's a (short or long) commit hash or not. |
| 29 | + Ref: https://github.com/pallets/jinja/issues/1921 |
| 30 | + -#} |
| 31 | + {%- |
| 32 | + set pr_issue_numbers = change_note_refs |
| 33 | + | map('lower') |
| 34 | + | map('replace', 'e', 'f') |
| 35 | + | map('int', default=None) |
| 36 | + | select('integer') |
| 37 | + | map('string') |
| 38 | + | list |
| 39 | + -%} |
| 40 | + {%- set arbitrary_refs = [] -%} |
| 41 | + {%- set commit_refs = [] -%} |
| 42 | + {%- with -%} |
| 43 | + {%- set commit_ref_candidates = change_note_refs | reject('in', pr_issue_numbers) -%} |
| 44 | + {%- for cf in commit_ref_candidates -%} |
| 45 | + {%- if cf | length in (7, 8, 40) and cf | int(default=None, base=16) is not none -%} |
| 46 | + {%- set _ = commit_refs.append(cf) -%} |
| 47 | + {%- else -%} |
| 48 | + {%- set _ = arbitrary_refs.append(cf) -%} |
| 49 | + {%- endif -%} |
| 50 | + {%- endfor -%} |
| 51 | + {%- endwith -%} |
| 52 | + |
| 53 | + {% if pr_issue_numbers %} |
20 | 54 | *Related issues and pull requests on GitHub:* |
21 | | - {{ pr_issue_numbers | join(', ') }}. |
| 55 | + :issue:`{{ pr_issue_numbers | join('`, :issue:`') }}`. |
| 56 | + {{- '\n' * 2 -}} |
| 57 | + {%- endif -%} |
| 58 | + |
| 59 | + {% if commit_refs %} |
| 60 | + *Related commits on GitHub:* |
| 61 | + :commit:`{{ commit_refs | join('`, :commit:`') }}`. |
| 62 | + {{- '\n' * 2 -}} |
| 63 | + {%- endif -%} |
| 64 | + |
| 65 | + {% if arbitrary_refs %} |
| 66 | + *Unlinked references:* |
| 67 | + {{ arbitrary_refs | join(', ') }}. |
| 68 | + {{- '\n' * 2 -}} |
| 69 | + {%- endif -%} |
22 | 70 |
|
23 | 71 | {% endfor %} |
24 | 72 | {% else %} |
|
0 commit comments