Dev #14

Merged
omegaleo merged 53 commits from dev into main 2026-05-15 21:04:51 +00:00
10 changed files with 320 additions and 69 deletions
Showing only changes of commit d4e41c9747 - Show all commits
@@ -1,8 +1,10 @@
using System;
using NetFlow.DocumentationHelper.Library.Attributes;
namespace OmegaLeo.HelperLib.Changelog.Attributes
{
[Changelog("v1.0.0", "Created ChangelogAttribute to be used to register changes in the code.")]
[Documentation(nameof(ChangelogAttribute), "Attribute to annotate classes, methods, or properties with changelog information.")]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)]
public class ChangelogAttribute : Attribute
{
@@ -18,4 +18,10 @@
<None Include="LICENSE.md" Pack="true" PackagePath="\"/>
</ItemGroup>
<ItemGroup>
<Reference Include="NetFlow.DocumentationHelper.Library">
<HintPath>..\..\..\..\..\..\home\omegaleo\.nuget\packages\netflow.documentationhelper.library\1.1.2\lib\netstandard2.1\NetFlow.DocumentationHelper.Library.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
@@ -2,13 +2,16 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using NetFlow.DocumentationHelper.Library.Attributes;
using OmegaLeo.HelperLib.Changelog.Attributes;
namespace OmegaLeo.HelperLib.Changelog.Tools
{
[Changelog("v1.0.0", "Created the class ChangelogTool to extract changelogs via attributes")]
[Documentation("ChangelogTool", "Provides methods to extract changelog information from assembly attributes.")]
public class ChangelogTool
{
[Documentation("ChangelogTool.ExtractChangelog", "Extracts changelog entries from the specified assembly.")]
public static Dictionary<string, List<Models.Changelog>> ExtractChangelog(Assembly assembly)
{
var changelogByVersion = new Dictionary<string, List<Models.Changelog>>();
@@ -32,6 +35,7 @@ namespace OmegaLeo.HelperLib.Changelog.Tools
return changelogByVersion;
}
[Documentation("ChangelogTool.GetMarkdown", "Generates a markdown formatted changelog from the assembly's changelog attributes.")]
public static string GetMarkdown(Assembly assembly)
{
var changelog = ExtractChangelog(assembly);
@@ -1,7 +1,9 @@
// File: `OmegaLeo.HelperLib.Web/Controllers/HomeController.cs`
using System.Diagnostics;
using System.Reflection;
using GameDevLibrary.Helpers;
using Microsoft.AspNetCore.Mvc;
using NetFlow.DocumentationHelper.Library.Helpers;
using OmegaLeo.HelperLib.Changelog.Tools;
using OmegaLeo.HelperLib.Web.Models;
@@ -10,33 +12,57 @@ namespace OmegaLeo.HelperLib.Web.Controllers;
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private static Dictionary<string, LibraryDocumentationViewModel> _libraryCache;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
InitializeLibraries();
}
private void InitializeLibraries()
{
if (_libraryCache != null) return;
var root = GetSolutionRoot();
_libraryCache = new Dictionary<string, LibraryDocumentationViewModel>
{
["core"] = GenerateLibraryDocs(
typeof(BenchmarkUtility).Assembly,
Path.Join(root, "OmegaLeo.HelperLib", "CHANGELOG.md"),
"Core Library",
"Core utilities and helper functions for general C# development",
"OmegaLeo.HelperLib"
),
["changelog"] = GenerateLibraryDocs(
typeof(Changelog.Models.Changelog).Assembly,
Path.Join(root, "OmegaLeo.HelperLib.Changelog", "CHANGELOG.md"),
"Changelog Library",
"Tools for managing and generating changelogs",
"OmegaLeo.HelperLib.Changelog"
),
["game"] = GenerateLibraryDocs(
typeof(OmegaLeo.HelperLib.Game.Models.ConsoleCommand).Assembly,
Path.Join(root, "OmegaLeo.HelperLib.Game", "CHANGELOG.md"),
"Game Development Library",
"Game development utilities for Unity and Godot",
"OmegaLeo.HelperLib.Game"
)
};
}
public IActionResult Index()
{
var root = GetSolutionRoot();
var changelogs = new Dictionary<string, Assembly>()
{
{Path.Join(root, "OmegaLeo.HelperLib", "CHANGELOG.md"), typeof(BenchmarkUtility).Assembly},
{Path.Join(root, "OmegaLeo.HelperLib.Changelog", "CHANGELOG.md"), typeof(Changelog.Models.Changelog).Assembly},
};
return View(GenerateChangelog(changelogs));
return View(_libraryCache);
}
private IEnumerable<string> GenerateChangelog(Dictionary<string, Assembly> changelogs)
public IActionResult Library(string id)
{
foreach (var changelog in changelogs)
{
var changelogMarkdown = ChangelogTool.GetMarkdown(changelog.Value);
if (string.IsNullOrEmpty(id) || !_libraryCache.ContainsKey(id))
return NotFound();
yield return $"# {changelog.Value.GetName().Name}{Environment.NewLine}{changelogMarkdown}";
}
return View(_libraryCache[id]);
}
public IActionResult Privacy()
@@ -50,6 +76,43 @@ public class HomeController : Controller
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
private LibraryDocumentationViewModel GenerateLibraryDocs(Assembly assembly, string changelogPath, string displayName, string description, string nugetPackageId)
{
var allDocumentation = DocumentationHelperTool.GenerateDocumentation();
var assemblyName = assembly.GetName().Name;
var filteredDocumentation = allDocumentation
.Where(d => d.AssemblyName.Equals(assemblyName, StringComparison.OrdinalIgnoreCase))
.OrderBy(d => d.ClassName)
.ToList();
string changelogMarkdown = "";
if (System.IO.File.Exists(changelogPath))
{
changelogMarkdown = ChangelogTool.GetMarkdown(assembly);
}
string version = assembly.GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>()?.InformationalVersion
?? assembly.GetName().Version?.ToString()
?? "1.0.0";
if (version.Contains('+'))
{
version = version.Substring(0, version.IndexOf('+'));
}
return new LibraryDocumentationViewModel
{
LibraryName = displayName,
Description = description,
Version = version,
NuGetPackageId = nugetPackageId,
Documentation = filteredDocumentation,
ChangelogMarkdown = changelogMarkdown
};
}
static string GetSolutionRoot()
{
string dir = AppContext.BaseDirectory;
@@ -57,9 +120,9 @@ public class HomeController : Controller
while (!string.IsNullOrEmpty(dir))
{
if (Directory.GetFiles(dir, "*.sln").Length > 0)
return dir; // Found the solution root
return dir;
dir = Directory.GetParent(dir)?.FullName; // Move up a directory
dir = Directory.GetParent(dir)?.FullName;
}
throw new Exception("Solution root not found.");
@@ -0,0 +1,15 @@
// File: `OmegaLeo.HelperLib.Web/Models/LibraryDocumentationViewModel.cs`
using NetFlow.DocumentationHelper.Library.Models;
namespace OmegaLeo.HelperLib.Web.Models
{
public class LibraryDocumentationViewModel
{
public string LibraryName { get; set; }
public string Description { get; set; }
public string Version { get; set; }
public string NuGetPackageId { get; set; }
public List<DocumentationStructure> Documentation { get; set; }
public string ChangelogMarkdown { get; set; }
}
}
@@ -8,6 +8,8 @@
<ItemGroup>
<ProjectReference Include="..\OmegaLeo.HelperLib.Changelog\OmegaLeo.HelperLib.Changelog.csproj" />
<ProjectReference Include="..\OmegaLeo.HelperLib.Game\OmegaLeo.HelperLib.Game.csproj" />
<ProjectReference Include="..\OmegaLeo.HelperLib.Git\OmegaLeo.HelperLib.Git.csproj" />
<ProjectReference Include="..\OmegaLeo.HelperLib\OmegaLeo.HelperLib.csproj" />
</ItemGroup>
+33 -8
View File
@@ -1,14 +1,39 @@
@{
ViewData["Title"] = "Home Page";
@* File: `OmegaLeo.HelperLib.Web/Views/Home/Index.cshtml` *@
@model Dictionary<string, OmegaLeo.HelperLib.Web.Models.LibraryDocumentationViewModel>
@{
ViewData["Title"] = "OmegaLeo Helper Libraries";
}
@model IEnumerable<string>
<div class="container mt-5">
<div class="text-center mb-5">
<h1 class="display-4">OmegaLeo Helper Libraries</h1>
<p class="lead">Comprehensive C# libraries for game development and general utilities</p>
</div>
<div class="text-center">
<h1 class="display-4">Changelog</h1>
@foreach (var changelog in Model)
<div class="row g-4">
@foreach (var library in Model)
{
<p>@Html.Raw(Markdig.Markdown.ToHtml(changelog))</p>
<br/>
<div class="col-md-4">
<div class="card h-100 shadow-sm">
<div class="card-body">
<h5 class="card-title">@library.Value.LibraryName</h5>
<p class="card-text">@library.Value.Description</p>
<p class="text-muted small">
@library.Value.Documentation.Count classes documented
</p>
<a href="https://www.nuget.org/packages/@library.Value.NuGetPackageId"
target="_blank"
class="btn btn-sm btn-outline-primary">
<i class="bi bi-box-seam"></i> View on NuGet
</a>
</div>
<div class="card-footer">
<a asp-action="Library" asp-route-id="@library.Key" class="btn btn-primary w-100">
View Documentation
</a>
</div>
</div>
</div>
}
</div>
</div>
@@ -0,0 +1,126 @@
@* File: `OmegaLeo.HelperLib.Web/Views/Home/Library.cshtml` *@
@model OmegaLeo.HelperLib.Web.Models.LibraryDocumentationViewModel
@{
ViewData["Title"] = Model.LibraryName;
var groupedByNamespace = Model.Documentation.GroupBy(d => d.AssemblyName).OrderBy(g => g.Key);
}
<div class="container-fluid mt-4">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a asp-action="Index">Home</a></li>
<li class="breadcrumb-item active">@Model.LibraryName</li>
</ol>
</nav>
<div class="row">
<div class="col-md-3">
<div class="sticky-top" style="top: 20px;">
<div class="card">
<div class="card-header">
<h5>@Model.LibraryName</h5>
</div>
<div class="card-body p-0">
<div class="list-group list-group-flush">
<a class="list-group-item list-group-item-action" href="#overview">
<i class="bi bi-info-circle me-2"></i>Overview
</a>
@foreach (var ns in groupedByNamespace)
{
<a class="list-group-item list-group-item-action" href="#namespace-@ns.Key.Replace(".", "-")">
<i class="bi bi-folder me-2"></i>@ns.Key
</a>
}
<a class="list-group-item list-group-item-action" href="#changelog">
<i class="bi bi-clock-history me-2"></i>Changelog
</a>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-9">
<div id="overview" class="mb-5">
<h2>@Model.LibraryName</h2>
<p class="lead">@Model.Description</p>
<hr />
</div>
@foreach (var ns in groupedByNamespace)
{
<div id="namespace-@ns.Key.Replace(".", "-")" class="mb-5">
<h3>@ns.Key</h3>
@foreach (var classDoc in ns.OrderBy(d => d.ClassName))
{
<div class="card mb-3">
<div class="card-header">
<h4 class="mb-0">@classDoc.ClassName</h4>
<small class="text-muted">@classDoc.AssemblyName</small>
</div>
<div class="card-body">
@if (classDoc.Descriptions != null && classDoc.Descriptions.Any())
{
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Member</th>
<th>Documentation</th>
</tr>
</thead>
<tbody>
@foreach (var desc in classDoc.Descriptions)
{
<tr>
<td><code>@desc.Title</code></td>
<td>@Html.Raw(desc.Description)</td>
</tr>
}
</tbody>
</table>
</div>
}
else
{
<p class="text-muted">No documentation available.</p>
}
</div>
</div>
}
</div>
}
@if (!string.IsNullOrEmpty(Model.ChangelogMarkdown))
{
<div id="changelog" class="mb-5">
<h3>Changelog</h3>
<div class="card">
<div class="card-body">
@Html.Raw(Markdig.Markdown.ToHtml(Model.ChangelogMarkdown))
</div>
</div>
</div>
}
</div>
</div>
</div>
<style>
.sticky-top {
max-height: calc(100vh - 40px);
overflow-y: auto;
}
code {
background-color: #f8f9fa;
padding: 2px 6px;
border-radius: 3px;
font-size: 0.9em;
}
.table th {
background-color: #f8f9fa;
}
</style>
@@ -1,49 +1,56 @@
<!DOCTYPE html>
@* File: `OmegaLeo.HelperLib.Web/Views/Shared/_Layout.cshtml` *@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>@ViewData["Title"] - OmegaLeo.HelperLib.Web</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css"/>
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true"/>
<link rel="stylesheet" href="~/OmegaLeo.HelperLib.Web.styles.css" asp-append-version="true"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - OmegaLeo Helper Libraries</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<header>
<nav class="navbar navbar-expand-sm navbar-dark bg-dark border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">OmegaLeo.HelperLib.Web</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">
OmegaLeo Helper Libraries
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Library" asp-route-id="core">Core</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Library" asp-route-id="changelog">Changelog</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Library" asp-route-id="game">Game Dev</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
</header>
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2025 - OmegaLeo.HelperLib.Web - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; @DateTime.Now.Year - OmegaLeo Helper Libraries
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
+1
View File
@@ -1,5 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbf9021a960b74107a7e141aa06bc9d8a0a53c929178c2fb95b1597be8af8dc_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMonitor_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F9ee76fb4aded5e9da6e66cc2dcb127fac08d3ec5ac84fc6db9d4ee1d2e38_003FMonitor_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASafeFileHandle_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc21672d0d37542808f219d7d1f059dc1b2e000_003Faf_003Fbed3a9b4_003FSafeFileHandle_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc61cc76f205b4535a5b4f40700c07900b2d200_003Fe5_003F6b3ec67e_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATreeChanges_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7478b0ce6362feb345e793626f5c504bd9d7ffeb748226521658c85fc4e29_003FTreeChanges_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>