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