From 29061ef22de87beb217c6219df248653f1bc1635 Mon Sep 17 00:00:00 2001 From: Wannes Gennar Date: Thu, 14 Nov 2024 22:58:41 +0100 Subject: [PATCH] fix .NET 9 breakages - fixes docs no longer building - fixes SuperHeadersProcessor being included in Release builds - removed obsolete code --- .github/workflows/pages.yml | 22 ++----- .gitignore | 5 +- Helldivers-2.sln | 1 - docfx.json | 46 ------------- docs/.nojekyll | 0 docs/_coverpage.md | 12 ++++ docs/_navbar.md | 4 ++ docs/getting-started.md | 1 - docs/index.html | 27 ++++++++ docs/introduction.md | 1 - docs/toc.yml | 12 ---- .../SuperHeadersProcessor.cs | 2 + src/Helldivers-2-API/Program.cs | 3 +- .../StaticJsonSourceGenerator.cs | 64 ------------------- 14 files changed, 55 insertions(+), 145 deletions(-) delete mode 100644 docfx.json create mode 100644 docs/.nojekyll create mode 100644 docs/_coverpage.md create mode 100644 docs/_navbar.md delete mode 100644 docs/getting-started.md create mode 100644 docs/index.html delete mode 100644 docs/introduction.md delete mode 100644 docs/toc.yml diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 4040e2a..cbcc9e4 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -26,25 +26,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 9.0.x - - name: Install DocFX - run: dotnet tool install -g docfx - name: Initial static JSON schema submodule run: git submodule update --init ./src/Helldivers-2-Models/json - name: Generate OpenAPI JSON files run: dotnet build -c Debug - - name: Generate DocFX metadata - run: docfx metadata - - name: Generate DocFX site - run: docfx build docfx.json - - name: Upload DocFX website + - name: Copy README + run: cp README.md docs/README.md + - name: Upload docsify website uses: actions/upload-artifact@master with: - name: 'docfx' - path: './_site/' + name: 'docs' + path: './docs/' deploy: needs: build environment: @@ -52,10 +44,10 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - name: Download DocFX website + - name: Download docsify website uses: actions/download-artifact@master with: - name: 'docfx' + name: 'docs' path: '.' - name: Setup Pages uses: actions/configure-pages@v4 diff --git a/.gitignore b/.gitignore index 304e171..4a2a20a 100644 --- a/.gitignore +++ b/.gitignore @@ -365,9 +365,8 @@ FodyWeavers.xsd # Jetbrains generated folders .idea/ -# DocFX generates files -_site/ -api/ +# docsify files +docs/README.md # Ignore OpenAPI documents docs/openapi/*.json diff --git a/Helldivers-2.sln b/Helldivers-2.sln index 4a83c4b..fad0807 100644 --- a/Helldivers-2.sln +++ b/Helldivers-2.sln @@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props fly.toml = fly.toml .dockerignore = .dockerignore - docfx.json = docfx.json EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Helldivers-2-Models", "src\Helldivers-2-Models\Helldivers-2-Models.csproj", "{9B017849-C756-4B98-9B98-885AEBE9EAD4}" diff --git a/docfx.json b/docfx.json deleted file mode 100644 index 93c74b2..0000000 --- a/docfx.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "metadata": [ - { - "src": [ - { - "files": [ - "**/*.csproj" - ] - } - ], - "dest": "api" - } - ], - "build": { - "content": [ - { - "files": [ - "**/*.{md,yml}" - ], - "exclude": [ - "_site/**", - "src/Helldivers-2-Models/json/**" - ] - } - ], - "resource": [ - { - "files": [ - "images/**", - "docs/openapi/**" - ] - } - ], - "output": "_site", - "template": [ - "default", - "modern" - ], - "globalMetadata": { - "_appName": "Helldivers-2 API", - "_appTitle": "Helldivers-2 API", - "_enableSearch": true, - "pdf": false - } - } -} diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/_coverpage.md b/docs/_coverpage.md new file mode 100644 index 0000000..c81e5d1 --- /dev/null +++ b/docs/_coverpage.md @@ -0,0 +1,12 @@ +![logo](https://avatars.githubusercontent.com/u/164774207?s=200&v=4) + +# Helldivers 2API + +> A community driven API wrapper for Helldivers 2 + +- Provides fast & cached access to the official Helldivers 2 API +- Convenience abstractions for modern API design +- You can self host! + +[GitHub](https://github.com/helldivers-2/api) +[Get Started](README.md) \ No newline at end of file diff --git a/docs/_navbar.md b/docs/_navbar.md new file mode 100644 index 0000000..4864738 --- /dev/null +++ b/docs/_navbar.md @@ -0,0 +1,4 @@ +* [Self host](containers.md) +* OpenAPI + * [Redoc](openapi/redoc.html ':ignore') + * [Swagger UI](openapi/swagger-ui.html ':ignore') diff --git a/docs/getting-started.md b/docs/getting-started.md deleted file mode 100644 index 8b3a794..0000000 --- a/docs/getting-started.md +++ /dev/null @@ -1 +0,0 @@ -# Getting Started \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..8d6dd0a --- /dev/null +++ b/docs/index.html @@ -0,0 +1,27 @@ + + + + + Helldivers 2 API + + + + + + +
+ + + + + + diff --git a/docs/introduction.md b/docs/introduction.md deleted file mode 100644 index f6ecaa6..0000000 --- a/docs/introduction.md +++ /dev/null @@ -1 +0,0 @@ -# Introduction \ No newline at end of file diff --git a/docs/toc.yml b/docs/toc.yml deleted file mode 100644 index c445d14..0000000 --- a/docs/toc.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: Introduction - href: introduction.md -- name: Getting Started - href: getting-started.md -- name: Containers - href: containers.md -- name: Contributing - href: ../contributing.md -- name: Code of conduct - href: ../CODE_OF_CONDUCT.md -- name: Reporting vulnerabilities - href: ../SECURITY.md diff --git a/src/Helldivers-2-API/OpenApi/OperationProcessors/SuperHeadersProcessor.cs b/src/Helldivers-2-API/OpenApi/OperationProcessors/SuperHeadersProcessor.cs index 7216622..ff014fa 100644 --- a/src/Helldivers-2-API/OpenApi/OperationProcessors/SuperHeadersProcessor.cs +++ b/src/Helldivers-2-API/OpenApi/OperationProcessors/SuperHeadersProcessor.cs @@ -1,3 +1,4 @@ +#if DEBUG using NSwag; using NSwag.Generation.Processors; using NSwag.Generation.Processors.Contexts; @@ -40,3 +41,4 @@ public bool Process(OperationProcessorContext context) return true; } } +#endif diff --git a/src/Helldivers-2-API/Program.cs b/src/Helldivers-2-API/Program.cs index c90ed9e..eaf896a 100644 --- a/src/Helldivers-2-API/Program.cs +++ b/src/Helldivers-2-API/Program.cs @@ -4,7 +4,6 @@ using Helldivers.API.Controllers.V1; using Helldivers.API.Metrics; using Helldivers.API.Middlewares; -using Helldivers.API.OpenApi.OperationProcessors; using Helldivers.Core.Extensions; using Helldivers.Models; using Helldivers.Models.Domain.Localization; @@ -163,7 +162,7 @@ new Helldivers.API.OpenApi.TypeMappers.LocalizedMessageTypeMapper(languages) ); - document.OperationProcessors.Add(new SuperHeadersProcessor()); + document.OperationProcessors.Add(new Helldivers.API.OpenApi.OperationProcessors.SuperHeadersProcessor()); document.DocumentProcessors.Add(new Helldivers.API.OpenApi.DocumentProcessors.HelldiversDocumentProcessor()); }); diff --git a/src/Helldivers-2-SourceGen/StaticJsonSourceGenerator.cs b/src/Helldivers-2-SourceGen/StaticJsonSourceGenerator.cs index da5d73d..8781a8a 100644 --- a/src/Helldivers-2-SourceGen/StaticJsonSourceGenerator.cs +++ b/src/Helldivers-2-SourceGen/StaticJsonSourceGenerator.cs @@ -73,68 +73,4 @@ private static IJsonParser GetParserForFile(AdditionalText file) _ => throw new Exception($"Generator does not know how to parse {name}") }; } - - - -#if false - /// - public void Execute(GeneratorExecutionContext context) - { - foreach (var file in context.AdditionalFiles) - { - if (file is null) - continue; - - var name = Path.GetFileNameWithoutExtension(file.Path); - name = $"{char.ToUpper(name[0])}{name.Substring(1)}"; - - try - { - var json = file.GetText(context.CancellationToken)?.ToString() ?? throw new InvalidOperationException($"Cannot generate C# from missing JSON file {file.Path}"); - - var (type, value) = name.ToLowerInvariant() switch - { - "planets" => ParsePlanetsDictionary(json), - "biomes" => ParseBiomesDictionary(json), - "environmentals" => ParseEnvironmentalsDictionary(json), - "factions" => ParseFactionsDictionary(json), - _ => throw new Exception($"Generator does not know how to parse {name}") - }; - - var source = $@"// -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member -using global::System.Collections.Generic; -using global::Helldivers.Models.Domain.Localization; - -namespace Helldivers.Models; - -public static partial class Static -{{ - /// Public list of {name} entries from {Path.GetFileName(file.Path)} - public static {type} {name} = {value}; -}} -"; - - context.AddSource($"{name}.g.cs", source); - } - catch (Exception exception) - { - context.AddSource($"{name}.g.cs", $"// An exception was thrown processing {name}.json\n{exception.ToString()}"); - context.ReportDiagnostic( - Diagnostic.Create( - new DiagnosticDescriptor( - id: "HDJSON", // Unique ID for your error - title: "JSON source generator failed", // Title of the error - messageFormat: $"An error occured generating C# code from JSON files: {exception}", // Message format - category: "HD2", // Category of the error - DiagnosticSeverity.Error, // Severity of the error - isEnabledByDefault: true // Whether the error is enabled by default - ), - Location.None // No specific location provided for simplicity - ) - ); - } - } - } -#endif }