lib/jazzy/symbol_graph.rb in jazzy-0.13.7 vs lib/jazzy/symbol_graph.rb in jazzy-0.14.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'set' require 'jazzy/symbol_graph/graph' require 'jazzy/symbol_graph/constraint' require 'jazzy/symbol_graph/symbol' require 'jazzy/symbol_graph/relationship' @@ -35,41 +37,39 @@ end.to_json end end # Figure out the args to pass to symbolgraph-extract - # rubocop:disable Metrics/CyclomaticComplexity def self.arguments(config, output_path) if config.module_name.empty? raise 'error: `--swift-build-tool symbolgraph` requires `--module`.' end user_args = config.build_tool_arguments.join - if user_args =~ /--(?:module-name|minimum-access-level|output-dir)/ + if user_args =~ /-(?:module-name|minimum-access-level|output-dir)/ raise 'error: `--build-tool-arguments` for '\ - "`--swift-build-tool symbolgraph` can't use `--module`, "\ - '`--minimum-access-level`, or `--output-dir`.' + "`--swift-build-tool symbolgraph` can't use `-module`, "\ + '`-minimum-access-level`, or `-output-dir`.' end # Default set args = [ - "--module-name=#{config.module_name}", - '--minimum-access-level=private', - "--output-dir=#{output_path}", - '--skip-synthesized-members', + '-module-name', config.module_name, + '-minimum-access-level', 'private', + '-output-dir', output_path, + '-skip-synthesized-members' ] # Things user can override - args.append("--sdk=#{sdk(config)}") unless user_args =~ /--sdk/ - args.append("--target=#{target}") unless user_args =~ /--target/ - args.append("-F=#{config.source_directory}") unless user_args =~ /-F(?!s)/ - args.append("-I=#{config.source_directory}") unless user_args =~ /-I/ + args += ['-sdk', sdk(config)] unless user_args =~ /-sdk/ + args += ['-target', target] unless user_args =~ /-target/ + args += ['-F', config.source_directory.to_s] unless user_args =~ /-F(?!s)/ + args += ['-I', config.source_directory.to_s] unless user_args =~ /-I/ args + config.build_tool_arguments end - # rubocop:enable Metrics/CyclomaticComplexity # Get the SDK path. On !darwin this just isn't needed. def self.sdk(config) `xcrun --show-sdk-path --sdk #{config.sdk}`.chomp end @@ -85,11 +85,11 @@ # provide a name - at least conforming external types to local # protocols. def self.demangle(usr) args = %w[demangle -simplified -compact].append(usr.sub(/^s:/, 's')) output, = Executable.execute_command('swift', args, true) - return output.chomp - rescue + output.chomp + rescue StandardError usr end end end