1
0
Fork 0
mirror of https://github.com/Findus23/new-github-changelog-generator.git synced 2024-08-27 19:52:18 +02:00
new-github-changelog-generator/generator/formatters/markdown.py

31 lines
1.1 KiB
Python
Raw Normal View History

2019-02-03 14:10:17 +01:00
import html
from generator.formatters import BaseFormatter
class MarkdownFormatter(BaseFormatter):
def __str__(self) -> str:
text = ""
2019-02-03 16:33:44 +01:00
for repo in self.repos:
if repo.issues:
2019-02-03 18:26:13 +01:00
if len(self.repos) > 1:
text += "### [{}]({})\n".format(repo.path, repo.absolute_url)
2019-02-03 16:33:44 +01:00
for issue in repo.issues:
text += " - [#{id}]({url}) {title}".format(
url=issue.url,
id=issue.number,
title=html.escape(issue.title)
2019-02-03 14:10:17 +01:00
)
2019-02-03 16:33:44 +01:00
if issue.authors:
text += " [by {}]".format(
", ".join(
"[@{name}]({url})".format(
url=author.profile_url,
name=html.escape(author.username)
) for author in issue.authors
)
)
text += "\n"
2019-02-03 14:10:17 +01:00
return text