Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tst/docs assembly xml #30

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/EAVFW.Extensions.Docs.Generator/ReadMeDocumentationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ public async Task Write(FileInfo outputLocation, string component)
await writer.WriteLineAsync("## Table of contents");

var index = 2;
await writer.WriteLineAsync("1. [Class diagram](#class-diagram)");
await writer.WriteLineAsync("1. [Class diagram](#Class-diagram)");
foreach (var (key, value) in entitiesToWrite)
{
await writer.WriteLineAsync($"{index++}. [{key}](#{_schemaNameManager.ToSchemaName(key)})");
await writer.WriteLineAsync($"{index++}. [{key}](#{key.Replace(' ', '-')})");
}

await writer.WriteLineAsync("# Class diagram <a name=\"class-diagram\"></a>");
await writer.WriteLineAsync("# Class diagram");
await writer.WriteAsync(EntitiesToClassDiagram(_manifestObject, component));

var ignored = new List<string>
{ "Modified On", "Modified By", "Created By", "Created On", "Row Version", "Owner" };

foreach (var (key, value) in entitiesToWrite)
{
await writer.WriteLineAsync($"## {key} <a name=\"{_schemaNameManager.ToSchemaName(key)}\"></a>");
await writer.WriteLineAsync($"## {key}");

await writer.WriteLineAsync(value.Description);

Expand Down Expand Up @@ -276,15 +276,20 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon
{
var diagramBuilder = new StringBuilder();

diagramBuilder.AppendLine("```mermaid");
diagramBuilder.AppendLine("::: mermaid");
diagramBuilder.AppendLine("classDiagram");
diagramBuilder.AppendLine($"\tnote \"Class diagram for {component}\"");

var t = new DefaultSchemaNameManager();

var entities = manifest.Entities.Where(entity =>
entity.Value.AdditionalFields.ContainsKey("moduleSource") &&
entity.Value.AdditionalFields["moduleSource"].ToString() == component);
var entities = manifest.Entities;
if (!string.IsNullOrWhiteSpace(component))
{
entities = manifest.Entities.Where(entity =>
entity.Value.AdditionalFields.ContainsKey("moduleSource") &&
entity.Value.AdditionalFields["moduleSource"].ToString() == component)
.ToDictionary(x => x.Key, x => x.Value);
}

var ignored = new List<string>
{ "Modified On", "Modified By", "Created By", "Created On", "Row Version", "Owner" };
Expand All @@ -293,7 +298,7 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon
{
var attributes = value.Attributes.Where(x => !ignored.Contains(x.Key)).ToList();

diagramBuilder.AppendLine($"\tclass {t.ToSchemaName(key)}[\"{key}\"]{{");
diagramBuilder.AppendLine($"\tclass {t.ToSchemaName(key)}{{");
foreach (var (s, attributeDefinitionBase) in attributes)
{
if (attributeDefinitionBase is AttributeObjectDefinition o)
Expand Down Expand Up @@ -327,7 +332,7 @@ private string EntitiesToClassDiagram(ManifestDefinition manifest, string compon
}
}

diagramBuilder.AppendLine("```");
diagramBuilder.AppendLine(":::");
return diagramBuilder.ToString();
}
}
Expand Down
Loading