Skip to content

Commit 7c7ce58

Browse files
committed
Improve documentation coverage.
1 parent 3fc7869 commit 7c7ce58

16 files changed

+82
-15
lines changed

.jazzy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ custom_categories:
88
- name: Attribute Functions
99
children:
1010
- AttributeFunction
11-
- attribute(_:_:_:)
12-
- attributes(_:_:)
11+
- attribute(_:withValue:)
12+
- attributesWithValues(_:)
1313

1414
- name: Attribute Extensions
1515
children:

Attributed/AttributedStringConvertible.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@ import Foundation
1212

1313
// MARK: - Function Types
1414

15-
/// An attribute function.
15+
/// The type for attribute functions.
16+
///
17+
/// All extensions provided by Attributed add functions of this type. For example, an extension of `UIColor` can be used
18+
/// to create red text:
19+
///
20+
/// UIColor.redColor().foregroundAttribute(text)
21+
///
22+
/// However, referencing `UIColor.redColor().foregroundAttribute` alone can also be useful, as it is equivalent to an
23+
/// `AttributeFunction` that applies red text to its parameter. Attribute functions can be used in sequences, which can
24+
/// be reduced to a single `AttributeFunction` with the `join` extension of `SequenceType`.
25+
///
26+
/// If writing code that should compose with Attributed, it typically makes sense to write functions that will apply
27+
/// attributes in terms of `AttributeFunction`. If additional parameters are required, it's better to return a closure
28+
/// than to accept an `AttributedStringConvertible` alongside other parameters.
1629
public typealias AttributeFunction = AttributedStringConvertible -> AttributedStringConvertible
1730

1831
// MARK: - Protocol

Attributed/ColorType+Attributes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import AppKit
1515
#endif
1616

