From fde4f53f426a65fa611023b449a8ad9d59664345 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Thu, 16 Apr 2020 18:54:08 -0500 Subject: [PATCH] Documentation comments --- .../Timeline/Cell/NSAttributedString+NetNewsWire.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift b/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift index bad680a91..afd4fada9 100644 --- a/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift +++ b/Mac/MainWindow/Timeline/Cell/NSAttributedString+NetNewsWire.swift @@ -28,6 +28,14 @@ private let monoSpaceTrait = UIFontDescriptor.SymbolicTraits.traitMonoSpace extension NSAttributedString { + /// Adds a font and color to an attributed string. + /// + /// Additionally converts super-/subscript runs to super-/subscripted font variants + /// and converts bold text to heavy if the base font is semibold. + /// + /// - Parameters: + /// - baseFont: The font to add. + /// - color: The color to add. func adding(font baseFont: Font, color: Color? = nil) -> NSAttributedString { let mutable = self.mutableCopy() as! NSMutableAttributedString let fullRange = NSRange(location: 0, length: mutable.length) @@ -116,6 +124,7 @@ extension NSAttributedString { return mutable.copy() as! NSAttributedString } + /// Creates an attributed string from HTML. convenience init(html: String) { let data = html.data(using: .utf8)! let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [.characterEncoding: String.Encoding.utf8.rawValue, .documentType: NSAttributedString.DocumentType.html]