Skip to content

Commit

Permalink
Fix rendered towncrier changelog to be consistent with the way towncr…
Browse files Browse the repository at this point in the history
…ier does it (#12)

* Fix rendered towncrier changelog to be consistent with the way towncrier does it

* Fix template to not include top_line

* Fix code style

* Added news fragment

* Add a conditional check to hack around the default template

Co-authored-by: Stuart Mumford <stuart@cadair.com>
  • Loading branch information
astrofrog and Cadair authored Aug 19, 2021
1 parent a5905cc commit 39909a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/12.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed rendering to match towncrier, which means that top_line should not be included in the template.
2 changes: 1 addition & 1 deletion changelog/template.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if top_line %}
{{ top_line }}

{{ top_underline * ((top_line)|length)}}
{% elif versiondata.name %}
{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
Expand Down
7 changes: 7 additions & 0 deletions sphinx_changelog/towncrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,11 @@ def generate_changelog_for_docs(directory, skip_if_empty=True, underline=1):
)

os.chdir(curdir)

# To work around https://github.com/twisted/towncrier/issues/346 we check
# to see if the template is going to write the top_line, and if it isn't
# then we write it.
if "{{ top_line }}" not in template:
rendered = top_line + rendered

return rendered

0 comments on commit 39909a2

Please sign in to comment.