EC Documentation
This commit is contained in:
parent
3888ae1083
commit
ec3afd2f96
BIN
.kanbn/board.md
Normal file
BIN
.kanbn/board.md
Normal file
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
using Humanizer;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
@ -114,9 +115,11 @@ internal static class HelperCreateNoteFiles
|
||||
string? directory;
|
||||
string[] segments;
|
||||
int descriptionKey = 2;
|
||||
string[]? headerColumns;
|
||||
string destinationDirectory;
|
||||
DateTime dateTime = new(ticks);
|
||||
StringBuilder stringBuilder = new();
|
||||
StringBuilder attributes = new();
|
||||
StringBuilder keyValuePairLinks = new();
|
||||
string csvHeader = "type,title,description,links,body";
|
||||
string tsvHeader = "type\ttitle\tdescription\tlinks\tbody";
|
||||
int expectedCount = csvHeader.Length - csvHeader.Replace(",", string.Empty).Length + 1;
|
||||
@ -124,6 +127,7 @@ internal static class HelperCreateNoteFiles
|
||||
{
|
||||
csv = false;
|
||||
tsv = false;
|
||||
headerColumns = null;
|
||||
directory = Path.GetDirectoryName(importFile);
|
||||
if (directory is null)
|
||||
continue;
|
||||
@ -132,10 +136,16 @@ internal static class HelperCreateNoteFiles
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (lines[i] == csvHeader)
|
||||
if (lines[i].StartsWith(csvHeader))
|
||||
{
|
||||
(csv, tsv) = (true, false);
|
||||
else if (lines[i] == tsvHeader)
|
||||
headerColumns = lines[i].Split(',');
|
||||
}
|
||||
else if (lines[i].StartsWith(tsvHeader))
|
||||
{
|
||||
(csv, tsv) = (false, true);
|
||||
headerColumns = lines[i].Split('\t');
|
||||
}
|
||||
else
|
||||
break;
|
||||
continue;
|
||||
@ -146,9 +156,10 @@ internal static class HelperCreateNoteFiles
|
||||
columns = lines[i].Split('\t');
|
||||
else
|
||||
continue;
|
||||
if (columns.Length != expectedCount)
|
||||
if (columns.Length < expectedCount)
|
||||
continue;
|
||||
_ = stringBuilder.Clear();
|
||||
_ = attributes.Clear();
|
||||
_ = keyValuePairLinks.Clear();
|
||||
title = columns[titleKey].Trim();
|
||||
linkText = columns[linksKey].Trim();
|
||||
type = columns[typeKey].Trim().ToLower().Replace(' ', '-');
|
||||
@ -156,13 +167,22 @@ internal static class HelperCreateNoteFiles
|
||||
links = Array.Empty<string>();
|
||||
else
|
||||
links = linkText.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (headerColumns is not null && columns.Length > expectedCount)
|
||||
{
|
||||
for (int j = expectedCount; j < columns.Length; j++)
|
||||
{
|
||||
if (headerColumns.Length <= j)
|
||||
continue;
|
||||
_ = attributes.AppendLine($"{headerColumns[j].Trim().Camelize()}: '{columns[j].Trim()}'");
|
||||
}
|
||||
}
|
||||
foreach (string link in links)
|
||||
{
|
||||
segments = link.Split(':');
|
||||
if (segments.Length == 1)
|
||||
_ = stringBuilder.AppendLine($"- [[{segments.First()}]]");
|
||||
_ = keyValuePairLinks.AppendLine($"- [[{segments.First()}]]");
|
||||
else if (segments.Length == 2)
|
||||
_ = stringBuilder.AppendLine($"- [{segments.First()}]({segments.Last()})");
|
||||
_ = keyValuePairLinks.AppendLine($"- [{segments.First()}]({segments.Last()})");
|
||||
else
|
||||
continue;
|
||||
}
|
||||
@ -178,11 +198,14 @@ internal static class HelperCreateNoteFiles
|
||||
$"description: '{columns[descriptionKey].Trim()}'",
|
||||
$"created: {dateTime:yyyy-MM-ddTHH:mm:ss.fffZ}",
|
||||
$"updated: {dateTime:yyyy-MM-ddTHH:mm:ss.fffZ}",
|
||||
attributes.ToString(),
|
||||
"---",
|
||||
string.Empty,
|
||||
$"# {title}",
|
||||
string.Empty,
|
||||
stringBuilder.ToString(),
|
||||
keyValuePairLinks.ToString(),
|
||||
string.Empty,
|
||||
$"## Comment {dateTime:yyyy-MM-dd}",
|
||||
string.Empty,
|
||||
columns[bodyKey].Trim(),
|
||||
string.Empty,
|
||||
@ -194,8 +217,8 @@ internal static class HelperCreateNoteFiles
|
||||
internal static void CreateNoteFiles(string argsZero)
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
CleanExistingFiles(argsZero, ticks);
|
||||
List<string> importFiles = new();
|
||||
CleanExistingFiles(argsZero, ticks);
|
||||
importFiles.AddRange(Directory.GetFiles(argsZero, "*.csv", SearchOption.TopDirectoryOnly));
|
||||
importFiles.AddRange(Directory.GetFiles(argsZero, "*.tsv", SearchOption.TopDirectoryOnly));
|
||||
if (!importFiles.Any())
|
||||
|
@ -153,8 +153,6 @@ internal static partial class HelperMarkdown
|
||||
List<string> results = new();
|
||||
foreach ((MarkdownFile markdownFile, string[] lines) in collection)
|
||||
{
|
||||
if (markdownFile.FileName == "board.md")
|
||||
continue;
|
||||
if (!lines.Any())
|
||||
continue;
|
||||
results.Clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user