Skip to content

Commit

Permalink
Menu: Update Help - Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKSerene committed Nov 27, 2023
1 parent 3d3906f commit bfbd598
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 112 deletions.
16 changes: 5 additions & 11 deletions utils/wl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ def check_os():
return is_windows, is_macos, is_linux

def get_wl_ver():
wl_ver = '1.0.0'
with open('../VERSION', 'r', encoding = 'utf_8') as f:
for line in f:
if line.strip() and not line.startswith('#'):
wl_ver = line.strip()

try:
# Version file is generated on Windows
with open('../VERSION', 'r', encoding = 'utf_8', newline = '\r\n') as f:
for line in f:
if line.strip() and not line.startswith('#'):
wl_ver = line.strip()

break
except (FileNotFoundError, PermissionError):
pass
break

return wl_ver
177 changes: 87 additions & 90 deletions wordless/wl_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,110 +1085,107 @@ def __init__(self, main):

changelog = []

try:
with open(wl_paths.get_path_file('CHANGELOG.md'), 'r', encoding = 'utf_8') as f:
for line in f:
# Changelog headers
if line.startswith('## '):
release_ver = re.search(r'(?<=\[)[^\]]+?(?=\])', line).group()
release_link = re.search(r'(?<=\()[^\)]+?(?=\))', line).group()
release_date = re.search(r'(?<=\- )[0-9?]{2}/[0-9?]{2}/[0-9?]{4}', line).group()

changelog.append({
'release_ver': release_ver,
'release_link': release_link,
'release_date': release_date,
'changelog_sections': []
})

# Changelog section headers
elif line.startswith('### '):
changelog[-1]['changelog_sections'].append({
'section_header': line.replace('###', '').strip(),
'section_list': []
})
# Changelog section lists
elif line.startswith('- '):
line = re.sub(r'^- ', r'', line).strip()

changelog[-1]['changelog_sections'][-1]['section_list'].append(line)

font_size_custom = main.settings_custom['general']['ui_settings']['font_size']

changelog_text = f'''
<head>
<style>
* {{
outline: none;
margin: 0;
border: 0;
padding: 0;
text-align: justify;
}}
ul {{
line-height: 120%;
margin-bottom: 10px;
}}
li {{
margin-left: -30px;
}}
.changelog {{
margin-bottom: 5px;
}}
.changelog-header {{
margin-bottom: 3px;
font-size: {font_size_custom}pt;
font-weight: bold;
}}
.changelog-section-header {{
margin-bottom: 5px;
font-size: {font_size_custom}pt;
font-weight: bold;
}}
</style>
</head>
<body>
with open(wl_paths.get_path_file('CHANGELOG.md'), 'r', encoding = 'utf_8') as f:
for line in f:
# Changelog headers
if line.startswith('## '):
release_ver = re.search(r'(?<=\[)[^\]]+?(?=\])', line).group()
release_link = re.search(r'(?<=\()[^\)]+?(?=\))', line).group()
release_date = re.search(r'(?<=\- )[0-9?]{2}/[0-9?]{2}/[0-9?]{4}', line).group()

changelog.append({
'release_ver': release_ver,
'release_link': release_link,
'release_date': release_date,
'changelog_sections': []
})

# Changelog section headers
elif line.startswith('### '):
changelog[-1]['changelog_sections'].append({
'section_header': line.replace('###', '').strip(),
'section_list': []
})
# Changelog section lists
elif line.startswith('- '):
line = re.sub(r'^- ', r'', line).strip()

changelog[-1]['changelog_sections'][-1]['section_list'].append(line)

font_size_custom = main.settings_custom['general']['ui_settings']['font_size']

changelog_text = f'''
<head>
<style>
* {{
outline: none;
margin: 0;
border: 0;
padding: 0;
text-align: justify;
}}
ul {{
line-height: 120%;
margin-bottom: 10px;
}}
li {{
margin-left: -30px;
}}
.changelog {{
margin-bottom: 5px;
}}
.changelog-header {{
margin-bottom: 3px;
font-size: {font_size_custom}pt;
font-weight: bold;
}}
.changelog-section-header {{
margin-bottom: 5px;
font-size: {font_size_custom}pt;
font-weight: bold;
}}
</style>
</head>
<body>
'''

for release in changelog:
changelog_text += f'''
<div class="changelog">
<div class="changelog-header"><a href="{release['release_link']}">{release['release_ver']}</a> - {release['release_date']}</div>
<hr>
'''

for release in changelog:
for changelog_section in release['changelog_sections']:
changelog_text += f'''
<div class="changelog">
<div class="changelog-header"><a href="{release['release_link']}">{release['release_ver']}</a> - {release['release_date']}</div>
<hr>
<div class="changelog-section">
<div class="changelog-section-header">{changelog_section['section_header']}</div>
<ul>
'''

for changelog_section in release['changelog_sections']:
for item in changelog_section['section_list']:
changelog_text += f'''
<div class="changelog-section">
<div class="changelog-section-header">{changelog_section['section_header']}</div>
<ul>
'''

for item in changelog_section['section_list']:
changelog_text += f'''
<li>{item}</li>
'''

changelog_text += '''
</ul>
</div>
<li>{item}</li>
'''

changelog_text += '''
</ul>
</div>
'''

changelog_text += '''
</body>
</div>
'''
except (FileNotFoundError, PermissionError):
changelog_text = traceback.format_exc()

changelog_text += '''
</body>
'''

text_edit_changelog = wl_editors.Wl_Text_Browser(self)
text_edit_changelog.setHtml(changelog_text)
Expand Down
16 changes: 5 additions & 11 deletions wordless/wl_utils/wl_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,12 @@ def get_linux_distro():


def get_wl_ver():
wl_ver = '1.0.0'
with open(wl_paths.get_path_file('VERSION'), 'r', encoding = 'utf_8') as f:
for line in f:
if line.strip() and not line.startswith('#'):
wl_ver = line.strip()

try:
# Version file is generated on Windows
with open(wl_paths.get_path_file('VERSION'), 'r', encoding = 'utf_8', newline = '\r\n') as f:
for line in f:
if line.strip() and not line.startswith('#'):
wl_ver = line.strip()

break
except (FileNotFoundError, PermissionError):
pass
break

return packaging.version.Version(wl_ver)

Expand Down

0 comments on commit bfbd598

Please sign in to comment.