Browse Source

Add documentation

onevcat 9 năm trước cách đây
mục cha
commit
84ea8c43da

+ 29 - 16
Sources/Filter.swift

@@ -32,15 +32,31 @@ import Accelerate
 // Reuse the same CI Context for all CI drawing.
 private let ciContext = CIContext(options: nil)
 
+/// Transformer method which will be used in to provide a `Filter`.
 public typealias Transformer = (CIImage) -> CIImage?
+
+/// Supply a filter to create an `ImageProcessor`.
 public protocol CIImageProcessor: ImageProcessor {
     var filter: Filter { get }
 }
 
+extension CIImageProcessor {
+    public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? {
+        switch item {
+        case .image(let image):
+            return image.kf_apply(filter)
+        case .data(let data):
+            return Image.kf_image(data: data, scale: options.scaleFactor, preloadAllGIFData: options.preloadAllGIFData)
+        }
+    }
+}
+
+/// Wrapper for a `Transformer` of CIImage filters.
 public struct Filter {
     
     let transform: Transformer
-    
+
+    /// Tint filter which will apply a tint color to images.
     public static var tint: (Color) -> Filter = {
         color in
         Filter { input in
@@ -56,6 +72,8 @@ public struct Filter {
     }
     
     public typealias ColorElement = (CGFloat, CGFloat, CGFloat, CGFloat)
+    
+    /// Color control filter which will apply color control change to images.
     public static var colorControl: (ColorElement) -> Filter = {
         brightness, contrast, saturation, inputEV in
         Filter { input in
@@ -71,21 +89,16 @@ public struct Filter {
     }
 }
 
-
-
-extension CIImageProcessor {
-    public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? {
-        switch item {
-        case .image(let image):
-            return image.kf_apply(filter)
-        case .data(let data):
-            return Image.kf_image(data: data, scale: options.scaleFactor, preloadAllGIFData: options.preloadAllGIFData)
-        }
-    }
-}
-
-extension Image {
-    func kf_apply(_ filter: Filter) -> Image {
+public extension Image {
+    
+    /// Apply a `Filter` containing `CIImage` transformer to `self`.
+    ///
+    /// - parameter filter: The filter used to transform `self`.
+    ///
+    /// - returns: A transformed image by input `Filter`.
+    ///
+    /// - Note: Only CG-based images are supported. If any error happens during transforming, `self` will be returned.
+    public func kf_apply(_ filter: Filter) -> Image {
         
         guard let cgImage = cgImage else {
             assertionFailure("[Kingfisher] Tint image only works for CG-based image.")

+ 49 - 18
Sources/ImageCache.swift

@@ -70,7 +70,10 @@ public enum CacheType {
     case none, memory, disk
 }
 
-/// `ImageCache` represents both the memory and disk cache system of Kingfisher. While a default image cache object will be used if you prefer the extension methods of Kingfisher, you can create your own cache object and configure it as your need. You should use an `ImageCache` object to manipulate memory and disk cache for Kingfisher.
+/// `ImageCache` represents both the memory and disk cache system of Kingfisher. 
+/// While a default image cache object will be used if you prefer the extension methods of Kingfisher, 
+/// you can create your own cache object and configure it as your need. You should use an `ImageCache` 
+/// object to manipulate memory and disk cache for Kingfisher.
 public class ImageCache {
 
     //Memory
@@ -93,7 +96,8 @@ public class ImageCache {
     /// The longest time duration of the cache being stored in disk. Default is 1 week.
     public var maxCachePeriodInSecond = defaultMaxCachePeriodInSecond
     
-    /// The largest disk size can be taken for the cache. It is the total allocated size of cached files in bytes. Default is 0, which means no limit.
+    /// The largest disk size can be taken for the cache. It is the total allocated size of cached files in bytes. 
+    /// Default is 0, which means no limit.
     public var maxDiskCacheSize: UInt = 0
     
     fileprivate let processQueue: DispatchQueue
@@ -106,9 +110,11 @@ public class ImageCache {
     /**
     Init method. Passing a name for the cache. It represents a cache folder in the memory and disk.
     
-    - parameter name: Name of the cache. It will be used as the memory cache name and the disk cache folder name appending to the cache path. This value should not be an empty string.
+    - parameter name: Name of the cache. It will be used as the memory cache name and the disk cache folder name 
+                      appending to the cache path. This value should not be an empty string.
     - parameter path: Optional - Location of cache path on disk. If `nil` is passed (the default value), 
-                      the cache folder in of your app will be used. If you want to cache some user generating images, you could pass the Documentation path here.
+                      the cache folder in of your app will be used. If you want to cache some user generating images, 
+                      you could pass the Documentation path here.
     
     - returns: The cache object.
     */
@@ -130,9 +136,12 @@ public class ImageCache {
         ioQueue.sync { fileManager = FileManager() }
         
 #if !os(macOS) && !os(watchOS)
-        NotificationCenter.default.addObserver(self, selector: #selector(clearMemoryCache), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(cleanExpiredDiskCache_), name: .UIApplicationWillTerminate, object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(backgroundCleanExpiredDiskCache), name: .UIApplicationDidEnterBackground, object: nil)
+        NotificationCenter.default.addObserver(
+            self, selector: #selector(clearMemoryCache), name: .UIApplicationDidReceiveMemoryWarning, object: nil)
+        NotificationCenter.default.addObserver(
+            self, selector: #selector(cleanExpiredDiskCache_), name: .UIApplicationWillTerminate, object: nil)
+        NotificationCenter.default.addObserver(
+            self, selector: #selector(backgroundCleanExpiredDiskCache), name: .UIApplicationDidEnterBackground, object: nil)
 #endif
     }
     
@@ -149,13 +158,21 @@ extension ImageCache {
     - parameter image:             The image to be stored.
     - parameter originalData:      The original data of the image.
                                    Kingfisher will use it to check the format of the image and optimize cache size on disk.
-                                   If `nil` is supplied, the image data will be saved as a normalized PNG file. 
+                                   If `nil` is supplied, the image data will be saved as a normalized PNG file.
                                    It is strongly suggested to supply it whenever possible, to get a better performance and disk usage.
     - parameter key:               Key for the image.
+    - parameter identifier:        The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it.
+                                   This identifier will be used to generate a corresponding key for the combination of `key` and processor.
     - parameter toDisk:            Whether this image should be cached to disk or not. If false, the image will be only cached in memory.
     - parameter completionHandler: Called when store operation completes.
     */
-    public func storeImage(_ image: Image, originalData: Data? = nil, forKey key: String, processorIdentifier identifier: String = "", toDisk: Bool = true, completionHandler: (() -> Void)? = nil) {
+    public func storeImage(_ image: Image,
+                           originalData: Data? = nil,
+                           forKey key: String,
+                           processorIdentifier identifier: String = "",
+                           toDisk: Bool = true,
+                           completionHandler: (() -> Void)? = nil)
+    {
         
         let computedKey = key.computedKey(with: identifier)
         memoryCache.setObject(image, forKey: computedKey as NSString, cost: image.kf_imageCost)
@@ -201,10 +218,16 @@ extension ImageCache {
     It is an async operation.
     
     - parameter key:               Key for the image.
+    - parameter identifier:        The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it.
+                                   This identifier will be used to generate a corresponding key for the combination of `key` and processor.
     - parameter fromDisk:          Whether this image should be removed from disk or not. If false, the image will be only removed from memory.
     - parameter completionHandler: Called when removal operation completes.
     */
-    public func removeImage(forKey key: String, processorIdentifier identifier: String = "", fromDisk: Bool = true, completionHandler: (() -> Void)? = nil) {
+    public func removeImage(forKey key: String,
+                            processorIdentifier identifier: String = "",
+                            fromDisk: Bool = true,
+                            completionHandler: (() -> Void)? = nil)
+    {
         let computedKey = key.computedKey(with: identifier)
         memoryCache.removeObject(forKey: computedKey as NSString)
         
@@ -236,12 +259,17 @@ extension ImageCache {
     Get an image for a key from memory or disk.
     
     - parameter key:               Key for the image.
-    - parameter options:           Options of retrieving image.
-    - parameter completionHandler: Called when getting operation completes with image result and cached type of this image. If there is no such key cached, the image will be `nil`.
+    - parameter options:           Options of retrieving image. If you need to retrieve an image which was 
+                                   stored with a specified `ImageProcessor`, pass the processor in the option too.
+    - parameter completionHandler: Called when getting operation completes with image result and cached type of 
+                                   this image. If there is no such key cached, the image will be `nil`.
     
     - returns: The retrieving task.
     */
-    @discardableResult public func retrieveImage(forKey key: String, options: KingfisherOptionsInfo?, completionHandler: ((Image?, CacheType) -> ())?) -> RetrieveImageDiskTask? {
+    @discardableResult public func retrieveImage(forKey key: String,
+                                                 options: KingfisherOptionsInfo?,
+                                                 completionHandler: ((Image?, CacheType) -> ())?) -> RetrieveImageDiskTask?
+    {
         // No completion handler. Not start working and early return.
         guard let completionHandler = completionHandler else {
             return nil
@@ -295,8 +323,9 @@ extension ImageCache {
     /**
     Get an image for a key from memory.
     
-    - parameter key: Key for the image.
-    
+    - parameter key:        Key for the image.
+    - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it.
+                            This identifier will be used to generate a corresponding key for the combination of `key` and processor.
     - returns: The image object if it is cached, or `nil` if there is no such key in the cache.
     */
     public func retrieveImageInMemoryCache(forKey key: String, processIdentifier identifier: String = "") -> Image? {
@@ -307,10 +336,12 @@ extension ImageCache {
     /**
     Get an image for a key from disk.
     
-    - parameter key: Key for the image.
-    - parameter scale: The scale factor to assume when interpreting the image data.
+    - parameter key:               Key for the image.
+    - parameter identifier:        The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it.
+                                   This identifier will be used to generate a corresponding key for the combination of `key` and processor.
+    - parameter scale:             The scale factor to assume when interpreting the image data.
     - parameter preloadAllGIFData: Whether all GIF data should be loaded. If true, you can set the loaded image to a regular UIImageView to play 
-      the GIF animation. Otherwise, you should use `AnimatedImageView` to play it. Default is `false`
+                                   the GIF animation. Otherwise, you should use `AnimatedImageView` to play it. Default is `false`
 
     - returns: The image object if it is cached, or `nil` if there is no such key in the cache.
     */

+ 1 - 0
Sources/ImageDownloader.swift

@@ -95,6 +95,7 @@ public enum KingfisherError: Int {
 
 public let KingfisherErrorStatusCodeKey = "statusCode"
 
+/// Request modifier of image downloader.
 public protocol ImageDownloadRequestModifier {
     func modified(for request: URLRequest) -> URLRequest?
 }

+ 132 - 6
Sources/ImageProcessor.swift

@@ -28,20 +28,50 @@
 import Foundation
 import CoreGraphics
 
+
+/// The item which could be processed by an `ImageProcessor`
+///
+/// - image: Input image
+/// - data:  Input data
 public enum ImageProcessItem {
     case image(Image)
     case data(Data)
 }
 
+/// An `ImageProcessor` could be used to convert some downloaded data to an image.
 public protocol ImageProcessor {
+    /// Identifier of the processor. It will be used to identify the processor when 
+    /// caching and retriving an image. You might want to make sure that processors with
+    /// same properties/functionality have the same identifiers.
     var identifier: String { get }
+    
+    /// Process an input `ImageProcessItem` item to an image for this processor.
+    ///
+    /// - parameter item:    Input item which will be processed by `self`
+    /// - parameter options: Options when processing the item.
+    ///
+    /// - returns: The processed image.
+    ///
+    /// - Note: The return value will be `nil` if processing failed while converting data to image.
+    ///         If input item is already an image and there is any errors in processing, the input 
+    ///         image itself will be returned.
+    /// - Note: Most processor only supports CG-based images. 
+    ///         watchOS is not supported for processers containing filter, the input image will be returned directly on watchOS.
     func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image?
 }
 
 typealias ProcessorImp = ((ImageProcessItem, KingfisherOptionsInfo) -> Image?)
 
 public extension ImageProcessor {
-    func append(another: ImageProcessor) -> ImageProcessor {
+    
+    /// Append an `ImageProcessor` to another. The identifier of the new `ImageProcessor` 
+    /// will be "\(self.identifier)|>\(another.identifier)>".
+    ///
+    /// - parameter another: An `ImageProcessor` you want to append to `self`.
+    ///
+    /// - returns: The new `ImageProcessor`. It will process the image in the order
+    ///            of the two processors concatenated.
+    public func append(another: ImageProcessor) -> ImageProcessor {
         let newIdentifier = identifier.appending("|>\(another.identifier)")
         return GeneralProcessor(identifier: newIdentifier) {
             item, options in
@@ -62,12 +92,21 @@ fileprivate struct GeneralProcessor: ImageProcessor {
     }
 }
 
+/// The default processor. It convert the input data to a valid image.
+/// Images of .PNG, .JPEG and .GIF format are supported.
+/// If an image is given, `DefaultProcessor` will do nothing on it and just return that image.
 public struct DefaultProcessor: ImageProcessor {
     
+    /// A default `DefaultProcessor` could be used across.
     public static let `default` = DefaultProcessor()
     
     public let identifier = ""
+    
+    /// Initialize a `DefaultProcessor`
+    ///
+    /// - returns: An initialized `DefaultProcessor`.
     public init() {}
+    
     public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? {
         switch item {
         case .image(let image):
@@ -78,11 +117,25 @@ public struct DefaultProcessor: ImageProcessor {
     }
 }
 
+/// Processor for making round corner images. Only CG-based images are supported in macOS, 
+/// if a non-CG image passed in, the processor will do nothing.
 public struct RoundCornerImageProcessor: ImageProcessor {
     public let identifier: String
+
+    /// Corner radius will be applied in processing.
     public let cornerRadius: CGFloat
+    
+    /// Target size of output image should be. If `nil`, the image will keep its original size after processing.
     public let targetSize: CGSize?
     
+    /// Initialize a `RoundCornerImageProcessor`
+    ///
+    /// - parameter cornerRadius: Corner radius will be applied in processing.
+    /// - parameter targetSize:   Target size of output image should be. If `nil`, 
+    ///                           the image will keep its original size after processing.
+    ///                           Default is `nil`.
+    ///
+    /// - returns: An initialized `RoundCornerImageProcessor`.
     public init(cornerRadius: CGFloat, targetSize: CGSize? = nil) {
         self.cornerRadius = cornerRadius
         self.targetSize = targetSize
@@ -104,10 +157,18 @@ public struct RoundCornerImageProcessor: ImageProcessor {
     }
 }
 
+/// Processor for resizing images. Only CG-based images are supported in macOS.
 public struct ResizingImageProcessor: ImageProcessor {
     public let identifier: String
+    
+    /// Target size of output image should be.
     public let targetSize: CGSize
     
+    /// Initialize a `ResizingImageProcessor`
+    ///
+    /// - parameter targetSize: Target size of output image should be.
+    ///
+    /// - returns: An initialized `ResizingImageProcessor`.
     public init(targetSize: CGSize) {
         self.targetSize = targetSize
         self.identifier = "com.onevcat.Kingfisher.ResizingImageProcessor(\(targetSize))"
@@ -123,10 +184,19 @@ public struct ResizingImageProcessor: ImageProcessor {
     }
 }
 
+/// Processor for adding blur effect to images. `Accelerate.framework` is used underhood for 
+/// a better performance. A simulated Gaussian blur with specified blur radius will be applied.
 public struct BlurImageProcessor: ImageProcessor {
     public let identifier: String
+    
+    /// Blur radius for the simulated Gaussian blur.
     public let blurRadius: CGFloat
 
+    /// Initialize a `BlurImageProcessor`
+    ///
+    /// - parameter blurRadius: Blur radius for the simulated Gaussian blur.
+    ///
+    /// - returns: An initialized `BlurImageProcessor`.
     public init(blurRadius: CGFloat) {
         self.blurRadius = blurRadius
         self.identifier = "com.onevcat.Kingfisher.BlurImageProcessor(\(blurRadius))"
@@ -143,11 +213,24 @@ public struct BlurImageProcessor: ImageProcessor {
     }
 }
 
+/// Processor for adding an overlay to images. Only CG-based images are supported in macOS.
 public struct OverlayImageProcessor: ImageProcessor {
+    
     public var identifier: String
+    
+    /// Overlay color will be used to overlay the input image.
     public let overlay: Color
+    
+    /// Fraction will be used when overlay the color to image.
     public let fraction: CGFloat
     
+    /// Initialize an `OverlayImageProcessor`
+    ///
+    /// - parameter overlay:  Overlay color will be used to overlay the input image.
+    /// - parameter fraction: Fraction will be used when overlay the color to image. 
+    ///                       From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay.
+    ///
+    /// - returns: An initialized `OverlayImageProcessor`.
     public init(overlay: Color, fraction: CGFloat = 0.5) {
         self.overlay = overlay
         self.fraction = fraction
@@ -164,9 +247,19 @@ public struct OverlayImageProcessor: ImageProcessor {
     }
 }
 
+/// Processor for tint images with color. Only CG-based images are supported.
 public struct TintImageProcessor: ImageProcessor {
+    
     public let identifier: String
+    
+    /// Tint color will be used to tint the input image.
     public let tint: Color
+    
+    /// Initialize a `TintImageProcessor`
+    ///
+    /// - parameter tint: Tint color will be used to tint the input image.
+    ///
+    /// - returns: An initialized `TintImageProcessor`.
     public init(tint: Color) {
         self.tint = tint
         self.identifier = "com.onevcat.Kingfisher.TintImageProcessor(\(tint.hex))"
@@ -182,13 +275,32 @@ public struct TintImageProcessor: ImageProcessor {
     }
 }
 
+/// Processor for applying some color control to images. Only CG-based images are supported.
+/// watchOS is not supported.
 public struct ColorControlsProcessor: ImageProcessor {
+    
     public let identifier: String
+    
+    /// Brightness changing to image.
     public let brightness: CGFloat
+    
+    /// Contrast changing to image.
     public let contrast: CGFloat
+    
+    /// Saturation changing to image.
     public let saturation: CGFloat
+    
+    /// InputEV changing to image.
     public let inputEV: CGFloat
     
+    /// Initialize a `ColorControlsProcessor`
+    ///
+    /// - parameter brightness: Brightness changing to image.
+    /// - parameter contrast:   Contrast changing to image.
+    /// - parameter saturation: Saturation changing to image.
+    /// - parameter inputEV:    InputEV changing to image.
+    ///
+    /// - returns: An initialized `ColorControlsProcessor`
     public init(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) {
         self.brightness = brightness
         self.contrast = contrast
@@ -207,9 +319,16 @@ public struct ColorControlsProcessor: ImageProcessor {
     }
 }
 
+/// Processor for applying black and white effect to images. Only CG-based images are supported.
+/// watchOS is not supported.
 public struct BlackWhiteProcessor: ImageProcessor {
     public let identifier = "com.onevcat.Kingfisher.BlackWhiteProcessor"
+    
+    /// Initialize a `BlackWhiteProcessor`
+    ///
+    /// - returns: An initialized `BlackWhiteProcessor`
     public init() {}
+    
     public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? {
         return ColorControlsProcessor(brightness: 0.0, contrast: 1.0, saturation: 0.0, inputEV: 0.7)
             .process(item: item, options: options)
@@ -217,20 +336,27 @@ public struct BlackWhiteProcessor: ImageProcessor {
 }
 
 infix operator |>: AdditionPrecedence
+
+/// Concatenate two `ImageProcessor`s. `ImageProcessor.appen(another:)` is used internally.
+///
+/// - parameter left:  First processor.
+/// - parameter right: Second processor.
+///
+/// - returns: The concatenated processor.
 public func |>(left: ImageProcessor, right: ImageProcessor) -> ImageProcessor {
     return left.append(another: right)
 }
 
 fileprivate extension Color {
     var hex: String {
-        var r:CGFloat = 0
-        var g:CGFloat = 0
-        var b:CGFloat = 0
-        var a:CGFloat = 0
+        var r: CGFloat = 0
+        var g: CGFloat = 0
+        var b: CGFloat = 0
+        var a: CGFloat = 0
         
         getRed(&r, green: &g, blue: &b, alpha: &a)
         
-        let rgba = Int(r*255) << 24 | Int(g*255) << 16 | Int(b*255) << 8 | Int(a*255)
+        let rgba = Int(r * 255) << 24 | Int(g * 255) << 16 | Int(b * 255) << 8 | Int(a * 255)
         
         return String(format:"#%08x", rgba)
     }

+ 46 - 13
Sources/KingfisherOptionsInfo.swift

@@ -39,34 +39,67 @@ let KingfisherEmptyOptionsInfo = [KingfisherOptionsInfoItem]()
 
 /**
 Items could be added into KingfisherOptionsInfo.
-
-- targetCache: The associated value of this member should be an ImageCache object. Kingfisher will use the specified cache object when handling related operations, including trying to retrieve the cached images and store the downloaded image to it.
-- downloader:  The associated value of this member should be an ImageDownloader object. Kingfisher will use this downloader to download the images.
-- transition:  Member for animation transition when using UIImageView. Kingfisher will use the `ImageTransition` of this enum to animate the image in if it is downloaded from web. The transition will not happen when the image is retrieved from either memory or disk cache by default. If you need to do the transition even when the image being retrieved from cache, set `ForceTransition` as well.
-- downloadPriority: Associated `Float` value will be set as the priority of image download task. The value for it should be between 0.0~1.0. If this option not set, the default value (`NSURLSessionTaskPriorityDefault`) will be used.
-- forceRefresh: If set, `Kingfisher` will ignore the cache and try to fire a download task for the resource.
-- forceTransition: If set, setting the image to an image view will happen with transition even when retrieved from cache. See `Transition` option for more.
-- cacheMemoryOnly: If set, `Kingfisher` will only cache the value in memory but not in disk.
-- onlyFromCache: If set, `Kingfisher` will only try to retrieve the image from cache not from network.
-- backgroundDecode: Decode the image in background thread before using.
-- callbackDispatchQueue: The associated value of this member will be used as the target queue of dispatch callbacks when retrieving images from cache. If not set, `Kingfisher` will use main quese for callbacks.
-- scaleFactor: The associated value of this member will be used as the scale factor when converting retrieved data to an image.
-- preloadAllGIFData: Whether all the GIF data should be preloaded. Default it false, which means following frames will be loaded on need. If true, all the GIF data will be loaded and decoded into memory. This option is mainly used for back compatibility internally. You should not set it directly. `AnimatedImageView` will not preload all data, while a normal image view (`UIImageView` or `NSImageView`) will load all data. Choose to use corresponding image view type instead of setting this option.
 */
 public enum KingfisherOptionsInfoItem {
+    /// The associated value of this member should be an ImageCache object. Kingfisher will use the specified
+    /// cache object when handling related operations, including trying to retrieve the cached images and store
+    /// the downloaded image to it.
     case targetCache(ImageCache?)
+    
+    /// The associated value of this member should be an ImageDownloader object. Kingfisher will use this
+    /// downloader to download the images.
     case downloader(ImageDownloader?)
+    
+    /// Member for animation transition when using UIImageView. Kingfisher will use the `ImageTransition` of
+    /// this enum to animate the image in if it is downloaded from web. The transition will not happen when the
+    /// image is retrieved from either memory or disk cache by default. If you need to do the transition even when
+    /// the image being retrieved from cache, set `ForceTransition` as well.
     case transition(ImageTransition)
+    
+    /// Associated `Float` value will be set as the priority of image download task. The value for it should be
+    /// between 0.0~1.0. If this option not set, the default value (`NSURLSessionTaskPriorityDefault`) will be used.
     case downloadPriority(Float)
+    
+    /// If set, `Kingfisher` will ignore the cache and try to fire a download task for the resource.
     case forceRefresh
+    
+    /// If set, setting the image to an image view will happen with transition even when retrieved from cache.
+    /// See `Transition` option for more.
     case forceTransition
+    
+    ///  If set, `Kingfisher` will only cache the value in memory but not in disk.
     case cacheMemoryOnly
+    
+    /// If set, `Kingfisher` will only try to retrieve the image from cache not from network.
     case onlyFromCache
+    
+    /// Decode the image in background thread before using.
     case backgroundDecode
+    
+    /// The associated value of this member will be used as the target queue of dispatch callbacks when
+    /// retrieving images from cache. If not set, `Kingfisher` will use main quese for callbacks.
     case callbackDispatchQueue(DispatchQueue?)
+    
+    /// The associated value of this member will be used as the scale factor when converting retrieved data to an image.
     case scaleFactor(CGFloat)
+    
+    /// Whether all the GIF data should be preloaded. Default it false, which means following frames will be
+    /// loaded on need. If true, all the GIF data will be loaded and decoded into memory. This option is mainly
+    /// used for back compatibility internally. You should not set it directly. `AnimatedImageView` will not preload
+    /// all data, while a normal image view (`UIImageView` or `NSImageView`) will load all data. Choose to use
+    /// corresponding image view type instead of setting this option.
     case preloadAllGIFData
+    
+    /// The `ImageDownloadRequestModifier` contained will be used to change the request before it being sent.
+    /// This is the last chance you can modify the request. You can modify the request for some customizing purpose,
+    /// such as adding auth token to the header, do basic HTTP auth or something like url mapping. The original request
+    /// will be sent without any modification by default.
     case requestModifier(ImageDownloadRequestModifier)
+    
+    /// Processor for processing when the downloading finishes, a processor will convert the downloaded data to an image
+    /// and/or apply some filter on it. If a cache is connected to the downloader (it happenes when you are using
+    /// KingfisherManager or the image extension methods), the converted image will also be sent to cache as well as the
+    /// image view. `DefaultProcessor.default` will be used by default.
     case processor(ImageProcessor)
 }