Skip to content

Commit 4a0729f

Browse files
Better docs (#48)
1 parent 4d747cf commit 4a0729f

13 files changed

Lines changed: 168 additions & 4 deletions

File tree

.github/workflows/docs.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Trigger the action on push to master
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
8+
permissions:
9+
actions: read
10+
pages: write
11+
id-token: write
12+
13+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
14+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
publish-docs:
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
- name: Dotnet Setup
29+
uses: actions/setup-dotnet@v3
30+
with:
31+
dotnet-version: 8.x
32+
33+
- run: dotnet tool update -g docfx
34+
- run: |
35+
cd OpenPolytopia.Common
36+
dotnet build
37+
cd ..
38+
docfx docs/docfx.json
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
# Upload entire repository
44+
path: 'docs/_site'
45+
- name: Deploy to GitHub Pages
46+
id: deployment
47+
uses: actions/deploy-pages@v4

OpenPolytopia.Common/City.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ namespace OpenPolytopia.Common;
55
using System.Runtime.CompilerServices;
66
using Godot;
77

8+
/// <summary>
9+
/// Layer of abstraction to manage all cities in a grid
10+
/// </summary>
811
public class CityManager(Grid grid) {
912
private readonly List<uint> _cities = [];
1013

@@ -28,13 +31,25 @@ public CityData this[uint id] {
2831
/// </summary>
2932
/// <param name="id">the id of the city</param>
3033
/// <returns>the id of the tile in the grid</returns>
34+
/// <example>
35+
/// <code>
36+
/// var index = cityManager.GetIndex(cityId);
37+
/// grid[index].Owner = 2;
38+
/// </code>
39+
/// </example>
3140
public uint GetIndex(uint id) => _cities[(int)(id - 1)];
3241

3342
/// <summary>
3443
/// Registers a tile as a city
3544
/// </summary>
3645
/// <param name="position">position of the tile in the grid</param>
3746
/// <returns>the id of the city</returns>
47+
/// <example>
48+
/// <code>
49+
/// var position = new Vector2I(0, 5);
50+
/// var cityId = cityManager.RegisterCity(position);
51+
/// </code>
52+
/// </example>
3853
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3954
public uint RegisterCity(Vector2I position) => RegisterCity(grid.GridPositionToIndex(position));
4055

@@ -44,6 +59,13 @@ public CityData this[uint id] {
4459
/// <param name="index">index of the tile in the grid</param>
4560
/// <returns>the id of the city</returns>
4661
/// <exception cref="ArgumentOutOfRangeException">because of internal implementation, there can only be 255 cities</exception>
62+
/// <example>
63+
/// <code>
64+
/// var position = new Vector2I(0, 5);
65+
/// var index = grid.GridPositionToIndex(position);
66+
/// var cityId = cityManager.RegisterCity(index);
67+
/// </code>
68+
/// </example>
4769
public uint RegisterCity(uint index) {
4870
if (_cities.Count == 255) {
4971
throw new ArgumentOutOfRangeException(nameof(index), index, "reached maximum cities possible; max is 255");

OpenPolytopia.Common/OpenPolytopia.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
78
</PropertyGroup>
89

910
<ItemGroup>

OpenPolytopia.Common/Tribe.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ public class TribeManager {
2323
/// </summary>
2424
/// <param name="type">the type of the tribe</param>
2525
/// <param name="tribe">the data of the tribe</param>
26+
/// <example>
27+
/// <code>
28+
/// var imperiusTribe = new Tribe {
29+
/// // settings for this tribe
30+
/// };
31+
/// var tribeManager = new TribeManager();
32+
/// tribeManager.RegisterTribe(TribeType.Imperius, imperiusTribe);
33+
/// </code>
34+
/// </example>
2635
public void RegisterTribe(TribeType type, Tribe tribe) => Tribes.Add(type, tribe);
2736

2837
/// <summary>
@@ -36,9 +45,23 @@ public void RegisterTribes(TribesSerializedData tribes) {
3645
}
3746
}
3847

48+
/// <summary>
49+
/// Class representing all data a tribe has
50+
/// </summary>
3951
public class Tribe {
52+
/// <summary>
53+
/// The starting tech of a tribe
54+
/// </summary>
4055
public required StartingTech StartingTech { get; init; }
56+
57+
/// <summary>
58+
/// The resource spawn rates of a tribe
59+
/// </summary>
4160
public required SpawnRate SpawnRate { get; init; }
61+
62+
/// <summary>
63+
/// The terrain generation rates of a tribe
64+
/// </summary>
4265
public required TerrainRate TerrainRate { get; init; }
4366
}
4467

OpenPolytopia/OpenPolytopia.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
<Title>OpenPolytopia</Title>
2020
<Version>0.1.0</Version>
2121
<Description>OpenPolytopia</Description>
22-
<Copyright>© 2024 Enn3DevPlayer, GamerPlayer888, Remoxx</Copyright>
23-
<Authors>Enn3DevPlayer, GamerPlayer888, Remoxx</Authors>
24-
<Company>Enn3DevPlayer, GamerPlayer888, Remoxx</Company>
22+
<Copyright>© 2024 Enn3DevPlayer, GamerPlayer888, Remoxx, C0MPL3XDEV</Copyright>
23+
<Authors>Enn3DevPlayer, GamerPlayer888, Remoxx, C0MPL3XDEV</Authors>
24+
<Company>Enn3DevPlayer, GamerPlayer888, Remoxx, C0MPL3XDEV</Company>
2525
<!-- Don't include unit tests in release builds. -->
2626
<DefaultItemExcludes Condition="'$(Configuration)' == 'ExportRelease'">
2727
$(DefaultItemExcludes);test/**/*
2828
</DefaultItemExcludes>
2929
<TargetFramework>net8.0</TargetFramework>
30+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3031
</PropertyGroup>
3132
<ItemGroup Condition=" '$(Configuration)' == 'Debug' or '$(Configuration)' == 'ExportDebug' ">
3233
<!-- Test dependencies go here! -->
@@ -60,4 +61,4 @@
6061
<ProjectReference Include="..\FSharpLibrary\FSharpLibrary.fsproj"/>
6162
<ProjectReference Include="..\OpenPolytopia.Common\OpenPolytopia.Common.csproj"/>
6263
</ItemGroup>
63-
</Project>
64+
</Project>

StdbModule/StdbModule.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Nullable>enable</Nullable>
88
<RootNamespace>OpenPolytopia.Server</RootNamespace>
99
<OutputType>Exe</OutputType>
10+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_site/
2+
api/

docs/docfx.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/dotnet/docfx/main/schemas/docfx.schema.json",
3+
"metadata": [
4+
{
5+
"src": [
6+
{
7+
"src": "../.",
8+
"files": [
9+
"**/OpenPolytopia.Common/bin/Debug/**.dll"
10+
]
11+
}
12+
],
13+
"dest": "api"
14+
}
15+
],
16+
"build": {
17+
"content": [
18+
{
19+
"files": [
20+
"**/*.{md,yml}"
21+
],
22+
"exclude": [
23+
"_site/**"
24+
]
25+
}
26+
],
27+
"resource": [
28+
{
29+
"files": [
30+
"images/**"
31+
]
32+
}
33+
],
34+
"output": "_site",
35+
"template": [
36+
"default",
37+
"modern"
38+
],
39+
"globalMetadata": {
40+
"_appName": "OpenPolytopia",
41+
"_appTitle": "OpenPolytopia",
42+
"_enableSearch": true,
43+
"pdf": false
44+
}
45+
}
46+
}

docs/docs/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Getting Started

docs/docs/introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Introduction

0 commit comments

Comments
 (0)