lib/jazzy/podspec_documenter.rb in jazzy-0.13.7 vs lib/jazzy/podspec_documenter.rb in jazzy-0.14.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'tmpdir'
require 'json'
module Jazzy
# rubocop:disable Metrics/ClassLength
@@ -20,12 +22,12 @@
sandbox = Pod::Sandbox.new(Pod::Config.instance.sandbox_root)
installer = Pod::Installer.new(sandbox, podfile(config))
installer.install!
stdout = Dir.chdir(sandbox.root) do
targets = installer.pod_targets
- .select { |pt| pt.pod_name == podspec.root.name }
- .map(&:label)
+ .select { |pt| pt.pod_name == podspec.root.name }
+ .map(&:label)
targets.map do |t|
args = %W[doc --module-name #{podspec.module_name} -- -target #{t}]
SourceKitten.run_sourcekitten(args)
end
@@ -40,12 +42,10 @@
require 'cocoapods'
Pod::Specification.from_file(podspec_path)
end
end
- # rubocop:disable Metrics/CyclomaticComplexity
- # rubocop:disable Metrics/PerceivedComplexity
# rubocop:disable Metrics/MethodLength
def self.apply_config_defaults(podspec, config)
return unless podspec
unless config.author_name_configured
@@ -62,22 +62,20 @@
end
unless config.version_configured
config.version = podspec.version.to_s
config.version_configured = true
end
- unless config.github_file_prefix_configured
- config.github_file_prefix = github_file_prefix(podspec)
- config.github_file_prefix_configured = true
+ unless config.source_host_files_url_configured
+ config.source_host_files_url = github_file_prefix(podspec)
+ config.source_host_files_url_configured = true
end
unless config.swift_version_configured
trunk_swift_build = podspec.attributes_hash['pushed_with_swift_version']
config.swift_version = trunk_swift_build if trunk_swift_build
config.swift_version_configured = true
end
end
- # rubocop:enable Metrics/CyclomaticComplexity
- # rubocop:enable Metrics/PerceivedComplexity
# rubocop:enable Metrics/MethodLength
private
# @!group Config helper methods
@@ -92,21 +90,21 @@
private_class_method :author_name
def self.github_file_prefix(podspec)
return unless podspec.source[:url] =~ %r{github.com[:/]+(.+)/(.+)}
+
org, repo = Regexp.last_match
- return unless org && repo
- repo.sub!(/\.git$/, '')
return unless rev = podspec.source[:tag] || podspec.source[:commit]
- "https://github.com/#{org}/#{repo}/blob/#{rev}"
+
+ "https://github.com/#{org}/#{repo.sub(/\.git$/, '')}/blob/#{rev}"
end
private_class_method :github_file_prefix
# Latest valid value for SWIFT_VERSION.
- LATEST_SWIFT_VERSION = '5'.freeze
+ LATEST_SWIFT_VERSION = '5'
# All valid values for SWIFT_VERSION that are longer
# than a major version number. Ordered ascending.
LONG_SWIFT_VERSIONS = ['4.2'].freeze
@@ -160,13 +158,12 @@
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.
- if ENV['JAZZY_INTEGRATION_SPECS']
- next if p.name != :osx
- end
+ next if ENV['JAZZY_INTEGRATION_SPECS'] && p.name != :osx
+
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
@@ -175,6 +172,7 @@
end
end
end
# rubocop:enable Metrics/MethodLength
end
+ # rubocop:enable Metrics/ClassLength
end