Skip to content

Commit

Permalink
Release 3.3.9:
Browse files Browse the repository at this point in the history
- documentation parser removes links from source md file during extraction
- linefeeds during extraction are now os dependent (lf or cr/lf)
- version of generated knxprod file is printed in success message
  • Loading branch information
Waldemar Porscha committed Sep 6, 2024
1 parent f724b35 commit 726aacb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
6 changes: 3 additions & 3 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

[assembly: System.Reflection.AssemblyCompanyAttribute("OpenKNX")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("3.3.4.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("3.3.4")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("3.3.9.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("3.3.9")]
[assembly: System.Reflection.AssemblyProductAttribute("OpenKNXproducer")]
[assembly: System.Reflection.AssemblyTitleAttribute("OpenKNXproducer")]
[assembly: System.Reflection.AssemblyVersionAttribute("3.3.4.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("3.3.9.0")]
20 changes: 15 additions & 5 deletions ParseDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ParseDocumentation
static readonly Regex sRegexChapterId = new("[^a-zA-Z0-9-_ ÄäÖöÜüß\\n]");
static readonly Regex sRegexChapterWhitespaces = new("--*");
static readonly Regex sRegexChapterName = new("[#*]");
static readonly Regex sRegexLink = new(@"\[([^\]]*)\]\([^)]*\)");
static readonly Dictionary<string, string> sCharReplace = new() { { " ", "-" }, { "\n", "-" }, { "Ä", "Ae" }, { "ä", "ae" }, { "Ö", "Oe" }, { "ö", "oe" }, { "Ü", "Ue" }, { "ü", "ue" }, { "ß", "ss" } };
public static string GetChapterId(string iLine, string iPraefix)
{
Expand Down Expand Up @@ -46,8 +47,10 @@ private static int CountCharAtStart(string iLine, char iChar)
private static void WriteBaggage(string iPath, string iFileName, StringBuilder iBaggage)
{
// ensure right extension
string lBaggage = iBaggage.ToString();
lBaggage = sRegexLink.Replace(lBaggage, "$1");
iFileName = Path.ChangeExtension(iFileName, "md");
File.WriteAllText(Path.Combine(iPath, iFileName), iBaggage.ToString(), Encoding.UTF8);
File.WriteAllText(Path.Combine(iPath, iFileName), lBaggage, Encoding.UTF8);
}

public static int ExportBaggages(string iWorkingDir, string iBaggageDir, string iDocFileName, string iPraefix)
Expand Down Expand Up @@ -137,7 +140,9 @@ public static int ExportBaggages(string iWorkingDir, string iBaggageDir, string
{
// we have a new chapter, but the old is still active, we save the old one
lActiveDoc = 0;
Console.WriteLine("\n\n", lBaggageFileName);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(lBaggageFileName);
WriteBaggage(iBaggageDir, lBaggageFileName, lBaggage);
lBaggage.Clear();
}
Expand Down Expand Up @@ -169,11 +174,14 @@ public static int ExportBaggages(string iWorkingDir, string iBaggageDir, string
lActiveSkip = 1;
}
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("--> {0}.md\n", lBaggageFileName);
string lChapterNameFormatted = $"### {lChapterName}\n";
Console.WriteLine("--> {0}.md", lBaggageFileName);
Console.WriteLine();
string lChapterNameFormatted = $"### {lChapterName}";
lBaggage.AppendLine(lChapterNameFormatted);
lBaggage.AppendLine();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(lChapterNameFormatted);
Console.WriteLine();
Console.ResetColor();
}
else if (lActiveDoc > 0)
Expand All @@ -183,7 +191,9 @@ public static int ExportBaggages(string iWorkingDir, string iBaggageDir, string
{
// chapter is ended
lActiveDoc = 0;
Console.WriteLine("\n\n");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
WriteBaggage(iBaggageDir, lBaggageFileName, lBaggage);
lBaggage.Clear();
continue;
Expand Down
9 changes: 9 additions & 0 deletions ProcessInclude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,11 @@ bool ProcessFinish(XmlNode iTargetNode)
lValue = lValue.Replace("%SerialNumberEncoded%", lSerialNumberEncoded);
lValue = lValue.Replace("%VersionCheck%", lInlineData);
lValue = lValue.Replace("%VersionMessage%", lVersionMessage);
// TODO: solve this in a more generic way
lValue = lValue.Replace("%MaxKoNumber%", sMaxKoNumber.ToString());
lValue = lValue.Replace("-%MaxKoNumber%", (-sMaxKoNumber).ToString());
lValue = lValue.Replace("%MaxKoNumber-1%", (sMaxKoNumber - 1).ToString());
lValue = lValue.Replace("-%MaxKoNumber-1%", (-sMaxKoNumber + 1).ToString());
lNode.Value = lValue;
}
}
Expand Down Expand Up @@ -1843,7 +1847,12 @@ public void ResolveIncludes(string iCurrentDir)
{
ReplaceDocumentStrings(lInclude.mDocument, "%ModuleVersion%", string.Format("{0}.{1}", lDefine.VerifyVersion / 16, lDefine.VerifyVersion % 16));
if (lInclude.OriginalChannelCount > 0)
{
// TODO: Improve this in a more generic way
ReplaceDocumentStrings(lInclude.mDocument, "%N%", lInclude.OriginalChannelCount.ToString());
ReplaceDocumentStrings(lInclude.mDocument, "%N-1%", (lInclude.OriginalChannelCount - 1).ToString());
ReplaceDocumentStrings(lInclude.mDocument, "-%N-%", (-lInclude.OriginalChannelCount + 1).ToString());
}
}
// here we do template processing and repeat the template as many times as
// the Channels parameter in header file
Expand Down
5 changes: 4 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,10 @@ private static int ExportKnxprod(string iPathETS, string iWorkingDir, string iKn
System.IO.Directory.Delete(Path.Combine(localPath, "Temp"), true);

Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Output of {0} successful", iKnxprodFileName);
// derive version from appId
int lVersion = int.Parse(appId.Substring(14, 1), System.Globalization.NumberStyles.HexNumber);
int lRevision = int.Parse(appId.Substring(15, 1), System.Globalization.NumberStyles.HexNumber);
Console.WriteLine("Output of {0} (version {1}.{2}) successful", iKnxprodFileName, lVersion, lRevision);
Console.ResetColor();
return 0;
}
Expand Down

0 comments on commit 726aacb

Please sign in to comment.