Skip to content

Commit 3735a16

Browse files
committed
doc: update for extension
1 parent bf6c29e commit 3735a16

9 files changed

+616
-7
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ jobs:
1616
- name: Resolve Swift Package dependencies
1717
run: xcodebuild -resolvePackageDependencies
1818
- name: Generate Documentation
19-
run: ./docs.sh || {
20-
# 若失败,打印 xcodebuild 日志
21-
cat /var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/xcodebuild-*.log
22-
exit 1
23-
}
19+
run: ./docs.sh
2420
continue-on-error: false
2521
- name: Publish
2622
uses: peaceiris/actions-gh-pages@v3

.jazzy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ github_url: https://github.com/EFPrefix/EFQRCode
88
github_file_prefix: https://github.com/EFPrefix/EFQRCode/blob/main
99
dash_url: https://efprefix.github.io/EFQRCode/docsets/EFQRCode.xml
1010
exclude: ./Source/EFQRCode+Migration*
11-
xcodebuild_arguments: [-workspace, 'EFQRCode.xcworkspace', -scheme, 'EFQRCode iOS']
11+
xcodebuild_arguments: [-workspace, 'EFQRCode.xcworkspace', -scheme, 'EFQRCode iOS', -sdk, 'iphoneos']
1212
output: docs

Source/Extension/BinaryFloatingPoint+EFQRCode.swift

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,60 +27,189 @@
2727
import Foundation
2828
import CoreGraphics
2929

