lib/jazzy/config.rb in jazzy-0.10.0 vs lib/jazzy/config.rb in jazzy-0.11.0

- old
+ new

@@ -77,10 +77,18 @@ attr_accessor "#{name}_configured" @all_config_attrs ||= [] @all_config_attrs << Attribute.new(name, **opts) end + def self.alias_config_attr(name, forward, **opts) + alias_method name.to_s, forward.to_s + alias_method "#{name}=", "#{forward}=" + alias_method "#{name}_configured", "#{forward}_configured" + alias_method "#{name}_configured=", "#{forward}_configured=" + @all_config_attrs << Attribute.new(name, **opts) + end + class << self attr_reader :all_config_attrs end attr_accessor :base_path @@ -144,15 +152,20 @@ command_line: '--config PATH', description: ['Configuration file (.yaml or .json)', 'Default: .jazzy.yaml in source directory or ancestor'], parse: ->(cf) { expand_path(cf) } - config_attr :xcodebuild_arguments, - command_line: ['-x', '--xcodebuild-arguments arg1,arg2,…argN', Array], - description: 'Arguments to forward to xcodebuild', + config_attr :build_tool_arguments, + command_line: ['-b', '--build-tool-arguments arg1,arg2,…argN', Array], + description: 'Arguments to forward to xcodebuild, swift build, or ' \ + 'sourcekitten.', default: [] + alias_config_attr :xcodebuild_arguments, :build_tool_arguments, + command_line: ['-x', '--xcodebuild-arguments arg1,arg2,…argN', Array], + description: 'Back-compatibility alias for build_tool_arguments.' + config_attr :sourcekitten_sourcefile, command_line: ['-s', '--sourcekitten-sourcefile FILEPATH'], description: 'File generated from sourcekitten output to parse', parse: ->(s) { expand_path(s) } @@ -188,9 +201,23 @@ nil else raise 'jazzy only supports Swift 2.0 or later.' if v.to_f < 2 v end + end + + SWIFT_BUILD_TOOLS = %w[spm xcodebuild].freeze + + config_attr :swift_build_tool, + command_line: "--swift-build-tool #{SWIFT_BUILD_TOOLS.join(' | ')}", + description: 'Control whether Jazzy uses Swift Package Manager or '\ + 'xcodebuild to build the module to be documented. By '\ + 'default it uses xcodebuild if there is a .xcodeproj '\ + 'file in the source directory.', + parse: ->(tool) do + return tool.to_sym if SWIFT_BUILD_TOOLS.include?(tool) + raise "Unsupported swift_build_tool #{tool}, "\ + "supported values: #{SWIFT_BUILD_TOOLS.join(', ')}" end # ──────── Metadata ──────── config_attr :author_name,