Browse Source

Started on work to generate documentation for config file

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
5fdd21765c
10 changed files with 110 additions and 5 deletions
  1. +10
    -3
      IPA.Loader/Config/SelfConfig.cs
  2. +2
    -1
      docs/.gitignore
  3. +66
    -0
      docs/build.ps1
  4. +5
    -0
      docs/docfx.json
  5. +1
    -0
      docs/other_api/config/.gitignore
  6. +1
    -0
      docs/other_api/config/index.md
  7. +7
    -0
      docs/other_api/config/schema.md
  8. +5
    -0
      docs/other_api/index.md
  9. +9
    -0
      docs/other_api/toc.yml
  10. +4
    -1
      docs/toc.yml

+ 10
- 3
IPA.Loader/Config/SelfConfig.cs View File

@ -1,14 +1,16 @@
using IPA.JsonConverters;
// BEGIN: section ignore
using IPA.Logging;
using IPA.Utilities;
// END: section ignore
using Newtonsoft.Json;
using SemVer;
using System;
namespace IPA.Config
{
internal class SelfConfig
{
// This is to allow the doc generation to parse this file and use Newtonsoft to generate a JSON schema
// BEGIN: section ignore
private static IConfigProvider _loaderConfig;
public static IConfigProvider LoaderConfig
@ -39,6 +41,8 @@ namespace IPA.Config
internal const string IPAName = "Beat Saber IPA";
internal const string IPAVersion = "3.12.24";
// END: section ignore
public bool Regenerate = true;
public class UpdateObject
@ -47,6 +51,7 @@ namespace IPA.Config
public bool AutoCheckUpdates = true;
}
[JsonProperty(Required = Required.Always)]
public UpdateObject Updates = new UpdateObject();
public class DebugObject
@ -58,8 +63,10 @@ namespace IPA.Config
public int HideLogThreshold = 512;
}
[JsonProperty(Required = Required.Always)]
public DebugObject Debug = new DebugObject();
[JsonProperty(Required = Required.Default)]
public string LastGameVersion = null;
}
}

+ 2
- 1
docs/.gitignore View File

@ -3,4 +3,5 @@
/**/TEMP/
/**/packages/
/**/bin/
/obj
/obj
/nuget

+ 66
- 0
docs/build.ps1 View File

@ -0,0 +1,66 @@
& docfx metadata
# read SelfConfig, remove wierd bits, load it, load Newtonsoft, and turn it into a schema
$newtonsoftLoc = "nuget/Newtonsoft.Json.12.0.2/lib/netstandard2.0/Newtonsoft.Json.dll"
$newtonsoftSchemaLoc = "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 nuget
nuget install Newtonsoft.Json.Schema -Version 3.0.11 -source https://api.nuget.org/v3/index.json -o nuget
}
if ((Test-Path $newtonsoftLoc -PathType Leaf) -and (Test-Path $selfConfigLoc -PathType Leaf)) {
# The files we need exist, lets do this!
# First load Newtonsoft
Add-Type -Path $newtonsoftLoc
Add-Type -Path $newtonsoftSchemaLoc
# Read and parse special directives from SelfConfig
function Process-Lines {
begin {
$inIgnoreSection = $false
}
process {
if ( $_ -match "^\s*//\s+([A-Z]+):\s+section\s+(.+)\s*$" ) {
$Begin = ($Matches[1] -eq "BEGIN")
$End = ($Matches[1] -eq "END")
switch ($Matches[2]) {
"ignore" {
if ($Begin) { $inIgnoreSection = $true }
if ($End) { $inIgnoreSection = $false }
}
}
}
if ($inIgnoreSection) { "" }
else { $_ }
}
}
function Merge-Lines {
begin { $str = "" }
process { $str = $str + "`n" + $_ }
end { $str }
}
function Filter-Def {
process { $_ -replace "internal", "public" }
}
Add-Type -TypeDefinition (Get-Content $selfConfigLoc | Process-Lines | Merge-Lines | Filter-Def) -ReferencedAssemblies $newtonsoftLoc,"netstandard"
# type will be [IPA.Config.SelfConfig]
# Generate schema
$schemagen = New-Object -TypeName Newtonsoft.Json.Schema.Generation.JSchemaGenerator
$schema = $schemagen.Generate([IPA.Config.SelfConfig])
$schema.ToString() | Out-File "other_api/config/_schema.json"
}
& docfx build --globalMetadataFiles link_branch.json @Args
if ($lastexitcode -ne 0) {
throw [System.Exception] "docfx build failed with exit code $lastexitcode."
}

+ 5
- 0
docs/docfx.json View File

@ -6,8 +6,10 @@
"**.csproj"
],
"exclude": [
"**/BSIPA-Meta.csproj",
"**/IPA.csproj",
"**/IPA.Tests.csproj",
"TMP Exporter/**.csproj",
"BuildTools/**.csproj",
"Doorstop/**.csproj"
]
@ -27,6 +29,9 @@
"files": [
"articles/**.md",
"articles/**/toc.yml",
"other_api/**.md",
"other_api/**/toc.yml",
"other_api/**.yml",
"toc.yml",
"*.md"
]


+ 1
- 0
docs/other_api/config/.gitignore View File

@ -0,0 +1 @@
_schema.json

+ 1
- 0
docs/other_api/config/index.md View File

@ -0,0 +1 @@
# Title 2

+ 7
- 0
docs/other_api/config/schema.md View File

@ -0,0 +1,7 @@
---
uid: other.config.schema
---
# Configuration File Schema
[!code[Schema File](_schema.json)]

+ 5
- 0
docs/other_api/index.md View File

@ -0,0 +1,5 @@
---
uid: other.index
---
# Title1

+ 9
- 0
docs/other_api/toc.yml View File

@ -0,0 +1,9 @@
- name: Other APIs
href: index.md
- name: Configuration File
href: config/schema.md
items:
- name: Schema
href: config/schema.md
- name: Index
href: config/index.md

+ 4
- 1
docs/toc.yml View File

@ -1,6 +1,9 @@
- name: Articles
href: articles/
homepage: articles/index.md
- name: Api Documentation
- name: C# API Documentation
href: api/
homepage: api/index.md
- name: Other API Documentation
href: other_api/
homepage: other_api/index.md

Loading…
Cancel
Save