CommonMark.NET
This commit is contained in:
parent
6bda42fe67
commit
8db9514c83
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -13,7 +13,7 @@
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"D:/5-Other-Small/Kanban-messa010ec/Work-Items",
|
||||
"D:/5-Other-Small/Kanban-messa010ec/Kanban/Work-Items",
|
||||
"Day-Helper-2024-09-11",
|
||||
"*.json",
|
||||
".kanbn",
|
||||
|
@ -12,7 +12,7 @@ internal static partial class Helper20240911
|
||||
|
||||
public record Relation([property: JsonPropertyName("rel")] string Type,
|
||||
[property: JsonPropertyName("url")] string URL,
|
||||
[property: JsonPropertyName("attributes")] Attribute Attribute);
|
||||
[property: JsonPropertyName("attributes")] Attribute Attributes);
|
||||
|
||||
public record Record(WorkItem WorkItem, ReadOnlyDictionary<int, Record> Children);
|
||||
|
||||
@ -74,7 +74,7 @@ internal static partial class Helper20240911
|
||||
private static int? GetIdFromUrlIfChild(Relation relation)
|
||||
{
|
||||
int? result;
|
||||
string[] segments = relation.Attribute.Name != "Child" ? [] : relation.URL.Split('/');
|
||||
string[] segments = relation?.Attributes is null || relation.Attributes.Name != "Child" ? [] : relation.URL.Split('/');
|
||||
if (segments.Length < 2)
|
||||
result = null;
|
||||
else
|
||||
@ -134,19 +134,20 @@ internal static partial class Helper20240911
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string GetLine(List<char> spaces, WorkItem workItem, KeyValuePair<int, Record> keyValuePair, bool condensed) =>
|
||||
condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title}" :
|
||||
$"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} ~~~ {workItem.AssignedTo} - {workItem.IterationPath.Replace('\\', '-')} - {workItem.CreatedDate} --- {workItem.ClosedDate}";
|
||||
private static string GetLine(List<char> spaces, WorkItem workItem, KeyValuePair<int, Record> keyValuePair, bool condensed, bool sprintOnly) =>
|
||||
sprintOnly ? $"\t- [ ] {workItem.IterationPath}" :
|
||||
condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title}" :
|
||||
$"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} ~~~ {workItem.AssignedTo} - {workItem.IterationPath.Replace('\\', '-')} - {workItem.CreatedDate} --- {workItem.ClosedDate}";
|
||||
|
||||
private static void AppendLines(List<char> spaces, List<string> lines, Record record, bool condensed)
|
||||
private static void AppendLines(List<char> spaces, List<string> lines, Record record, bool condensed, bool sprintOnly)
|
||||
{
|
||||
spaces.Add('\t');
|
||||
WorkItem workItem;
|
||||
foreach (KeyValuePair<int, Record> keyValuePair in record.Children)
|
||||
{
|
||||
workItem = keyValuePair.Value.WorkItem;
|
||||
lines.Add(GetLine(spaces, workItem, keyValuePair, condensed));
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed);
|
||||
lines.Add(GetLine(spaces, workItem, keyValuePair, condensed, sprintOnly));
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed, sprintOnly);
|
||||
}
|
||||
spaces.RemoveAt(0);
|
||||
}
|
||||
@ -154,6 +155,7 @@ internal static partial class Helper20240911
|
||||
private static void AppendLines(List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||
{
|
||||
WorkItem workItem;
|
||||
List<string> distinct = [];
|
||||
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||
{
|
||||
workItem = keyValuePair.Value.WorkItem;
|
||||
@ -165,11 +167,20 @@ internal static partial class Helper20240911
|
||||
lines.Add(string.Empty);
|
||||
if (keyValuePair.Value.Children.Count > 0)
|
||||
{
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: true);
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: true, sprintOnly: false);
|
||||
lines.Add(string.Empty);
|
||||
distinct.Clear();
|
||||
lines.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
||||
distinct.Sort();
|
||||
lines.AddRange(distinct.Distinct());
|
||||
lines.Add(string.Empty);
|
||||
lines.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
||||
lines.Add(string.Empty);
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: false);
|
||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: false, sprintOnly: false);
|
||||
lines.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
@ -177,6 +188,10 @@ internal static partial class Helper20240911
|
||||
|
||||
internal static void WriteMarkdown(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
string old;
|
||||
string html;
|
||||
string text;
|
||||
string checkFile;
|
||||
List<char> spaces = [];
|
||||
string searchPattern = args[2];
|
||||
string filterDirectory = args[3];
|
||||
@ -200,7 +215,16 @@ internal static partial class Helper20240911
|
||||
foreach (string workItemType in workItemTypes)
|
||||
{
|
||||
AppendLines(spaces, lines, workItemAndChildren, workItemType);
|
||||
File.WriteAllText(Path.Combine(destinationDirectory, $"{workItemType}.md"), string.Join(Environment.NewLine, lines));
|
||||
checkFile = Path.Combine(destinationDirectory, $"{workItemType}.md");
|
||||
text = string.Join(Environment.NewLine, lines);
|
||||
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
||||
if (text != old)
|
||||
File.WriteAllText(checkFile, text);
|
||||
checkFile = Path.Combine(destinationDirectory, $"{workItemType}.html");
|
||||
html = CommonMark.CommonMarkConverter.Convert(text);
|
||||
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
||||
if (html != old)
|
||||
File.WriteAllText(checkFile, html);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
@ -13,6 +13,7 @@
|
||||
<RuntimeHostConfigurationOption Include="AssemblyName" Value="File-Folder-Helper" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
|
||||
<PackageReference Include="DiscUtils.Iso9660" Version="0.16.13" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user