Skip to content

Commit b874ac2

Browse files
authored
Add documentation (#35)
* Add documentation * Lint * add docs-coverage rule * docs: complete documentation coverage to 100% for types * Add operator documentation * Lint * feat(docs): Add local documentation targets to Makefile * conductor(checkpoint): Checkpoint end of Phase 1 * feat(docs): Add docs-check-coverage target to Makefile * feat(docs): Add docs-check-links target to Makefile * conductor(checkpoint): Checkpoint end of Phase 2 * feat(docs): Add Documentation CI/CD workflow * conductor(checkpoint): Checkpoint end of Phase 3 * build: include swift-docc-plugin only on macOS to fix Windows CI
1 parent eabf3ea commit b874ac2

Some content is hidden

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

87 files changed

+1722
-505
lines changed

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
workflow_dispatch:
7+
8+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
jobs:
15+
build-docs:
16+
name: Build Documentation
17+
runs-on: macos-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v6
21+
22+
- name: Setup Swift
23+
uses: swift-actions/setup-swift@v2
24+
with:
25+
swift-version: "6.1"
26+
27+
- name: Build Documentation
28+
run: make docs-generate
29+
30+
- name: Check Documentation Quality
31+
run: |
32+
make docs-check-coverage
33+
make docs-check-links
34+
35+
- name: Upload artifact
36+
uses: actions/upload-pages-artifact@v3
37+
with:
38+
path: .build/documentation
39+
40+
deploy:
41+
name: Deploy to GitHub Pages
42+
needs: build-docs
43+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
44+
runs-on: ubuntu-latest
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,39 @@ UNAME_S := $(shell uname -s)
22
SWIFT_FLAGS ?= --disable-sandbox
33
PACKAGE_SWIFT_VERSION := $(shell grep "swift-tools-version" Package.swift | head -n 1 | cut -d ":" -f 2 | xargs)
44

5+
HOSTING_BASE_PATH ?= fireblade-math
6+
57
# Targets
6-
.PHONY: setup lint lint-fix test test-coverage clean pre-commit
8+
.PHONY: setup lint lint-fix test test-coverage clean pre-commit docs docs-preview docs-generate docs-coverage
79

810
setup:
911
@echo "Detected Package Swift Version: $(PACKAGE_SWIFT_VERSION)"
1012
@which mint > /dev/null || (echo "Mint not found. Installing via Homebrew..." && brew install mint)
1113
mint bootstrap
1214
swift package resolve $(SWIFT_FLAGS)
1315

16+
docs: docs-generate
17+
18+
docs-preview:
19+
swift package --disable-sandbox preview-documentation --target FirebladeMath
20+
21+
docs-generate:
22+
swift package --disable-sandbox \
23+
--allow-writing-to-directory .build/documentation \
24+
generate-documentation --target FirebladeMath \
25+
--disable-indexing \
26+
--transform-for-static-hosting \
27+
--hosting-base-path $(HOSTING_BASE_PATH) \
28+
--output-path .build/documentation
29+
30+
docs-coverage: docs-check-coverage
31+
32+
docs-check-coverage:
33+
swift package --disable-sandbox generate-documentation --target FirebladeMath --experimental-documentation-coverage --coverage-summary-level brief
34+
35+
docs-check-links:
36+
swift package --disable-sandbox generate-documentation --target FirebladeMath --analyze --warnings-as-errors
37+
1438
lint:
1539
mint run swiftlint lint --quiet
1640
mint run swiftformat --lint --swiftversion $(PACKAGE_SWIFT_VERSION) Sources/ Tests/

Package.resolved

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

Package.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ let package = Package(
2525
.trait(name: "simd"),
2626
.trait(name: "default", enabledTraits: Set(defaultTraits))
2727
],
28+
dependencies: [
29+
],
2830
targets: [
2931
.target(
3032
name: "FirebladeMath",
@@ -36,3 +38,9 @@ let package = Package(
3638
swiftSettings: swiftSettings)
3739
]
3840
)
41+
42+
#if os(macOS)
43+
package.dependencies.append(
44+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.4.6")
45+
)
46+
#endif
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
/// Factor to convert degrees to radians (Double).
12
public let kDegreeToRadians64 = Double.pi / 180.0
3+
/// Factor to convert degrees to radians (Float).
24
public let kDegreeToRadians32 = Float(kDegreeToRadians64)
35

6+
/// Factor to convert radians to degrees (Double).
47
public let kRadiansToDegree64: Double = 180.0 / Double.pi
8+
/// Factor to convert radians to degrees (Float).
59
public let kRadiansToDegree32 = Float(kRadiansToDegree64)
610

11+
/// Extension to add constants to Float.
712
extension Float {
13+
/// Half of Pi (π/2).
814
public static let halfPi = Float(Double.halfPi)
915
}
1016

17+
/// Extension to add constants to Double.
1118
extension Double {
19+
/// Half of Pi (π/2).
1220
public static let halfPi: Double = .pi * 0.5
1321
}

Sources/FirebladeMath/Functions/abs.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ import Darwin
66
import Glibc
77
#endif
88

9-
/// Computes the absolute value of a floating point value arg.
9+
/// Computes the absolute value of a floating point value x.
1010
///
11-
/// - Parameter float: floating point value
12-
/// - Returns: If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
13-
public func abs(_ float: Float) -> Float {
14-
fabsf(float)
11+
/// - Parameter x: floating point value
12+
/// - Returns: If successful, returns the absolute value of x (|x|). The value returned is exact and does not depend on any rounding modes.
13+
public func abs(_ x: Float) -> Float {
14+
fabsf(x)
1515
}
1616

17-
/// Computes the absolute value of a floating point value arg.
17+
/// Computes the absolute value of a floating point value x.
1818
///
19-
/// - Parameter double: floating point value
20-
/// - Returns: If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
21-
public func abs(_ double: Double) -> Double {
19+
/// - Parameter x: floating point value
20+
/// - Returns: If successful, returns the absolute value of x (|x|). The value returned is exact and does not depend on any rounding modes.
21+
public func abs(_ x: Double) -> Double {
2222
#if canImport(Darwin)
23-
return Darwin.fabs(double)
23+
return Darwin.fabs(x)
2424
#elseif canImport(Glibc)
25-
return Glibc.fabs(double)
25+
return Glibc.fabs(x)
2626
#else
27-
return Foundation.fabs(double)
27+
return Foundation.fabs(x)
2828
#endif
2929
}

Sources/FirebladeMath/Functions/acos.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ import Darwin
66
import Glibc
77
#endif
88

9-
/// Computes the principal value of the arc cosine of arg.
9+
/// Computes the principal value of the arc cosine of x.
1010
///
11-
/// - Parameter float: floating point value
12-
/// - Returns: If no errors occur, the arc cosine of arg (arccos(arg)) in the range [0 ; π], is returned.
11+
/// - Parameter x: floating point value
12+
/// - Returns: If no errors occur, the arc cosine of x (arccos(x)) in the range [0 ; π], is returned.
1313
/// If a domain error occurs, an implementation-defined value is returned (NaN where supported).
1414
/// If a range error occurs due to underflow, the correct result (after rounding) is returned.
15-
public func acos(_ float: Float) -> Float {
15+
public func acos(_ x: Float) -> Float {
1616
#if canImport(Darwin)
17-
return Darwin.acosf(float)
17+
return Darwin.acosf(x)
1818
#elseif canImport(Glibc)
19-
return Glibc.acosf(float)
19+
return Glibc.acosf(x)
2020
#else
21-
return Foundation.acosf(float)
21+
return Foundation.acosf(x)
2222
#endif
2323
}
2424

25-
/// Computes the principal value of the arc cosine of arg.
25+
/// Computes the principal value of the arc cosine of x.
2626
///
27-
/// - Parameter double: floating point value
28-
/// - Returns: If no errors occur, the arc cosine of arg (arccos(arg)) in the range [0 ; π], is returned.
27+
/// - Parameter x: floating point value
28+
/// - Returns: If no errors occur, the arc cosine of x (arccos(x)) in the range [0 ; π], is returned.
2929
/// If a domain error occurs, an implementation-defined value is returned (NaN where supported).
3030
/// If a range error occurs due to underflow, the correct result (after rounding) is returned.
31-
public func acos(_ double: Double) -> Double {
31+
public func acos(_ x: Double) -> Double {
3232
#if canImport(Darwin)
33-
return Darwin.acos(double)
33+
return Darwin.acos(x)
3434
#elseif canImport(Glibc)
35-
return Glibc.acos(double)
35+
return Glibc.acos(x)
3636
#else
37-
return Foundation.acos(double)
37+
return Foundation.acos(x)
3838
#endif
3939
}

Sources/FirebladeMath/Functions/acosh.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ import Darwin
66
import Glibc
77
#endif
88

9-
/// Computes the inverse hyperbolic cosine of arg.
9+
/// Computes the inverse hyperbolic cosine of x.
1010
///
11-
/// - Parameter double: floating point value representing the area of a hyperbolic sector
12-
/// - Returns: If no errors occur, the inverse hyperbolic cosine of arg (cosh-1
13-
/// (arg), or arcosh(arg)) on the interval [0, +∞], is returned.
11+
/// - Parameter x: floating point value representing the area of a hyperbolic sector
12+
/// - Returns: If no errors occur, the inverse hyperbolic cosine of x (cosh-1
13+
/// (x), or arcosh(x)) on the interval [0, +∞], is returned.
1414
/// If a domain error occurs, an implementation-defined value is returned (NaN where supported).
15-
public func acosh(_ double: Double) -> Double {
15+
public func acosh(_ x: Double) -> Double {
1616
#if canImport(Darwin)
17-
return Darwin.acosh(double)
17+
return Darwin.acosh(x)
1818
#elseif canImport(Glibc)
19-
return Glibc.acosh(double)
19+
return Glibc.acosh(x)
2020
#else
21-
return Foundation.acosh(double)
21+
return Foundation.acosh(x)
2222
#endif
2323
}
2424

25-
/// Computes the inverse hyperbolic cosine of arg.
25+
/// Computes the inverse hyperbolic cosine of x.
2626
///
27-
/// - Parameter float: floating point value representing the area of a hyperbolic sector
28-
/// - Returns: If no errors occur, the inverse hyperbolic cosine of arg (cosh-1
29-
/// (arg), or arcosh(arg)) on the interval [0, +∞], is returned.
27+
/// - Parameter x: floating point value representing the area of a hyperbolic sector
28+
/// - Returns: If no errors occur, the inverse hyperbolic cosine of x (cosh-1
29+
/// (x), or arcosh(x)) on the interval [0, +∞], is returned.
3030
/// If a domain error occurs, an implementation-defined value is returned (NaN where supported).
31-
public func acosh(_ float: Float) -> Float {
31+
public func acosh(_ x: Float) -> Float {
3232
#if canImport(Darwin)
33-
return Darwin.acoshf(float)
33+
return Darwin.acoshf(x)
3434
#elseif canImport(Glibc)
35-
return Glibc.acoshf(float)
35+
return Glibc.acoshf(x)
3636
#else
37-
return Foundation.acoshf(float)
37+
return Foundation.acoshf(x)
3838
#endif
3939
}

Sources/FirebladeMath/Functions/adjugate.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/// Computes the adjugate of a 3x3 matrix.
2+
/// - Parameter inMat: The input matrix.
3+
/// - Returns: The adjugate of the input matrix.
14
public func adjugate(_ inMat: Mat3x3f) -> Mat3x3f {
25
var out = Mat3x3f.identity
36

@@ -16,6 +19,9 @@ public func adjugate(_ inMat: Mat3x3f) -> Mat3x3f {
1619
return out
1720
}
1821

22+
/// Computes the adjugate of a 3x3 matrix.
23+
/// - Parameter inMat: The input matrix.
24+
/// - Returns: The adjugate of the input matrix.
1925
public func adjugate(_ inMat: Mat3x3d) -> Mat3x3d {
2026
var out = Mat3x3d.identity
2127

@@ -34,6 +40,9 @@ public func adjugate(_ inMat: Mat3x3d) -> Mat3x3d {
3440
return out
3541
}
3642

43+
/// Computes the adjugate of a 4x4 matrix.
44+
/// - Parameter m: The input matrix.
45+
/// - Returns: The adjugate of the input matrix.
3746
public func adjugate(_ m: Mat4x4f) -> Mat4x4f {
3847
// Adjugate is the transpose of the cofactor matrix.
3948
// cofactor(i, j) = (-1)^(i+j) * minor(i, j)
@@ -63,6 +72,9 @@ public func adjugate(_ m: Mat4x4f) -> Mat4x4f {
6372
return res
6473
}
6574

75+
/// Computes the adjugate of a 4x4 matrix.
76+
/// - Parameter m: The input matrix.
77+
/// - Returns: The adjugate of the input matrix.
6678
public func adjugate(_ m: Mat4x4d) -> Mat4x4d {
6779
var res = Mat4x4d.identity
6880

Sources/FirebladeMath/Functions/angle.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import func simd.simd_angle
33
#endif
44

55
/// Returns the angle by which a quaternion rotates.
6+
/// - Parameter quat: The quaternion.
7+
/// - Returns: The angle in radians.
68
public func angle(_ quat: Quat4f) -> Float {
79
#if FRB_MATH_USE_SIMD
810
return simd.simd_angle(quat.storage)
@@ -13,6 +15,8 @@ public func angle(_ quat: Quat4f) -> Float {
1315
}
1416

1517
/// Returns the angle by which a quaternion rotates.
18+
/// - Parameter quat: The quaternion.
19+
/// - Returns: The angle in radians.
1620
public func angle(_ quat: Quat4d) -> Double {
1721
#if FRB_MATH_USE_SIMD
1822
return simd.simd_angle(quat.storage)

0 commit comments

Comments
 (0)