@@ -42,11 +42,21 @@ pub fn render_changelog_content(output: &mut impl Write) -> Result<()> {
4242 style:: SetForegroundColor ( Color :: Reset ) ,
4343 ) ?;
4444
45- for change in & entry. changes {
46- // Process **bold** syntax and remove PR links
45+ let mut sorted_changes = entry. changes . clone ( ) ;
46+ sorted_changes. sort_by ( |a, b| a. change_type . cmp ( & b. change_type ) ) ;
47+
48+ for change in & sorted_changes {
4749 let cleaned_description = clean_pr_links ( & change. description ) ;
4850 let processed_description = process_bold_text ( & cleaned_description) ;
49- execute ! ( output, style:: Print ( "• " ) ) ?;
51+ let capitalized_type = capitalize_first_word ( & change. change_type ) ;
52+ execute ! ( output, style:: Print ( "• [" ) ) ?;
53+ execute ! (
54+ output,
55+ style:: SetForegroundColor ( Color :: Magenta ) ,
56+ style:: Print ( & capitalized_type) ,
57+ style:: SetForegroundColor ( Color :: Reset ) ,
58+ ) ?;
59+ execute ! ( output, style:: Print ( "] " ) ) ?;
5060 print_with_bold ( output, & processed_description) ?;
5161 execute ! ( output, style:: Print ( "\n " ) ) ?;
5262 }
@@ -60,6 +70,19 @@ pub fn render_changelog_content(output: &mut impl Write) -> Result<()> {
6070 Ok ( ( ) )
6171}
6272
73+ /// Capitalizes the first character of a string.
74+ fn capitalize_first_word ( s : & str ) -> String {
75+ let mut chars = s. chars ( ) ;
76+ match chars. next ( ) {
77+ None => String :: new ( ) ,
78+ Some ( first) => {
79+ let mut result = first. to_uppercase ( ) . collect :: < String > ( ) ;
80+ result. push_str ( chars. as_str ( ) ) ;
81+ result
82+ } ,
83+ }
84+ }
85+
6386/// Removes PR links and numbers from changelog descriptions to improve readability.
6487///
6588/// Removes text matching the pattern " - [#NUMBER](URL)" from the end of descriptions.
0 commit comments