Skip to content

Commit

Permalink
adding simple script for generating changelogs. wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freyamade committed Jun 29, 2024
1 parent 65e9a7f commit a3416c5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 14 deletions.
51 changes: 51 additions & 0 deletions changelog_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from bs4 import BeautifulSoup
from bs4.element import TemplateString

# Open the changelog file, split it on <script> tag, use the 0th element

with open('frontend/src/components/modals/changelog.vue') as f:
template = f.read().split('<script>')[0]

soup = BeautifulSoup(template, features='html.parser')

lines = []
dividers = soup.select('div.divider')

for div in dividers:
# Get the text from the divider
lines.append(f'## {str([c for c in div.children][1]).strip()}')

# Iterate through the siblings until we reach another divider
sibling = div.find_next_sibling()
if sibling.name == 'div':
continue
elif sibling.name != 'p':
print('found non p, non div tag', sibling.name)
continue

while sibling is not None and sibling.name != 'div':
is_info = False
# It's definitely a p tag, got some rules to look at
# If it's info text, add asterisks for italics
if 'has-text-info' in sibling.attrs.get('class', set()):
is_info = True

# Parse the children elements of the p tag
for child in sibling.children:
if isinstance(child, TemplateString):
line = str(child).strip()
if len(line) == 0:
continue
elif is_info:
lines.append(f'- *{line}*')
else:
lines.append(f'- {line}')
elif child.name == 'ul':
for list_item in child.children:
if not isinstance(list_item, TemplateString):
lines.append(f' - {str(list_item.contents[0]).strip()}')

sibling = sibling.find_next_sibling()
lines.append('\n')

print('\n'.join(lines))
15 changes: 1 addition & 14 deletions frontend/src/components/modals/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,9 @@
<h2 class="has-text-primary subtitle">{{ version }}</h2>
<div class="divider"><i class="material-icons icon">expand_more</i> Dawntrail Release <i class="material-icons icon">expand_more</i></div>
<p>Happy first new expansion for SavageAim, and a happy 7.0 to all of you wonderful gamers out there!</p>
<p class="changelog-icon-text">
<span>Added two new Jobs!</span>
<span class="icon">
<img src="/job_icons/VPR.webp" alt="Viper Job Icon" width="24" height="24" />
</span>
<span class="icon">
<img src="/job_icons/PCT.webp" alt="Pictomancer Job Icon" width="24" height="24" />
</span>
</p>
<p>Added Viper (VPR) and Pictomancer (PCT)!</p>
<p class="has-text-info">The current icons are temporary. Once XIVAPI's repo gets the fancy shaded ones, I'll update them!</p>

<div class="divider"><i class="material-icons icon">expand_more</i> FFXIV 7.0 <i class="material-icons icon">expand_more</i></div>
<p>
Added Gear associated with Dawntrail's release;
<ul>
Expand Down Expand Up @@ -67,8 +58,4 @@ export default class Changelog extends Vue {
</script>

<style lang="scss">
.changelog-icon-text {
display: inline-flex;
gap: 1rem;
}
</style>

0 comments on commit a3416c5

Please sign in to comment.