Skip to content

Commit be9767c

Browse files
Mark Pospeselmpospese
authored andcommitted
[CM-996] Add linter rules and fix violations
1 parent 3d1e202 commit be9767c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.swiftlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
99
- empty_count
1010
- first_where
1111
- force_unwrapping
12+
- implicit_return
13+
- missing_docs
1214
- multiline_arguments
1315
- multiline_arguments_brackets
1416
- multiline_function_chains

Sources/YMatterType/Typography/FontFamily/FontFamily.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ extension Typography {
7070

7171
// MARK: - Default implementations
7272

73+
/// Default implementations
7374
extension FontFamily {
74-
// returns no suffix
75+
/// Returns no suffix
7576
public var fontNameSuffix: String { "" }
7677

77-
// returns all weights
78+
/// Returns all weights
7879
public var supportedWeights: [Typography.FontWeight] { Typography.FontWeight.allCases }
7980

81+
/// Generates the font to be used using `UIFont(name:size:)` and the name generated by
82+
/// `fontName(weight:traitCollection:)`
8083
public func font(
8184
for weight: Typography.FontWeight,
8285
pointSize: CGFloat,
@@ -95,6 +98,8 @@ extension FontFamily {
9598
return font
9699
}
97100

101+
/// Generates the font name by combining family name, the weight name
102+
/// (potentially adjusted for Bold Text), and suffix.
98103
public func fontName(
99104
for weight: Typography.FontWeight,
100105
compatibleWith traitCollection: UITraitCollection?
@@ -106,6 +111,7 @@ extension FontFamily {
106111
return "\(familyName)-\(weightName)\(fontNameSuffix)"
107112
}
108113

114+
/// Returns default name for each weight
109115
public func weightName(for weight: Typography.FontWeight) -> String {
110116
// Default font name suffix by weight
111117
switch weight {
@@ -130,8 +136,8 @@ extension FontFamily {
130136
}
131137
}
132138

139+
/// Returns the next heavier supported weight (if any), otherwise the heaviest supported weight
133140
public func accessibilityBoldWeight(for weight: Typography.FontWeight) -> Typography.FontWeight {
134-
// By default returns the next heavier supported weight (if any), otherwise the heaviest supported weight
135141
let weights = supportedWeights.sorted(by: { $0.rawValue < $1.rawValue })
136142
// return the next heavier supported weight
137143
return weights.first(where: { $0.rawValue > weight.rawValue }) ?? weights.last ?? weight

0 commit comments

Comments
 (0)