From f481b8cb1dfa353c61926713e30197caba67b249 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 23 Aug 2024 16:01:55 +0200 Subject: [PATCH 1/3] Fix section depth in markdown template --- src/towncrier/templates/default.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/towncrier/templates/default.md b/src/towncrier/templates/default.md index 0aa7262c..4a5a07d4 100644 --- a/src/towncrier/templates/default.md +++ b/src/towncrier/templates/default.md @@ -13,7 +13,7 @@ {% if sections[section] %} {% for category, val in definitions.items() if category in sections[section] %} -### {{ definitions[category]['name'] }} +##{% if section %}#{% endif %} {{ definitions[category]['name'] }} {% for text, values in sections[section][category].items() %} - {{ text }} From f5e2a0ca15e5919c3561f5f707962f411666c43b Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 23 Aug 2024 16:11:57 +0200 Subject: [PATCH 2/3] Add news fragment --- src/towncrier/newsfragments/663.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/towncrier/newsfragments/663.bugfix.rst diff --git a/src/towncrier/newsfragments/663.bugfix.rst b/src/towncrier/newsfragments/663.bugfix.rst new file mode 100644 index 00000000..aab065a4 --- /dev/null +++ b/src/towncrier/newsfragments/663.bugfix.rst @@ -0,0 +1 @@ +Markdown template: Render category headers as h2 when no sections are present. From 56e0035f3dba6413327310a3cced2c184235c879 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Fri, 23 Aug 2024 16:37:03 +0200 Subject: [PATCH 3/3] Fix tests --- src/towncrier/test/test_build.py | 13 ++++++------- src/towncrier/test/test_format.py | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/towncrier/test/test_build.py b/src/towncrier/test/test_build.py index 0092d495..76c75aa2 100644 --- a/src/towncrier/test/test_build.py +++ b/src/towncrier/test/test_build.py @@ -1085,7 +1085,7 @@ def test_title_format_custom_markdown(self, runner): [20-01-2001] CUSTOM RELEASE for FooBarBaz version 7.8.9 - ### Features + ## Features - Adds levitation (#123) @@ -1136,11 +1136,10 @@ def test_markdown_injected_after_header(self, runner): ) default_template = read_pkg_resource("templates/default.md") + assert "##{%" in default_template write( "custom_template.md", - contents=default_template.replace( - "### {{ definitions", "#### {{ definitions" - ), + contents=default_template.replace("##{%", "####{%"), ) result = runner.invoke(_main, ["--date", "01-01-2001"], catch_exceptions=False) @@ -1387,7 +1386,7 @@ def test_default_start_string_markdown(self, runner): # Foo 1.2.3 (01-01-2001) - ### Features + ## Features - Adds levitation (#123) @@ -1437,7 +1436,7 @@ def test_markdown_no_name_title(self, runner): # 1.2.3 (01-01-2001) - ### Features + ## Features - Adds levitation (#123) """ @@ -1607,7 +1606,7 @@ def test_orphans_in_non_showcontent_markdown(self, runner): # 7.8.9 (20-01-2001) - ### Misc + ## Misc - #123, #345 - Another orphan misc still displayed! diff --git a/src/towncrier/test/test_format.py b/src/towncrier/test/test_format.py index a1efefb5..eee947e5 100644 --- a/src/towncrier/test/test_format.py +++ b/src/towncrier/test/test_format.py @@ -205,7 +205,7 @@ def test_markdown(self): expected_output = """# MyProject 1.0 (never) -### Features +## Features - Fun! (baz) - Foo added. (#2, #9, #72) @@ -213,7 +213,7 @@ def test_markdown(self): here (#3) - Stuff! (#4) -### Misc +## Misc - bar, #1, #9, #142 @@ -254,7 +254,7 @@ def test_markdown(self): # Also test with custom issue format expected_output = """# MyProject 1.0 (never) -### Features +## Features - Fun! ([baz]) - Foo added. ([2], [9], [72]) @@ -269,7 +269,7 @@ def test_markdown(self): [9]: https://github.com/twisted/towncrier/issues/9 [72]: https://github.com/twisted/towncrier/issues/72 -### Misc +## Misc - [bar], [1], [9], [142]