17+
/// `ColorType` is extended to provide foreground, background, underline, and strikethrough color attributes.
1718
public extension ColorType
1819
{
1920
// MARK: - Foreground Color

Attributed/FontType+Attributes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import AppKit
1515
#endif
1616

17+
/// `FontType` is extended to provide an attribute function.
1718
public extension FontType
1819
{
1920
// MARK: - Attributes

Attributed/Ligature+Attributes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import AppKit
1515
#endif
1616

17+
/// `Ligature` is extended to provide an attribute function.
1718
public extension Ligature
1819
{
1920
// MARK: - Attributes

Attributed/Ligature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public enum Ligature: Int
1414
/// No ligatures will be used.
1515
case None = 0
1616

17-
/// The default ligatures will be used
17+
/// The default ligatures will be used.
1818
case Default = 1
1919

2020
#if os(OSX)

Attributed/NSCursor+Attributes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import AppKit
1414

15+
/// `NSCursor` is extended to provide an attribute function.
1516
extension NSCursor
1617
{
1718
// MARK: - Attributes

Attributed/NSNumberConvertible+Attributes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import AppKit
1515
#endif
1616

17+
/// `NSNumberConvertible` is extended to provide baseline offset and kerning attribute functions.
1718
public extension NSNumberConvertible
1819
{
1920
// MARK: - Baseline Offset

Attributed/NSNumberConvertible.swift

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,130 +18,172 @@ import Foundation
1818
/// Extensions for number-based attributes extend this type.
1919
public protocol NSNumberConvertible
2020
{
21-
/// The value of the type, as an `NSNumber` instance.
21+
/// The value, wrapped in an `NSNumber` instance.
2222
var NSNumberValue: NSNumber { get }
2323
}
2424

2525
// MARK: - NSNumber
26+
27+
/// `NSNumber` is extended to conform to `NSNumberConvertible`.
2628
extension NSNumber: NSNumberConvertible
2729
{
30+
/// Returns `self`.
2831
public var NSNumberValue: NSNumber
2932
{
3033
return self
3134
}
3235
}
3336

3437
// MARK: - Int
38+
39+
/// `Int` is extended to conform to `NSNumberConvertible`.
3540
extension Int: NSNumberConvertible
3641
{
42+
/// The value, wrapped in an `NSNumber` instance.
3743
public var NSNumberValue: NSNumber
3844
{
3945
return self
4046
}
4147
}
4248

4349
// MARK: - UInt
50+
51+
/// `UInt` is extended to conform to `NSNumberConvertible`.
4452
extension UInt: NSNumberConvertible
4553
{
54+
/// The value, wrapped in an `NSNumber` instance.
4655
public var NSNumberValue: NSNumber
4756
{
4857
return self
4958
}
5059
}
5160

5261
// MARK: - Int8
62+
63+
/// `Int8` is extended to conform to `NSNumberConvertible`.
5364
extension Int8: NSNumberConvertible
5465
{
66+
/// The value, wrapped in an `NSNumber` instance.
5567
public var NSNumberValue: NSNumber
5668
{
5769
return Int(self)
5870
}
5971
}
6072

6173
// MARK: - UInt8
74+
75+
/// `UInt8` is extended to conform to `NSNumberConvertible`.
6276
extension UInt8: NSNumberConvertible
6377
{
78+
/// The value, wrapped in an `NSNumber` instance.
6479
public var NSNumberValue: NSNumber
6580
{
6681
return UInt(self)
6782
}
6883
}
6984

7085
// MARK: - Int16
86+
87+
/// `Int16` is extended to conform to `NSNumberConvertible`.
7188
extension Int16: NSNumberConvertible
7289
{
90+
/// The value, wrapped in an `NSNumber` instance.
7391
public var NSNumberValue: NSNumber
7492
{
7593
return Int(self)
7694
}
7795
}
7896

7997
// MARK: - UInt16
98+
99+
/// `UInt16` is extended to conform to `NSNumberConvertible`.
80100
extension UInt16: NSNumberConvertible
81101
{
102+
/// The value, wrapped in an `NSNumber` instance.
82103
public var NSNumberValue: NSNumber
83104
{
84105
return UInt(self)
85106
}
86107
}
87108

88109
// MARK: - Int32
110+
111+
/// `Int32` is extended to conform to `NSNumberConvertible`.
89112
extension Int32: NSNumberConvertible
90113
{
114+
/// The value, wrapped in an `NSNumber` instance.
91115
public var NSNumberValue: NSNumber
92116
{
93117
return Int(self)
94118
}
95119
}
96120

97121
// MARK: - UInt32
122+
123+
/// `UInt32` is extended to conform to `NSNumberConvertible`.
98124
extension UInt32: NSNumberConvertible
99125
{
126+
/// The value, wrapped in an `NSNumber` instance.
100127
public var NSNumberValue: NSNumber
101128
{
102129
return UInt(self)
103130
}
104131
}
105132

106133
// MARK: - Int64
134+
135+
/// `Int64` is extended to conform to `NSNumberConvertible`.
107136
extension Int64: NSNumberConvertible
108137
{
138+
/// The value, wrapped in an `NSNumber` instance.
109139
public var NSNumberValue: NSNumber
110140
{
111141
return NSNumber(longLong: self)
112142
}
113143
}
114144

115145
// MARK: - UInt64
146+
147+
/// `UInt64` is extended to conform to `NSNumberConvertible`.
116148
extension UInt64: NSNumberConvertible
117149
{
150+
/// The value, wrapped in an `NSNumber` instance.
118151
public var NSNumberValue: NSNumber
119152
{
120153
return NSNumber(unsignedLongLong: self)
121154
}
122155
}
123156

124157
// MARK: - Float
158+
159+
/// `Float` is extended to conform to `NSNumberConvertible`.
125160
extension Float: NSNumberConvertible
126161
{
162+
/// The value, wrapped in an `NSNumber` instance.
127163
public var NSNumberValue: NSNumber
128164
{
129165
return self
130166
}
131167
}
132168

133169
// MARK: - Double
170+
171+
/// `Double` is extended to conform to `NSNumberConvertible`.
134172
extension Double: NSNumberConvertible
135173
{
174+
/// The value, wrapped in an `NSNumber` instance.
136175
public var NSNumberValue: NSNumber
137176
{
138177
return self
139178
}
140179
}
141180

142181
// MARK: - CGFloat
182+
183+
/// `CGFloat` is extended to conform to `NSNumberConvertible`.
143184
extension CGFloat: NSNumberConvertible
144185
{
186+
/// The value, wrapped in an `NSNumber` instance.
145187
public var NSNumberValue: NSNumber
146188
{
147189
return self

Attributed/NSParagraphStyle+Attributes.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import AppKit
1515
#endif
1616

17+
/// `NSParagraphStyle` is extended to provide an attribute function.
1718
public extension NSParagraphStyle
1819
{
1920
// MARK: - Attributes

0 commit comments

Comments
 (0)