From c2c9edbeab8acb536bc1bf181e223e2a23c324c7 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Fri, 16 Aug 2019 16:12:13 -0500 Subject: [PATCH] Updated config and doc generation script to ignore invalid lines --- IPA.Loader/Config/SelfConfig.cs | 9 +++++++++ docs/build.ps1 | 20 ++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/IPA.Loader/Config/SelfConfig.cs b/IPA.Loader/Config/SelfConfig.cs index 90e0b5e7..758f8339 100644 --- a/IPA.Loader/Config/SelfConfig.cs +++ b/IPA.Loader/Config/SelfConfig.cs @@ -48,9 +48,11 @@ namespace IPA.Config public class Updates_ { public bool AutoUpdate = true; + // LINE: ignore public static bool AutoUpdate_ => SelfConfigRef.Value.Updates.AutoUpdate; public bool AutoCheckUpdates = true; + // LINE: ignore public static bool AutoCheckUpdates_ => SelfConfigRef.Value.Updates.AutoCheckUpdates; } @@ -59,28 +61,35 @@ namespace IPA.Config public class Debug_ { public bool ShowCallSource = false; + // LINE: ignore public static bool ShowCallSource_ => SelfConfigRef.Value.Debug.ShowCallSource; public bool ShowDebug = false; + // LINE: ignore public static bool ShowDebug_ => SelfConfigRef.Value.Debug.ShowDebug; public bool ShowHandledErrorStackTraces = false; + // LINE: ignore public static bool ShowHandledErrorStackTraces_ => SelfConfigRef.Value.Debug.ShowHandledErrorStackTraces; public bool HideMessagesForPerformance = true; + // LINE: ignore public static bool HideMessagesForPerformance_ => SelfConfigRef.Value.Debug.HideMessagesForPerformance; public int HideLogThreshold = 512; + // LINE: ignore public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold; } public Debug_ Debug = new Debug_(); public bool YeetMods = true; + // LINE: ignore public static bool YeetMods_ => SelfConfigRef.Value.YeetMods; [JsonProperty(Required = Required.Default)] public string LastGameVersion = null; + // LINE: ignore public static string LastGameVersion_ => SelfConfigRef.Value.LastGameVersion; } } \ No newline at end of file diff --git a/docs/build.ps1 b/docs/build.ps1 index 5a87c729..ad57f815 100644 --- a/docs/build.ps1 +++ b/docs/build.ps1 @@ -1,11 +1,11 @@ # read SelfConfig, remove wierd bits, load it, load Newtonsoft, and turn it into a schema -$newtonsoftLoc = "$(pwd)/nuget/Newtonsoft.Json.12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll" -$newtonsoftSchemaLoc = "$(pwd)/nuget/Newtonsoft.Json.Schema.3.0.11/lib/netstandard2.0/Newtonsoft.Json.Schema.dll" +$newtonsoftLoc = "$(Get-Location)/nuget/Newtonsoft.Json.12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll" +$newtonsoftSchemaLoc = "$(Get-Location)/nuget/Newtonsoft.Json.Schema.3.0.11/lib/netstandard2.0/Newtonsoft.Json.Schema.dll" $selfConfigLoc = "../IPA.Loader/Config/SelfConfig.cs" if (!(Test-Path "nuget" -PathType Container)) { - nuget install Newtonsoft.Json -Version 12.0.2 -source https://api.nuget.org/v3/index.json -o "$(pwd)/nuget" - nuget install Newtonsoft.Json.Schema -Version 3.0.11 -source https://api.nuget.org/v3/index.json -o "$(pwd)/nuget" + nuget install Newtonsoft.Json -Version 12.0.2 -source https://api.nuget.org/v3/index.json -o "$(Get-Location)/nuget" + nuget install Newtonsoft.Json.Schema -Version 3.0.11 -source https://api.nuget.org/v3/index.json -o "$(Get-Location)/nuget" } & docfx metadata @@ -18,23 +18,27 @@ if ((Test-Path $newtonsoftLoc -PathType Leaf) -and (Test-Path $selfConfigLoc -Pa Add-Type -Path $newtonsoftSchemaLoc # Read and parse special directives from SelfConfig - function Process-Lines { + function ProcessLines { begin { $inIgnoreSection = $false + $ignoreNext = 0 } process { - if ( $_ -match "^\s*//\s+([A-Z]+):\s+section\s+(.+)\s*$" ) { + if ( $_ -match "^\s*//\s+([A-Z]+):\s*(?:section)?\s+(.+)\s*$" ) { $Begin = ($Matches[1] -eq "BEGIN") $End = ($Matches[1] -eq "END") + $Line = ($Matches[1] -eq "LINE") switch ($Matches[2]) { "ignore" { if ($Begin) { $inIgnoreSection = $true } if ($End) { $inIgnoreSection = $false } + if ($Line) { $ignoreNext = 2 } } } } if ($inIgnoreSection) { "" } + elseif ($ignoreNext -gt 0) { $ignoreNext = $ignoreNext - 1; "" } else { $_ } } } @@ -45,11 +49,11 @@ if ((Test-Path $newtonsoftLoc -PathType Leaf) -and (Test-Path $selfConfigLoc -Pa end { $str } } - function Filter-Def { + function FilterDef { process { $_ -replace "internal", "public" } } - Add-Type -TypeDefinition (Get-Content $selfConfigLoc | Process-Lines | Merge-Lines | Filter-Def) -ReferencedAssemblies $newtonsoftLoc,"netstandard" + Add-Type -TypeDefinition (Get-Content $selfConfigLoc | ProcessLines | Merge-Lines | FilterDef) -ReferencedAssemblies $newtonsoftLoc,"netstandard" # type will be [IPA.Config.SelfConfig]