Skip to content

Commit

Permalink
feat(dev): icons and lists;
Browse files Browse the repository at this point in the history
- Better support for markdown lists.
- Added type icons for the change log titles.
  • Loading branch information
JVickery-TBS committed Aug 9, 2024
1 parent d76ba09 commit 84072f2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
42 changes: 42 additions & 0 deletions docs/source/_static/css/canada_theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,36 @@ ul.changes-list li span{

}

ul.changes-list ul{

list-style: disc;
padding-left: 30px;
margin-top: 5px !important;
margin-bottom: 5px !important;

}

ul.changes-list ul li{

list-style: disc;

}

ul.changes-list ol{

list-style: decimal;
padding-left: 30px;
margin-top: 5px !important;
margin-bottom: 5px !important;

}

ul.changes-list ol li{

list-style: decimal;

}

span.change-sub-note{

font-weight: 600;
Expand All @@ -268,6 +298,18 @@ span.change-backport{

}

.change-canada-type-title{

position: relative;

}

.change-canada-type-icon::before{

color: rgba(0, 0, 0, 0.525);

}

a.headerlink{

text-decoration: none !important;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h3 class="release-repo-title">
<p><i class="fas fa-info-circle"></i>&nbsp;<em>This repository is only tracked from upstream.</em></p>
{% elif info.change_logs %}
{% for type, changes in info.change_logs.items() %}
<h4>{{ type }}</h4>
<h4 class="change-canada-type-title"><i class="fa {{ type_icons.get(type) }} change-canada-type-icon"></i>&nbsp;&nbsp;{{ type }}</h4>
<ul class="changes-list">
{% for change in changes %}
<li>
Expand Down
29 changes: 27 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
MARKDOWN_TAGS = set([
'del', 'dd', 'dl', 'dt', 'h1', 'h2',
'h3', 'img', 'kbd', 'p', 'pre', 's',
'sup', 'sub', 'strike', 'br', 'hr'
'sup', 'sub', 'strike', 'br', 'hr',
'ul', 'ol', 'li',
]).union(ALLOWED_TAGS)

MARKDOWN_ATTRIBUTES = copy.deepcopy(ALLOWED_ATTRIBUTES)
Expand Down Expand Up @@ -98,6 +99,15 @@ def escape(cls, s):
]
REMOVAL_LABEL = 'Removals'

LABEL_MAP = [FEATURE_LABEL, FIX_LABEL, REMOVAL_LABEL, CHANGES_LABEL, MIGRATION_LABEL]
LABEL_ICONS = {
FEATURE_LABEL: 'fa-code-fork',
FIX_LABEL: 'fa-wrench',
REMOVAL_LABEL: 'fa-trash',
CHANGES_LABEL: 'fa-code',
MIGRATION_LABEL: 'fa-database',
}


# Configuration file for the Sphinx documentation builder.
#
Expand Down Expand Up @@ -440,7 +450,11 @@ def parsed_release_hashses():
for project_name, project_stack in changelog_dicts.items():
for repo, changelog_dict in project_stack.items():
if repo in parsed_release_hashses[release][project_name]:
parsed_release_hashses[release][project_name][repo]['change_logs'] = changelog_dict
sorted_dict = {}
for _key in LABEL_MAP:
if _key in changelog_dict:
sorted_dict[_key] = changelog_dict[_key]
parsed_release_hashses[release][project_name][repo]['change_logs'] = sorted_dict

sorted_dict = dict(reversed(parsed_release_hashses.items()))
parsed_release_hashses = sorted_dict
Expand Down Expand Up @@ -481,8 +495,18 @@ def render_markdown(data):
If False all html tags are removed.
:type allow_html: bool
"""
#FIXME: sublists
if not data:
return ''
markdown_lists = [
'\n -',
'\n *',
'\n +',
'\n 1.',
]
for match in markdown_lists:
if match in data:
data = data.replace(match, '\n%s' % match)
data = RE_MD_HTML_TAGS.sub('', data.strip())
data = bleach_clean(
markdown(data), strip=True,
Expand All @@ -494,6 +518,7 @@ def render_markdown(data):
html_context = {
'release_tags': release_tags,
'release_hashes': release_hashes,
'type_icons': LABEL_ICONS,
'version_prefix': FRONTEND_VERSION_PREFIX,
'render_markdown': render_markdown,
}

0 comments on commit 84072f2

Please sign in to comment.