lib/jazzy/podspec_documenter.rb in jazzy-0.9.6 vs lib/jazzy/podspec_documenter.rb in jazzy-0.10.0
- old
+ new
@@ -16,21 +16,20 @@
installation_root = Pathname(Dir.mktmpdir(['jazzy', podspec.name]))
installation_root.rmtree if installation_root.exist?
Pod::Config.instance.with_changes(installation_root: installation_root,
verbose: false) do
sandbox = Pod::Sandbox.new(Pod::Config.instance.sandbox_root)
- installer = Pod::Installer.new(sandbox, podfile)
+ swift_version = compiler_swift_version(config.swift_version)
+ installer = Pod::Installer.new(sandbox, podfile(swift_version))
installer.install!
stdout = Dir.chdir(sandbox.root) do
targets = installer.pod_targets
.select { |pt| pt.pod_name == podspec.root.name }
.map(&:label)
targets.map do |t|
args = %W[doc --module-name #{podspec.module_name} -- -target #{t}]
- swift_version = compiler_swift_version(config.swift_version)
- args << "SWIFT_VERSION=#{swift_version}"
SourceKitten.run_sourcekitten(args)
end
end
stdout.reduce([]) { |a, s| a + JSON.parse(s) }.to_json
end
@@ -105,38 +104,49 @@
LONG_SWIFT_VERSIONS = ['4.2'].freeze
# Go from a full Swift version like 4.2.1 to
# something valid for SWIFT_VERSION.
def compiler_swift_version(user_version)
- return LATEST_SWIFT_VERSION unless user_version
+ unless user_version
+ return podspec_swift_version || LATEST_SWIFT_VERSION
+ end
LONG_SWIFT_VERSIONS.select do |version|
user_version.start_with?(version)
end.last || "#{user_version[0]}.0"
end
+ def podspec_swift_version
+ # `swift_versions` exists from CocoaPods 1.7
+ if podspec.respond_to?('swift_versions')
+ podspec.swift_versions.max
+ else
+ podspec.swift_version
+ end
+ end
+
# @!group SourceKitten output helper methods
def pod_path
if podspec.defined_in_file
podspec.defined_in_file.parent
else
config.source_directory
end
end
- def podfile
+ # rubocop:disable Metrics/MethodLength
+ def podfile(swift_version)
podspec = @podspec
path = pod_path
@podfile ||= Pod::Podfile.new do
install! 'cocoapods',
integrate_targets: false,
deterministic_uuids: false
[podspec, *podspec.recursive_subspecs].each do |ss|
- # test_specification exists from CocoaPods 1.3.0
- next if ss.respond_to?('test_specification') && ss.test_specification
+ next if ss.test_specification
ss.available_platforms.each do |p|
# Travis builds take too long when building docs for all available
# platforms for the Moya integration spec, so we just document OSX.
# TODO: remove once jazzy is fast enough.
@@ -145,12 +155,14 @@
end
target("Jazzy-#{ss.name.gsub('/', '__')}-#{p.name}") do
use_frameworks!
platform p.name, p.deployment_target
pod ss.name, path: path.realpath.to_s
+ current_target_definition.swift_version = swift_version
end
end
end
end
end
+ # rubocop:enable Metrics/MethodLength
end
end