Skip to content

Commit

Permalink
Merge pull request #601 from tomaz/swift-3
Browse files Browse the repository at this point in the history
Great! Tested project and unit tests and both build and run correctly on Xcode 8.2.
  • Loading branch information
tomaz committed Dec 22, 2016
2 parents 4527fc4 + 297a883 commit 8bc453d
Show file tree
Hide file tree
Showing 390 changed files with 15,280 additions and 4,270 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: objective-c

osx_image: xcode7.1
osx_image: xcode8.2

script:
- set -o pipefail
- xcodebuild -version
- xcodebuild -showsdks
- xctool test -scheme appledoc

- xcodebuild test -scheme appledoc
374 changes: 214 additions & 160 deletions appledoc.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion appledoc.xcodeproj/xcshareddata/xcschemes/tests.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions appledoc/Application/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Application {
}
}

private func initializeApplication() throws {
fileprivate func initializeApplication() throws {
// Parse command line. Bail out in case of errors
try commandLineParser.run()

Expand All @@ -45,7 +45,7 @@ class Application {
lazy var commandLineParser: CommandLineParser = {
let result = CommandLineParser()
result.registerOptions(self.options)
result.registerSettings(self.settings)
result.register(self.settings)
return result
}()

Expand Down
24 changes: 12 additions & 12 deletions appledoc/Application/CommandLineParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class CommandLineParser: GBCommandLineParser, Task {

// MARK: - Overriden functions

override func registerOptions(options: GBOptionsHelper!) {
override func registerOptions(_ options: GBOptionsHelper!) {
self.options = options as! Options
super.registerOptions(options)
}

override func registerSettings(settings: GBSettings!) {
override func register(_ settings: GBSettings!) {
self.settings = settings as! Settings
super.registerSettings(settings)
super.register(settings)
}

// MARK: - Task
Expand All @@ -35,7 +35,7 @@ class CommandLineParser: GBCommandLineParser, Task {
// Parse command line. If anything fails, print help and exit.
if !parseOptionsUsingDefaultArguments() {
options.printHelp()
throw Result.Cancel
throw Result.cancel
}

// Inject global and project settings; we can only do this after we've read the command line.
Expand All @@ -46,36 +46,36 @@ class CommandLineParser: GBCommandLineParser, Task {
printValuesIfNeeded()

if printVersion() {
throw Result.Cancel
throw Result.cancel
}

if printHelp() {
throw Result.Cancel
throw Result.cancel
}

if printMissingArguments() {
throw Result.Cancel
throw Result.cancel
}
}

// MARK: - Helper functions

private func printValuesIfNeeded() {
fileprivate func printValuesIfNeeded() {
// If values printout is instructed, do so, then continue.
if settings.printValues {
options.printValuesFromSettings(settings)
options.printValues(from: settings)
}
}

private func printVersion() -> Bool {
fileprivate func printVersion() -> Bool {
// If version printout is instructed, exit (we already printed it).
if settings.printVersion {
return true
}
return false
}

private func printHelp() -> Bool {
fileprivate func printHelp() -> Bool {
// If help printout is instructed, do so and exit.
if settings.printHelp {
options.printHelp()
Expand All @@ -84,7 +84,7 @@ class CommandLineParser: GBCommandLineParser, Task {
return false
}

private func printMissingArguments() -> Bool {
fileprivate func printMissingArguments() -> Bool {
// If there's no input path, print error exit.
if arguments.count == 0 {
print("At least one input path is required!\n")
Expand Down
4 changes: 2 additions & 2 deletions appledoc/Application/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class Options: GBOptionsHelper {

extension Options {

private func register() {
fileprivate func register() {
// Registers all settings for command line parser - this is where
SwiftyOptions.sharedInstance.register(self) {
section("OPTIONS") {
option(nil, long: settingsGeneralValuesKey, description: "Print option values and sources")
option(nil, long: settingsGeneralVersionKey, description: "Print version and exit")
option(nil, long: settingsGeneralPrintHelpKey, description: "Print this help and exit")
option(nil, long: settingsGeneralLoggingVerbosityKey, description: "Logging verbosity [0-5]", flags: .RequiredValue)
option(nil, long: settingsGeneralLoggingVerbosityKey, description: "Logging verbosity [0-5]", flags: GBOptionFlags())
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions appledoc/Application/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The main responsibility of this class is to define and provide settings values f
class Settings: GBSettings {

override init() {
Settings.factoryDefaults.initializeFactoryDefaults()
Settings.factoryDefaults?.initializeFactoryDefaults()
super.init(name: "Settings", parent: Settings.projectDefaults)
}

Expand All @@ -26,18 +26,18 @@ class Settings: GBSettings {
// TODO: Attempt to load from root of --templates option.

// Attempt to load from ~/Library/Application Support/appledoc/appledoc.plist
if let applicationSupportPath = NSSearchPathForDirectoriesInDomains(.ApplicationSupportDirectory, .UserDomainMask, true).first {
if let applicationSupportPath = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first {
let appledocSupportPath = applicationSupportPath.stringByAppendingPathComponent("Appledoc")
let path = Settings.settingsFileNameForPath(appledocSupportPath)
if Settings.globalDefaults.loadSettingsFromFile(path) {
if ((Settings.globalDefaults?.loadSettingsFromFile(path)) != nil) {
gdebug("Using global setings at \(path)")
return
}
}

// Attempt to load from ~/.appledoc.plist
let userRootPath = Settings.settingsFileNameForPath("~/")
if Settings.globalDefaults.loadSettingsFromFile(userRootPath) {
if (Settings.globalDefaults?.loadSettingsFromFile(userRootPath))! {
gdebug("Using global settings at \(userRootPath)")
return
}
Expand All @@ -48,7 +48,7 @@ class Settings: GBSettings {
for path in self.arguments {
let inputPath = path as! String
let settingsPath = Settings.settingsFileNameForPath(inputPath)
if Settings.projectDefaults.loadSettingsFromFile(settingsPath) {
if (Settings.projectDefaults?.loadSettingsFromFile(settingsPath))! {
gdebug("Using project settings at \(settingsPath)")
return
}
Expand All @@ -61,25 +61,25 @@ class Settings: GBSettings {

extension Settings {

private func initializeFactoryDefaults() {
fileprivate func initializeFactoryDefaults() {
loggingVerbosity = 3 // Use info logging verbosity by default
}

private static let factoryDefaults = Settings(name: "Factory Defaults", parent: nil)
fileprivate static let factoryDefaults = Settings(name: "Factory Defaults", parent: nil)

}

// MARK: - Global and project settings.

extension Settings {

private func loadSettingsFromFile(path: String) -> Bool {
fileprivate func loadSettingsFromFile(_ path: String) -> Bool {
// This function is just convenience wrapper over loadSettingsFromPlist - it converts try/catch into Bool result (we don't really care why loading failed outside the function, just interested if it succedded or not).
let standardizedPath = path.stringByStandardizingPath

// Load settings from given file.
do {
try loadSettingsFromPlist(standardizedPath)
try load(fromPlist: standardizedPath)
return true
} catch {
gwarn("Failed loading settings from \(path)!")
Expand All @@ -88,12 +88,12 @@ extension Settings {
return false
}

private class func settingsFileNameForPath(path: String) -> String {
fileprivate class func settingsFileNameForPath(_ path: String) -> String {
return path.stringByAppendingPathComponent("appledoc.plist")
}

private static let globalDefaults = Settings(name: "Global Defaults", parent: Settings.factoryDefaults)
private static let projectDefaults = Settings(name: "Project Defaults", parent: Settings.globalDefaults)
fileprivate static let globalDefaults = Settings(name: "Global Defaults", parent: Settings.factoryDefaults)
fileprivate static let projectDefaults = Settings(name: "Project Defaults", parent: Settings.globalDefaults)

}

Expand All @@ -102,22 +102,22 @@ extension Settings {
extension Settings {

var loggingVerbosity: Int {
get { return integerForKey(settingsGeneralLoggingVerbosityKey) }
get { return integer(forKey: settingsGeneralLoggingVerbosityKey) }
set { setInteger(newValue, forKey: settingsGeneralLoggingVerbosityKey) }
}

var printValues: Bool {
get { return boolForKey(settingsGeneralValuesKey) }
get { return bool(forKey: settingsGeneralValuesKey) }
set { setBool(newValue, forKey: settingsGeneralValuesKey) }
}

var printVersion: Bool {
get { return boolForKey(settingsGeneralVersionKey) }
get { return bool(forKey: settingsGeneralVersionKey) }
set { setBool(newValue, forKey: settingsGeneralVersionKey) }
}

var printHelp: Bool {
get { return boolForKey(settingsGeneralPrintHelpKey) }
get { return bool(forKey: settingsGeneralPrintHelpKey) }
set { setBool(newValue, forKey: settingsGeneralPrintHelpKey) }
}

Expand Down
6 changes: 3 additions & 3 deletions appledoc/Common/Extensions/NSFileManager+Appledoc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

import Foundation

extension NSFileManager {
extension FileManager {

/** Determines whether the given path exists and represents a directory.
@param path Path to examine.
@return Returns true if path exists and is directory, false otherwise.
*/
func isPathDirectory(path: String) -> Bool {
func isPathDirectory(_ path: String) -> Bool {
var isDirectory = ObjCBool(false)

if !fileExistsAtPath(path, isDirectory: &isDirectory) {
if !fileExists(atPath: path, isDirectory: &isDirectory) {
return false
}

Expand Down
16 changes: 8 additions & 8 deletions appledoc/Common/Extensions/String+Appledoc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import Foundation

extension String {

func stringByAppendingPathComponent(path: String) -> String {
return (self as NSString).stringByAppendingPathComponent(path)
func stringByAppendingPathComponent(_ path: String) -> String {
return (self as NSString).appendingPathComponent(path)
}

func stringByAppendingPathExtension(ext: String) -> String? {
return (self as NSString).stringByAppendingPathExtension(ext)
func stringByAppendingPathExtension(_ ext: String) -> String? {
return (self as NSString).appendingPathExtension(ext)
}

var lastPathComponent: String {
Expand All @@ -24,19 +24,19 @@ extension String {
}

var stringByStandardizingPath: String {
return (self as NSString).stringByStandardizingPath
return (self as NSString).standardizingPath
}

var stringByDeletingLastPathComponent: String {
return (self as NSString).stringByDeletingLastPathComponent
return (self as NSString).deletingLastPathComponent
}

var stringByDeletingPathExtension: String {
return (self as NSString).stringByDeletingPathExtension
return (self as NSString).deletingPathExtension
}

var pathComponents: [String] {
return (self as NSString).pathComponents
}

}
}
14 changes: 7 additions & 7 deletions appledoc/Common/ThirdParty/GBCli/SwiftyOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import Foundation
This class allows to use convenience functions for options registrations. To use, you need to pass `Options` instance on which to operate to `register` function and then you can call convenience functions for actual registrations inside the block. Using convenience functions outside this block will result in runtime exceptions!
*/
public class SwiftyOptions {
open class SwiftyOptions {

/// The one and only `OptionsRegistrator` instance
public static let sharedInstance = SwiftyOptions()
open static let sharedInstance = SwiftyOptions()

/** Registers options using helper methods.
It's required to wrap all convenience registration method calls the block!
*/
public func register(options: GBOptionsHelper, block: () -> Void) {
open func register(_ options: GBOptionsHelper, block: () -> Void) {
self.options = options
block()
self.options = nil
}

/// Current `Options` instance on which registration functions will operate.
private(set) internal var options: GBOptionsHelper!
fileprivate(set) internal var options: GBOptionsHelper!
}

/** Starts options section with given separator.
Expand All @@ -37,7 +37,7 @@ Note this method registers section to last instance of the `Options` class, assi
@param separator The name of separator to use on help output.
@param block Block inside which to register all options or groups of this section.
*/
public func section(separator: String, block: () -> Void) {
public func section(_ separator: String, block: () -> Void) {
SwiftyOptions.sharedInstance.options.registerSeparator(separator)
block()
}
Expand All @@ -51,7 +51,7 @@ Register all options inside the given block.
@param flags Optional group flags - whether there's a value attached etc. Defaults to `.NoValue`.
@param block Block inside which to register all options of this group.
*/
public func group(name: String, description: String, flags: GBOptionFlags = .NoValue, block: () -> Void) {
public func group(_ name: String, description: String, flags: GBOptionFlags = .noValue, block: @escaping () -> Void) {
SwiftyOptions.sharedInstance.options.registerGroup(name, description: description, flags: flags) { options in
block()
}
Expand All @@ -64,7 +64,7 @@ public func group(name: String, description: String, flags: GBOptionFlags = .NoV
@param description The description of the option as shown on help output.
@param flags Optional option flags - whether there's value required or not etc. Defaults to `.NoValue`
*/
public func option(short: Character?, long: String, description: String, flags: GBOptionFlags = .NoValue) {
public func option(_ short: Character?, long: String, description: String, flags: GBOptionFlags = .noValue) {
// Convert Character to Int8. Not sure this is the best approach...
var shorty = Int8(0)
if let short = short {
Expand Down
10 changes: 9 additions & 1 deletion appledoc/Common/ThirdParty/Nimble/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.DS_Store
xcuserdata/
**/xcuserdata/*
**/*.xccheckout
**/*.xcscmblueprint
build/
.idea
DerivedData/
Expand All @@ -11,3 +13,9 @@ Nimble.framework.zip
# Carthage/Checkouts

Carthage/Build

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/
1 change: 1 addition & 0 deletions appledoc/Common/ThirdParty/Nimble/.swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
Loading

0 comments on commit 8bc453d

Please sign in to comment.