0001    //
0002    //  SwiftDocs.swift
0003    //  SourceKitten
0004    //
0005    //  Created by JP Simard on 2015-01-03.
0006    //  Copyright (c) 2015 SourceKitten. All rights reserved.
0007    //
0008    
0009    import Foundation
0010    #if SWIFT_PACKAGE
0011    import SourceKit
0012    #endif
0013    
0014    /// Represents docs for a Swift file.
0015    public struct SwiftDocs
Module.swift:29
                return SwiftDocs(file: file, arguments: compilerArguments)
Module.swift:21
    public var docs: [SwiftDocs] {
SwiftDocs.swift:71
extension SwiftDocs: CustomStringConvertible {
{ 0016 /// Documented File. 0017 public let file
SwiftDocs.swift:51
        self.file = file
SwiftDocs.swift:74
        return toJSON(toAnyObject([file.path ?? "<No File>": docsDictionary]))
: File 0018 0019 /// Docs information as an [String: SourceKitRepresentable]. 0020 public let docsDictionary
SwiftDocs.swift:65
        docsDictionary = dictionary
SwiftDocs.swift:74
        return toJSON(toAnyObject([file.path ?? "<No File>": docsDictionary]))
: [String: SourceKitRepresentable] 0021 0022 /** 0023 Create docs for the specified Swift file and compiler arguments. 0024 0025 - parameter file: Swift file to document. 0026 - parameter arguments: compiler arguments to pass to SourceKit. 0027 */ 0028 public init
Module.swift:29
                return SwiftDocs(file: file, arguments: compilerArguments)
?(file: File, arguments: [String]) { 0029 do { 0030 self.init( 0031 file: file, 0032 dictionary: try Request.EditorOpen(file).failableSend(), 0033 cursorInfoRequest: Request.cursorInfoRequestForFilePath(file.path, arguments: arguments) 0034 ) 0035 } catch let error as Request.Error { 0036 fputs(error.description, stderr) 0037 return nil 0038 } catch { 0039 return nil 0040 } 0041 } 0042 0043 /** 0044 Create docs for the specified Swift file, editor.open SourceKit response and cursor info request. 0045 0046 - parameter file: Swift file to document. 0047 - parameter dictionary: editor.open response from SourceKit. 0048 - parameter cursorInfoRequest: SourceKit dictionary to use to send cursorinfo request. 0049 */ 0050 public init
SwiftDocs.swift:30
            self.init(
(file: File, dictionary: [String: SourceKitRepresentable], cursorInfoRequest: sourcekitd_object_t?) { 0051 self.file = file 0052 var dictionary = dictionary 0053 let syntaxMapData = dictionary.removeValueForKey(SwiftDocKey.SyntaxMap.rawValue) as! [SourceKitRepresentable] 0054 let syntaxMap = SyntaxMap(data: syntaxMapData) 0055 dictionary = file.processDictionary(dictionary, cursorInfoRequest: cursorInfoRequest, syntaxMap: syntaxMap) 0056 if let cursorInfoRequest = cursorInfoRequest { 0057 let documentedTokenOffsets = file.contents.documentedTokenOffsets(syntaxMap) 0058 dictionary = file.furtherProcessDictionary( 0059 dictionary, 0060 documentedTokenOffsets: documentedTokenOffsets, 0061 cursorInfoRequest: cursorInfoRequest, 0062 syntaxMap: syntaxMap 0063 ) 0064 } 0065 docsDictionary = dictionary 0066 } 0067 } 0068 0069 // MARK: CustomStringConvertible 0070 0071 extension SwiftDocs: CustomStringConvertible { 0072 /// A textual JSON representation of `SwiftDocs`. 0073 public var description: String { 0074 return toJSON(toAnyObject([file.path ?? "<No File>": docsDictionary])) 0075 } 0076 } 0077