30+
/**
31+
* Extensions for BinaryFloatingPoint to support type conversion in QR code processing.
32+
*
33+
* This extension provides convenient type conversion methods for floating-point numbers
34+
* that are used throughout the EFQRCode library for coordinate calculations, size conversions,
35+
* and other numerical operations.
36+
*
37+
* ## Features
38+
*
39+
* - Boolean conversion for conditional logic
40+
* - CGFloat conversion for Core Graphics operations
41+
* - Numeric type conversions for various precision requirements
42+
* - Integer type conversions for different bit widths
43+
* - Unsigned integer conversions for positive-only values
44+
*
45+
* ## Usage
46+
*
47+
* ```swift
48+
* let value: Double = 3.14
49+
*
50+
* // Convert to different types
51+
* let cgFloat = value.cgFloat // CGFloat
52+
* let int = value.int // Int
53+
* let bool = value.bool // Bool (true if non-zero)
54+
* let uInt32 = value.uInt32 // UInt32
55+
* ```
56+
*
57+
* ## Supported Types
58+
*
59+
* The extension provides conversions to:
60+
* - **Boolean**: `bool` - true if non-zero, false if zero
61+
* - **Floating Point**: `cgFloat`, `double`, `float`
62+
* - **Signed Integers**: `int`, `int8`, `int16`, `int32`, `int64`
63+
* - **Unsigned Integers**: `uInt`, `uInt8`, `uInt16`, `uInt32`, `uInt64`
64+
*/
3065
extension BinaryFloatingPoint {
3166

67+
/**
68+
* Converts the floating-point value to a boolean.
69+
*
70+
* Returns true if the value is non-zero, false if the value is zero.
71+
*
72+
* - Returns: true if the value is non-zero, false otherwise.
73+
*/
3274
var bool: Bool {
3375
return 0 != self
3476
}
3577

78+
/**
79+
* Converts the floating-point value to CGFloat.
80+
*
81+
* This is commonly used for Core Graphics operations that require CGFloat.
82+
*
83+
* - Returns: A CGFloat representation of the value.
84+
*/
3685
var cgFloat: CGFloat {
3786
return CGFloat(self)
3887
}
3988

89+
/**
90+
* Converts the floating-point value to Double.
91+
*
92+
* - Returns: A Double representation of the value.
93+
*/
4094
var double: Double {
4195
return Double(self)
4296
}
4397

98+
/**
99+
* Converts the floating-point value to Float.
100+
*
101+
* - Returns: A Float representation of the value.
102+
*/
44103
var float: Float {
45104
return Float(self)
46105
}
47106

107+
/**
108+
* Converts the floating-point value to Int.
109+
*
110+
* The value is truncated to the nearest integer.
111+
*
112+
* - Returns: An Int representation of the value.
113+
*/
48114
var int: Int {
49115
return Int(self)
50116
}
51117

118+
/**
119+
* Converts the floating-point value to Int8.
120+
*
121+
* The value is truncated to the nearest integer and clamped to Int8 range.
122+
*
123+
* - Returns: An Int8 representation of the value.
124+
*/
52125
var int8: Int8 {
53126
return Int8(self)
54127
}
55128

129+
/**
130+
* Converts the floating-point value to Int16.
131+
*
132+
* The value is truncated to the nearest integer and clamped to Int16 range.
133+
*
134+
* - Returns: An Int16 representation of the value.
135+
*/
56136
var int16: Int16 {
57137
return Int16(self)
58138
}
59139

140+
/**
141+
* Converts the floating-point value to Int32.
142+
*
143+
* The value is truncated to the nearest integer and clamped to Int32 range.
144+
*
145+
* - Returns: An Int32 representation of the value.
146+
*/
60147
var int32: Int32 {
61148
return Int32(self)
62149
}
63150

151+
/**
152+
* Converts the floating-point value to Int64.
153+
*
154+
* The value is truncated to the nearest integer and clamped to Int64 range.
155+
*
156+
* - Returns: An Int64 representation of the value.
157+
*/
64158
var int64: Int64 {
65159
return Int64(self)
66160
}
67161

162+
/**
163+
* Converts the floating-point value to UInt.
164+
*
165+
* The value is truncated to the nearest integer and clamped to UInt range.
166+
*
167+
* - Returns: A UInt representation of the value.
168+
*/
68169
var uInt: UInt {
69170
return UInt(self)
70171
}
71172

173+
/**
174+
* Converts the floating-point value to UInt8.
175+
*
176+
* The value is truncated to the nearest integer and clamped to UInt8 range.
177+
*
178+
* - Returns: A UInt8 representation of the value.
179+
*/
72180
var uInt8: UInt8 {
73181
return UInt8(self)
74182
}
75183

184+
/**
185+
* Converts the floating-point value to UInt16.
186+
*
187+
* The value is truncated to the nearest integer and clamped to UInt16 range.
188+
*
189+
* - Returns: A UInt16 representation of the value.
190+
*/
76191
var uInt16: UInt16 {
77192
return UInt16(self)
78193
}
79194

195+
/**
196+
* Converts the floating-point value to UInt32.
197+
*
198+
* The value is truncated to the nearest integer and clamped to UInt32 range.
199+
*
200+
* - Returns: A UInt32 representation of the value.
201+
*/
80202
var uInt32: UInt32 {
81203
return UInt32(self)
82204
}
83205

206+
/**
207+
* Converts the floating-point value to UInt64.
208+
*
209+
* The value is truncated to the nearest integer and clamped to UInt64 range.
210+
*
211+
* - Returns: A UInt64 representation of the value.
212+
*/
84213
var uInt64: UInt64 {
85214
return UInt64(self)
86215
}

Source/Extension/BinaryInteger+EFQRCode.swift

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,60 +27,187 @@
2727
import Foundation
2828
import CoreGraphics
2929

30+
/**
31+
* Extensions for BinaryInteger to support type conversion in QR code processing.
32+
*
33+
* This extension provides convenient type conversion methods for integer numbers
34+
* that are used throughout the EFQRCode library for coordinate calculations, size conversions,
35+
* and other numerical operations.
36+
*
37+
* ## Features
38+
*
39+
* - Boolean conversion for conditional logic
40+
* - CGFloat conversion for Core Graphics operations
41+
* - Numeric type conversions for various precision requirements
42+
* - Integer type conversions for different bit widths
43+
* - Unsigned integer conversions for positive-only values
44+
*
45+
* ## Usage
46+
*
47+
* ```swift
48+
* let value: Int = 42
49+
*
50+
* // Convert to different types
51+
* let cgFloat = value.cgFloat // CGFloat
52+
* let double = value.double // Double
53+
* let bool = value.bool // Bool (true if non-zero)
54+
* let uInt32 = value.uInt32 // UInt32
55+
* ```
56+
*
57+
* ## Supported Types
58+
*
59+
* The extension provides conversions to:
60+
* - **Boolean**: `bool` - true if non-zero, false if zero
61+
* - **Floating Point**: `cgFloat`, `double`, `float`
62+
* - **Signed Integers**: `int`, `int8`, `int16`, `int32`, `int64`
63+
* - **Unsigned Integers**: `uInt`, `uInt8`, `uInt16`, `uInt32`, `uInt64`
64+
*/
3065
extension BinaryInteger {
3166

67+
/**
68+
* Converts the integer value to a boolean.
69+
*
70+
* Returns true if the value is non-zero, false if the value is zero.
71+
*
72+
* - Returns: true if the value is non-zero, false otherwise.
73+
*/
3274
var bool: Bool {
3375
return 0 != self
3476
}
3577

78+
/**
79+
* Converts the integer value to CGFloat.
80+
*
81+
* This is commonly used for Core Graphics operations that require CGFloat.
82+
*
83+
* - Returns: A CGFloat representation of the value.
84+
*/
3685
var cgFloat: CGFloat {
3786
return CGFloat(self)
3887
}
3988

89+
/**
90+
* Converts the integer value to Double.
91+
*
92+
* - Returns: A Double representation of the value.
93+
*/
4094
var double: Double {
4195
return Double(self)
4296
}
4397

98+
/**
99+
* Converts the integer value to Float.
100+
*
101+
* - Returns: A Float representation of the value.
102+
*/
44103
var float: Float {
45104
return Float(self)
46105
}
47106

107+
/**
108+
* Converts the integer value to Int.
109+
*
110+
* - Returns: An Int representation of the value.
111+
*/
48112
var int: Int {
49113
return Int(self)
50114
}
51115

116+
/**
117+
* Converts the integer value to Int8.
118+
*
119+
* The value is clamped to Int8 range.
120+
*
121+
* - Returns: An Int8 representation of the value.
122+
*/
52123
var int8: Int8 {
53124
return Int8(self)
54125
}
55126

127+
/**
128+
* Converts the integer value to Int16.
129+
*
130+
* The value is clamped to Int16 range.
131+
*
132+
* - Returns: An Int16 representation of the value.
133+
*/
56134
var int16: Int16 {
57135
return Int16(self)
58136
}
59137

138+
/**
139+
* Converts the integer value to Int32.
140+
*
141+
* The value is clamped to Int32 range.
142+
*
143+
* - Returns: An Int32 representation of the value.
144+
*/
60145
var int32: Int32 {
61146
return Int32(self)
62147
}
63148

149+
/**
150+
* Converts the integer value to Int64.
151+
*
152+
* The value is clamped to Int64 range.
153+
*
154+
* - Returns: An Int64 representation of the value.
155+
*/
64156
var int64: Int64 {
65157
return Int64(self)
66158
}
67159

160+
/**
161+
* Converts the integer value to UInt.
162+
*
163+
* The value is clamped to UInt range.
164+
*
165+
* - Returns: A UInt representation of the value.
166+
*/
68167
var uInt: UInt {
69168
return UInt(self)
70169
}
71170

171+
/**
172+
* Converts the integer value to UInt8.
173+
*
174+
* The value is clamped to UInt8 range.
175+
*
176+
* - Returns: A UInt8 representation of the value.
177+
*/
72178
var uInt8: UInt8 {
73179
return UInt8(self)
74180
}
75181

182+
/**
183+
* Converts the integer value to UInt16.
184+
*
185+
* The value is clamped to UInt16 range.
186+
*
187+
* - Returns: A UInt16 representation of the value.
188+
*/
76189
var uInt16: UInt16 {
77190
return UInt16(self)
78191
}
79192

193+
/**
194+
* Converts the integer value to UInt32.
195+
*
196+
* The value is clamped to UInt32 range.
197+
*
198+
* - Returns: A UInt32 representation of the value.
199+
*/
80200
var uInt32: UInt32 {
81201
return UInt32(self)
82202
}
83203

204+
/**
205+
* Converts the integer value to UInt64.
206+
*
207+
* The value is clamped to UInt64 range.
208+
*
209+
* - Returns: A UInt64 representation of the value.
210+
*/
84211
var uInt64: UInt64 {
85212
return UInt64(self)
86213
}

0 commit comments

Comments
 (0)