Browse Source

Updated config and doc generation script to ignore invalid lines

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
c2c9edbeab
2 changed files with 21 additions and 8 deletions
  1. +9
    -0
      IPA.Loader/Config/SelfConfig.cs
  2. +12
    -8
      docs/build.ps1

+ 9
- 0
IPA.Loader/Config/SelfConfig.cs View File

@ -48,9 +48,11 @@ namespace IPA.Config
public class Updates_ public class Updates_
{ {
public bool AutoUpdate = true; public bool AutoUpdate = true;
// LINE: ignore
public static bool AutoUpdate_ => SelfConfigRef.Value.Updates.AutoUpdate; public static bool AutoUpdate_ => SelfConfigRef.Value.Updates.AutoUpdate;
public bool AutoCheckUpdates = true; public bool AutoCheckUpdates = true;
// LINE: ignore
public static bool AutoCheckUpdates_ => SelfConfigRef.Value.Updates.AutoCheckUpdates; public static bool AutoCheckUpdates_ => SelfConfigRef.Value.Updates.AutoCheckUpdates;
} }
@ -59,28 +61,35 @@ namespace IPA.Config
public class Debug_ public class Debug_
{ {
public bool ShowCallSource = false; public bool ShowCallSource = false;
// LINE: ignore
public static bool ShowCallSource_ => SelfConfigRef.Value.Debug.ShowCallSource; public static bool ShowCallSource_ => SelfConfigRef.Value.Debug.ShowCallSource;
public bool ShowDebug = false; public bool ShowDebug = false;
// LINE: ignore
public static bool ShowDebug_ => SelfConfigRef.Value.Debug.ShowDebug; public static bool ShowDebug_ => SelfConfigRef.Value.Debug.ShowDebug;
public bool ShowHandledErrorStackTraces = false; public bool ShowHandledErrorStackTraces = false;
// LINE: ignore
public static bool ShowHandledErrorStackTraces_ => SelfConfigRef.Value.Debug.ShowHandledErrorStackTraces; public static bool ShowHandledErrorStackTraces_ => SelfConfigRef.Value.Debug.ShowHandledErrorStackTraces;
public bool HideMessagesForPerformance = true; public bool HideMessagesForPerformance = true;
// LINE: ignore
public static bool HideMessagesForPerformance_ => SelfConfigRef.Value.Debug.HideMessagesForPerformance; public static bool HideMessagesForPerformance_ => SelfConfigRef.Value.Debug.HideMessagesForPerformance;
public int HideLogThreshold = 512; public int HideLogThreshold = 512;
// LINE: ignore
public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold; public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold;
} }
public Debug_ Debug = new Debug_(); public Debug_ Debug = new Debug_();
public bool YeetMods = true; public bool YeetMods = true;
// LINE: ignore
public static bool YeetMods_ => SelfConfigRef.Value.YeetMods; public static bool YeetMods_ => SelfConfigRef.Value.YeetMods;
[JsonProperty(Required = Required.Default)] [JsonProperty(Required = Required.Default)]
public string LastGameVersion = null; public string LastGameVersion = null;
// LINE: ignore
public static string LastGameVersion_ => SelfConfigRef.Value.LastGameVersion; public static string LastGameVersion_ => SelfConfigRef.Value.LastGameVersion;
} }
} }

+ 12
- 8
docs/build.ps1 View File

@ -1,11 +1,11 @@
# read SelfConfig, remove wierd bits, load it, load Newtonsoft, and turn it into a schema # 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" $selfConfigLoc = "../IPA.Loader/Config/SelfConfig.cs"
if (!(Test-Path "nuget" -PathType Container)) { 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 & docfx metadata
@ -18,23 +18,27 @@ if ((Test-Path $newtonsoftLoc -PathType Leaf) -and (Test-Path $selfConfigLoc -Pa
Add-Type -Path $newtonsoftSchemaLoc Add-Type -Path $newtonsoftSchemaLoc
# Read and parse special directives from SelfConfig # Read and parse special directives from SelfConfig
function Process-Lines {
function ProcessLines {
begin { begin {
$inIgnoreSection = $false $inIgnoreSection = $false
$ignoreNext = 0
} }
process { 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") $Begin = ($Matches[1] -eq "BEGIN")
$End = ($Matches[1] -eq "END") $End = ($Matches[1] -eq "END")
$Line = ($Matches[1] -eq "LINE")
switch ($Matches[2]) { switch ($Matches[2]) {
"ignore" { "ignore" {
if ($Begin) { $inIgnoreSection = $true } if ($Begin) { $inIgnoreSection = $true }
if ($End) { $inIgnoreSection = $false } if ($End) { $inIgnoreSection = $false }
if ($Line) { $ignoreNext = 2 }
} }
} }
} }
if ($inIgnoreSection) { "" } if ($inIgnoreSection) { "" }
elseif ($ignoreNext -gt 0) { $ignoreNext = $ignoreNext - 1; "" }
else { $_ } else { $_ }
} }
} }
@ -45,11 +49,11 @@ if ((Test-Path $newtonsoftLoc -PathType Leaf) -and (Test-Path $selfConfigLoc -Pa
end { $str } end { $str }
} }
function Filter-Def {
function FilterDef {
process { $_ -replace "internal", "public" } 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] # type will be [IPA.Config.SelfConfig]


Loading…
Cancel
Save