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 section depth in markdown template #664

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/663.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Markdown template: Render category headers as h2 when no sections are present.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment... and mauybe this should be a .removal type of fragment.

It should explain the existing users should manually update existing NEWS file to match the new H2 format.

Suggested change
Markdown template: Render category headers as h2 when no sections are present.
When no sections are present, the default Markdown template now renders the category headers as H2. In previous versions it was rendered as H3.

2 changes: 1 addition & 1 deletion src/towncrier/templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
13 changes: 6 additions & 7 deletions src/towncrier/test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1387,7 +1386,7 @@ def test_default_start_string_markdown(self, runner):

# Foo 1.2.3 (01-01-2001)

### Features
## Features

- Adds levitation (#123)

Expand Down Expand Up @@ -1437,7 +1436,7 @@ def test_markdown_no_name_title(self, runner):

# 1.2.3 (01-01-2001)

### Features
## Features

- Adds levitation (#123)
"""
Expand Down Expand Up @@ -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!
Expand Down
8 changes: 4 additions & 4 deletions src/towncrier/test/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ def test_markdown(self):

expected_output = """# MyProject 1.0 (never)

### Features
## Features

- Fun! (baz)
- Foo added. (#2, #9, #72)
- Multi-line
here (#3)
- Stuff! (#4)

### Misc
## Misc

- bar, #1, #9, #142

Expand Down Expand Up @@ -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])
Expand All @@ -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]

Expand Down
Loading