Skip to content

Commit 158365c

Browse files
committed
Added documentation workflow
1 parent 36311aa commit 158365c

63 files changed

Lines changed: 1249 additions & 94 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
- Add or update **Unity Test Framework** tests in `Tests/` for behavior changes.
2121
- Prefer golden-value tests for deterministic APIs (hashing, noise); tolerance tests for fast math approximations.
2222
- Run **Window → General → Test Runner → Edit Mode** before opening a PR.
23-
- See [docs/QUALITY.md](../docs/QUALITY.md) for local test setup and IL2CPP validation checklist.
23+
- See [Quality & testing](https://ltmx.github.io/Unity.mathx/QUALITY/) for local test setup and IL2CPP validation checklist.

.github/workflows/docs.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: '8.0.x'
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
cache: pip
33+
cache-dependency-path: requirements-docs.txt
34+
35+
- name: Install DocFX
36+
run: dotnet tool install -g docfx
37+
38+
- name: Build API reference
39+
run: |
40+
cd Documentation
41+
dotnet build Mathx.Docs.csproj
42+
docfx metadata docfx.json
43+
docfx build docfx.json
44+
45+
- name: Stage API into docs tree
46+
run: |
47+
rm -rf docs/api
48+
mkdir -p docs/api
49+
cp -r Documentation/api/_site/* docs/api/
50+
cp docs/api-stub/index.html docs/api/index.html
51+
52+
- name: Install MkDocs
53+
run: pip install -r requirements-docs.txt
54+
55+
- name: Build site
56+
run: mkdocs build
57+
58+
- name: Upload Pages artifact
59+
uses: actions/upload-pages-artifact@v3
60+
with:
61+
path: site
62+
63+
deploy:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
environment:
67+
name: github-pages
68+
url: ${{ steps.deployment.outputs.page_url }}
69+
steps:
70+
- name: Deploy to GitHub Pages
71+
id: deployment
72+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
*.csproj
2-
*.csproj.meta
2+
*.csproj.meta
3+
4+
# Documentation builds
5+
site/
6+
docs/api/
7+
Documentation/api/metadata/
8+
Documentation/api/_site/
9+
Documentation/**/bin/
10+
Documentation/**/obj/

Documentation.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Documentation/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Build documentation locally
2+
3+
## Prerequisites
4+
5+
- [.NET 8 SDK](https://dotnet.microsoft.com/download)
6+
- Python 3.10+
7+
8+
## Commands
9+
10+
```bash
11+
# API reference (DocFX)
12+
cd Documentation
13+
dotnet build Mathx.Docs.csproj
14+
dotnet tool install -g docfx # once
15+
docfx metadata docfx.json
16+
docfx build docfx.json
17+
18+
# Merge API into docs before MkDocs (included in site output)
19+
rm -rf docs/api
20+
mkdir -p docs/api
21+
cp -r Documentation/api/_site/* docs/api/
22+
cp docs/api-stub/index.html docs/api/index.html
23+
24+
# Guides (MkDocs Material)
25+
cd ..
26+
pip install -r requirements-docs.txt
27+
mkdocs build
28+
```
29+
30+
Open `site/index.html` locally, or run `mkdocs serve` for live reload (guides only until API is copied).
31+
32+
Published site: [ltmx.github.io/Unity.mathx](https://ltmx.github.io/Unity.mathx/)

Documentation/README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Documentation/Stubs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Documentation/Stubs/Unity.Stubs.cs

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
// Minimal Unity API stubs for DocFX metadata extraction (not used at runtime).
2+
3+
using System;
4+
using System.Runtime.InteropServices;
5+
using Unity.Mathematics;
6+
7+
namespace UnityEngine
8+
{
9+
public struct Vector2
10+
{
11+
public float x, y;
12+
public Vector2(float x, float y) { this.x = x; this.y = y; }
13+
public static implicit operator float2(Vector2 v) { unsafe { return *(float2*)&v; } }
14+
public static implicit operator Vector2(float2 v) { unsafe { return *(Vector2*)&v; } }
15+
public static Vector2 operator -(Vector2 v) => new(-v.x, -v.y);
16+
}
17+
18+
public struct Vector3
19+
{
20+
public float x, y, z;
21+
public Vector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; }
22+
public static implicit operator float3(Vector3 v) { unsafe { return *(float3*)&v; } }
23+
public static implicit operator Vector3(float3 v) { unsafe { return *(Vector3*)&v; } }
24+
public static Vector3 operator -(Vector3 v) => new(-v.x, -v.y, -v.z);
25+
}
26+
27+
public struct Vector4
28+
{
29+
public float x, y, z, w;
30+
public Vector4(float x, float y, float z, float w) { this.x = x; this.y = y; this.z = z; this.w = w; }
31+
public static implicit operator float4(Vector4 v) { unsafe { return *(float4*)&v; } }
32+
public static Vector4 operator -(Vector4 v) => new(-v.x, -v.y, -v.z, -v.w);
33+
}
34+
public struct Vector2Int { public int x, y; public Vector2Int(int x, int y) { this.x = x; this.y = y; } }
35+
public struct Vector3Int { public int x, y, z; public Vector3Int(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } }
36+
public struct Matrix4x4
37+
{
38+
public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33;
39+
public static explicit operator float4x4(Matrix4x4 m) { unsafe { return *(float4x4*)&m; } }
40+
}
41+
public struct Color { public float r, g, b, a; public Color(float r, float g, float b, float a) { this.r = r; this.g = g; this.b = b; this.a = a; } }
42+
public struct Color32 { public byte r, g, b, a; public Color32(byte r, byte g, byte b, byte a) { this.r = r; this.g = g; this.b = b; this.a = a; } }
43+
public struct Bounds { public Vector3 center, size; public Bounds(Vector3 center, Vector3 size) { this.center = center; this.size = size; } }
44+
public struct Ray { public Vector3 origin, direction; public Ray(Vector3 origin, Vector3 direction) { this.origin = origin; this.direction = direction; } }
45+
public static class Time { public static float deltaTime => 0.016f; }
46+
47+
public class Transform
48+
{
49+
public Matrix4x4 localToWorldMatrix => default;
50+
}
51+
}
52+
53+
namespace AOT
54+
{
55+
[AttributeUsage(AttributeTargets.Method)]
56+
public class MonoPInvokeCallbackAttribute : Attribute
57+
{
58+
public MonoPInvokeCallbackAttribute(Type type) { }
59+
}
60+
}
61+
62+
namespace Unity.Burst
63+
{
64+
public enum FloatPrecision { Standard, Low, Medium, High }
65+
public enum FloatMode { Default, Strict, Deterministic, Fast }
66+
public enum OptimizeFor { Default, Performance, Size, FastCompilation }
67+
68+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method)]
69+
public class BurstCompileAttribute : Attribute
70+
{
71+
public FloatPrecision FloatPrecision { get; set; }
72+
public FloatMode FloatMode { get; set; }
73+
public bool CompileSynchronously { get; set; }
74+
public OptimizeFor OptimizeFor { get; set; }
75+
76+
public BurstCompileAttribute() { }
77+
public BurstCompileAttribute(FloatPrecision precision, FloatMode mode) { FloatPrecision = precision; FloatMode = mode; }
78+
}
79+
80+
public readonly struct FunctionPointer<T> where T : class
81+
{
82+
public FunctionPointer(IntPtr ptr) { Invoke = default!; }
83+
public T Invoke { get; }
84+
public void InvokeMethod() { }
85+
}
86+
87+
public static class BurstCompiler
88+
{
89+
public static FunctionPointer<T> CompileFunctionPointer<T>(T delegateMethod) where T : class =>
90+
new FunctionPointer<T>(IntPtr.Zero);
91+
}
92+
}
93+
94+
namespace Unity.Burst.Intrinsics
95+
{
96+
public struct v128
97+
{
98+
public int Int0, Int1, Int2, Int3;
99+
public v128(int a, int b, int c, int d) { Int0 = a; Int1 = b; Int2 = c; Int3 = d; }
100+
}
101+
102+
public static class X86
103+
{
104+
public static class Sse
105+
{
106+
public static v128 rcp_ss(v128 a) => a;
107+
}
108+
109+
public static class Sse2
110+
{
111+
public static v128 sub_epi32(v128 a, v128 b) => a;
112+
}
113+
}
114+
}
115+
116+
namespace Unity.Collections
117+
{
118+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter)]
119+
public class ReadOnlyAttribute : Attribute { }
120+
121+
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter)]
122+
public class WriteOnlyAttribute : Attribute { }
123+
124+
public struct NativeArray<T> where T : struct
125+
{
126+
public int Length => 0;
127+
public T this[int index] { get => default; set { } }
128+
public void CopyFrom(T[] array) { }
129+
}
130+
}
131+
132+
namespace Unity.Collections.LowLevel.Unsafe
133+
{
134+
public static class Unsafe
135+
{
136+
public static ref TTo As<TFrom, TTo>(ref TFrom source) where TFrom : struct where TTo : struct
137+
{
138+
// Doc stub only — not invoked at runtime.
139+
throw new NotSupportedException();
140+
}
141+
}
142+
}
143+
144+
namespace Unity.Jobs
145+
{
146+
public struct JobHandle { }
147+
148+
public static class JobHandleExtensions
149+
{
150+
public static void Complete(this JobHandle handle) { }
151+
}
152+
153+
public interface IJob
154+
{
155+
void Execute();
156+
}
157+
158+
public interface IJobParallelFor
159+
{
160+
void Execute(int index);
161+
}
162+
163+
public static class IJobExtensions
164+
{
165+
public static JobHandle Schedule<T>(this T jobData) where T : struct, IJob => default;
166+
public static JobHandle Schedule<T>(this T jobData, JobHandle dependsOn) where T : struct, IJob => default;
167+
}
168+
169+
public static class IJobParallelForExtensions
170+
{
171+
public static JobHandle Schedule<T>(this T jobData, int arrayLength, int innerloopBatchCount) where T : struct, IJobParallelFor => default;
172+
public static JobHandle Schedule<T>(this T jobData, int arrayLength, int innerloopBatchCount, JobHandle dependsOn) where T : struct, IJobParallelFor => default;
173+
}
174+
}

Documentation/Stubs/Unity.Stubs.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Documentation/Stubs/bin.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)