Skip to content

Commit

Permalink
Improve formatting for changelog generating script
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll committed Mar 13, 2024
1 parent 1057001 commit 08f4c13
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/py/flwr_tool/update_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _get_pull_requests_since_tag(gh_api, tag):

def _format_pr_reference(title, number, url):
"""Format a pull request reference as a markdown list item."""
return f"- **{title}** ([#{number}]({url}))"
return f"- **{title.replace('*', '')}** ([#{number}]({url}))"


def _extract_changelog_entry(pr_info):
Expand Down Expand Up @@ -193,11 +193,24 @@ def _insert_new_entry(content, pr_info, pr_reference, pr_entry_text, unreleased_
content = content[:pr_ref_end] + updated_entry + content[existing_entry_start:]
else:
insert_index = content.find("\n", unreleased_index) + 1

# Split the pr_entry_text into paragraphs
paragraphs = pr_entry_text.split("\n")

# Indent each paragraph
indented_paragraphs = [
" " + paragraph if paragraph else paragraph for paragraph in paragraphs
]

# Join the paragraphs back together, ensuring each is separated by a newline
indented_pr_entry_text = "\n".join(indented_paragraphs)

content = (
content[:insert_index]
+ "\n"
+ pr_reference
+ "\n "
+ pr_entry_text
+ "\n\n"
+ indented_pr_entry_text
+ "\n"
+ content[insert_index:]
)
Expand Down

0 comments on commit 08f4c13

Please sign in to comment.