@@ -1008,7 +1008,7 @@ public async static Task<bool> CreateModulesListing(this ModuleCollection module
10081008 Downloads = 0
10091009 } ) . ToList ( ) ;
10101010
1011- // Add renamed modules, but with their names, but only server revisions v2.4+
1011+ // Add renamed modules, using their new (current) names, but listing only server revisions v2.4+
10121012 foreach ( var pair in corrections )
10131013 {
10141014 ModuleConfig ? module = modules . Values . Where ( m => m . ModuleId == pair . NewModuleId ) . FirstOrDefault ( ) ;
@@ -1059,7 +1059,7 @@ public async static Task<bool> CreateModulesListing(this ModuleCollection module
10591059 var options = new JsonSerializerOptions { WriteIndented = true } ;
10601060 string configJson = JsonSerializer . Serialize ( moduleList , options ) ;
10611061
1062- configJson += "\n /*\n \n " + CreateModulesListingHtml ( modules , versionInfo ) + "\n */" ;
1062+ configJson += "\n /*\n \n " + CreateModulesListingMarkdown ( modules , versionInfo ) + "\n */" ;
10631063
10641064 await File . WriteAllTextAsync ( path , configJson ) . ConfigureAwait ( false ) ;
10651065
@@ -1073,7 +1073,7 @@ public async static Task<bool> CreateModulesListing(this ModuleCollection module
10731073 }
10741074
10751075 /// <summary>
1076- /// Creates markdown representing the file modules available.
1076+ /// Creates HTML representing the file modules available.
10771077 /// </summary>
10781078 /// <param name="modules">This set of module configs</param>
10791079 /// <param name="versionInfo">The version info for the current server</param>
@@ -1142,7 +1142,69 @@ private static string CreateModulesListingHtml(ModuleCollection modules,
11421142 return list . ToString ( ) ;
11431143 }
11441144
1145- private static string PlatformList ( string [ ] platforms )
1145+ /// <summary>
1146+ /// Creates Markdown representing the file modules available.
1147+ /// </summary>
1148+ /// <param name="modules">This set of module configs</param>
1149+ /// <param name="versionInfo">The version info for the current server</param>
1150+ /// <returns>A string</returns>
1151+ private static string CreateModulesListingMarkdown ( ModuleCollection modules ,
1152+ VersionInfo versionInfo )
1153+ {
1154+ var moduleList = modules . Values . Where ( m => m . InstallOptions ! . ModuleLocation == ModuleLocation . Internal ||
1155+ m . InstallOptions ! . ModuleLocation == ModuleLocation . External )
1156+ . OrderBy ( m => m . PublishingInfo ! . Category )
1157+ . ThenBy ( m => m . Name ) ;
1158+
1159+ StringBuilder list ;
1160+ if ( versionInfo is not null )
1161+ list = new StringBuilder ( $ "Supporting CodeProject.AI Server { versionInfo . Version } .\n ") ;
1162+ else
1163+ list = new StringBuilder ( ) ;
1164+
1165+ string ? currentCategory = string . Empty ;
1166+ foreach ( var module in moduleList )
1167+ {
1168+ if ( currentCategory != module . PublishingInfo ! . Category )
1169+ {
1170+ if ( list . Length > 0 )
1171+ list . AppendLine ( "\n " ) ;
1172+
1173+ list . AppendLine ( $ "### { module . PublishingInfo ! . Category } ") ;
1174+ list . AppendLine ( ) ;
1175+ currentCategory = module . PublishingInfo ! . Category ;
1176+ }
1177+
1178+ list . AppendLine ( $ " - **{ module . Name } **<br>") ;
1179+ list . AppendLine ( $ " { module . PublishingInfo . Description } <br>") ;
1180+
1181+ list . Append ( $ " v{ module . Version } ") ;
1182+ list . Append ( $ "{ PlatformList ( module . InstallOptions ! . Platforms , false ) } ") ;
1183+ list . AppendLine ( $ "{ module . PublishingInfo . Stack } <br>") ;
1184+
1185+ string author = string . IsNullOrWhiteSpace ( module . PublishingInfo . Author )
1186+ ? "Anonymous Legend" : module . PublishingInfo . Author ;
1187+ string basedOn = string . IsNullOrWhiteSpace ( module . PublishingInfo . BasedOn )
1188+ ? "this project" : module . PublishingInfo . BasedOn ;
1189+
1190+ // list.AppendLine();
1191+ if ( ! string . IsNullOrWhiteSpace ( module . PublishingInfo . Homepage ) )
1192+ list . Append ( $ " Project by [{ author } ]({ module . PublishingInfo . Homepage } )") ;
1193+ else
1194+ list . Append ( $ " By { author } ") ;
1195+ if ( ! string . IsNullOrWhiteSpace ( module . PublishingInfo . BasedOnUrl ) )
1196+ list . Append ( $ ", based on [{ basedOn } ]({ module . PublishingInfo . BasedOnUrl } ).") ;
1197+ else if ( ! string . IsNullOrWhiteSpace ( module . PublishingInfo . BasedOn ) )
1198+ list . Append ( $ ", based on { module . PublishingInfo . BasedOn } .") ;
1199+
1200+ list . AppendLine ( ) ;
1201+ list . AppendLine ( "<br>" ) ;
1202+ }
1203+
1204+ return list . ToString ( ) ;
1205+ }
1206+
1207+ private static string PlatformList ( string [ ] platforms , bool html = true )
11461208 {
11471209 var realNames = platforms . Select ( p => {
11481210 string suffix = string . Empty ;
@@ -1156,10 +1218,26 @@ private static string PlatformList(string[] platforms)
11561218 return suffix + string . Concat ( char . ToUpper ( p [ 0 ] ) , p [ 1 ..] ) ;
11571219 } ) ;
11581220
1159- var removes = string . Join ( " " , realNames . Where ( p => p . StartsWith ( '!' ) )
1221+ string removes , keeps ;
1222+ if ( html )
1223+ {
1224+ removes = string . Join ( " " , realNames . Where ( p => p . StartsWith ( '!' ) )
11601225 . Select ( p => $ "<span class='t'>{ p [ 1 ..] } </span>") ) ;
1161- var keeps = string . Join ( " " , realNames . Where ( p => ! p . StartsWith ( '!' ) )
1226+ keeps = string . Join ( " " , realNames . Where ( p => ! p . StartsWith ( '!' ) )
11621227 . Select ( p => $ "<span class='t'>{ p } </span>") ) ;
1228+ }
1229+ else
1230+ {
1231+ removes = string . Join ( " " , realNames . Where ( p => p . StartsWith ( '!' ) )
1232+ . Select ( p => $ "{ p [ 1 ..] } , ") ) ;
1233+ keeps = string . Join ( " " , realNames . Where ( p => ! p . StartsWith ( '!' ) )
1234+ . Select ( p => $ "{ p } , ") ) ;
1235+
1236+ if ( removes . EndsWith ( ", " ) ) removes = removes [ ..^ 2 ] ;
1237+ if ( keeps . EndsWith ( ", " ) ) keeps = keeps [ ..^ 2 ] ;
1238+
1239+ if ( keeps == "All" ) keeps = "All Platforms" ;
1240+ }
11631241
11641242 string platformString = keeps ;
11651243 if ( ! string . IsNullOrEmpty ( removes ) )
0 commit comments