jazzy 0.13.7 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/Tests.yml +6 -6
  3. data/.rubocop.yml +155 -24
  4. data/CHANGELOG.md +91 -0
  5. data/CONTRIBUTING.md +1 -1
  6. data/Dangerfile +11 -8
  7. data/Gemfile +3 -1
  8. data/Gemfile.lock +85 -64
  9. data/ObjectiveC.md +208 -0
  10. data/README.md +63 -33
  11. data/Rakefile +18 -15
  12. data/bin/jazzy +3 -2
  13. data/bin/sourcekitten +0 -0
  14. data/jazzy.gemspec +9 -6
  15. data/lib/jazzy/config.rb +135 -69
  16. data/lib/jazzy/doc.rb +3 -1
  17. data/lib/jazzy/doc_builder.rb +72 -83
  18. data/lib/jazzy/docset_builder.rb +3 -1
  19. data/lib/jazzy/documentation_generator.rb +6 -2
  20. data/lib/jazzy/executable.rb +3 -0
  21. data/lib/jazzy/extensions/bitbucket/img/bitbucket.svg +11 -0
  22. data/lib/jazzy/{themes/apple/assets → extensions/github}/img/gh.png +0 -0
  23. data/lib/jazzy/extensions/gitlab/img/gitlab.svg +23 -0
  24. data/lib/jazzy/gem_version.rb +3 -1
  25. data/lib/jazzy/highlighter.rb +5 -3
  26. data/lib/jazzy/jazzy_markdown.rb +75 -32
  27. data/lib/jazzy/podspec_documenter.rb +14 -16
  28. data/lib/jazzy/search_builder.rb +5 -6
  29. data/lib/jazzy/source_declaration/access_control_level.rb +7 -5
  30. data/lib/jazzy/source_declaration/type.rb +29 -3
  31. data/lib/jazzy/source_declaration.rb +22 -5
  32. data/lib/jazzy/source_document.rb +8 -5
  33. data/lib/jazzy/source_host.rb +111 -0
  34. data/lib/jazzy/source_mark.rb +8 -6
  35. data/lib/jazzy/source_module.rb +6 -6
  36. data/lib/jazzy/sourcekitten.rb +155 -81
  37. data/lib/jazzy/stats.rb +14 -3
  38. data/lib/jazzy/symbol_graph/constraint.rb +5 -1
  39. data/lib/jazzy/symbol_graph/ext_node.rb +3 -1
  40. data/lib/jazzy/symbol_graph/graph.rb +19 -12
  41. data/lib/jazzy/symbol_graph/relationship.rb +9 -0
  42. data/lib/jazzy/symbol_graph/sym_node.rb +25 -7
  43. data/lib/jazzy/symbol_graph/symbol.rb +54 -25
  44. data/lib/jazzy/symbol_graph.rb +43 -32
  45. data/lib/jazzy/themes/apple/assets/css/highlight.css.scss +63 -59
  46. data/lib/jazzy/themes/apple/assets/css/jazzy.css.scss +5 -1
  47. data/lib/jazzy/themes/apple/assets/js/jazzy.js +4 -0
  48. data/lib/jazzy/themes/apple/assets/js/jazzy.search.js +4 -0
  49. data/lib/jazzy/themes/apple/templates/doc.mustache +4 -5
  50. data/lib/jazzy/themes/apple/templates/footer.mustache +1 -1
  51. data/lib/jazzy/themes/apple/templates/header.mustache +6 -6
  52. data/lib/jazzy/themes/apple/templates/task.mustache +6 -11
  53. data/lib/jazzy/themes/fullwidth/assets/css/highlight.css.scss +63 -59
  54. data/lib/jazzy/themes/fullwidth/assets/css/jazzy.css.scss +6 -2
  55. data/lib/jazzy/themes/fullwidth/assets/js/jazzy.js +4 -0
  56. data/lib/jazzy/themes/fullwidth/assets/js/jazzy.search.js +4 -0
  57. data/lib/jazzy/themes/fullwidth/templates/doc.mustache +4 -5
  58. data/lib/jazzy/themes/fullwidth/templates/footer.mustache +1 -1
  59. data/lib/jazzy/themes/fullwidth/templates/header.mustache +8 -8
  60. data/lib/jazzy/themes/fullwidth/templates/task.mustache +6 -11
  61. data/lib/jazzy/themes/jony/assets/css/highlight.css.scss +63 -59
  62. data/lib/jazzy/themes/jony/assets/css/jazzy.css.scss +5 -1
  63. data/lib/jazzy/themes/jony/assets/js/jazzy.js +4 -0
  64. data/lib/jazzy/themes/jony/templates/doc.mustache +4 -5
  65. data/lib/jazzy/themes/jony/templates/footer.mustache +1 -1
  66. data/lib/jazzy/themes/jony/templates/header.mustache +6 -6
  67. data/lib/jazzy/themes/jony/templates/task.mustache +6 -11
  68. data/lib/jazzy.rb +2 -0
  69. data/spec/integration_spec.rb +46 -42
  70. data/spec/spec_helper/pre_flight.rb +2 -0
  71. data/spec/spec_helper.rb +3 -1
  72. metadata +32 -16
  73. data/lib/jazzy/themes/fullwidth/assets/img/gh.png +0 -0
  74. data/lib/jazzy/themes/jony/assets/img/gh.png +0 -0
  75. data/spec/sourcekitten_spec.rb +0 -6
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # rubocop:disable Metrics/ClassLength
2
4
  module Jazzy
3
5
  module SymbolGraph
@@ -63,21 +65,26 @@ module Jazzy
63
65
  # Increasingly desparate ways to find the name of the symbol
64
66
  # at the target end of a relationship
65
67
  def rel_target_name(rel, target_node)
66
- (target_node && target_node.symbol.name) ||
68
+ target_node&.symbol&.name ||
67
69
  rel.target_fallback ||
68
70
  Jazzy::SymbolGraph.demangle(rel.target_usr)
69
71
  end
70
72
 
71
73
  # Same for the source end. Less help from the tool here
72
74
  def rel_source_name(rel, source_node)
73
- (source_node && source_node.qualified_name) ||
75
+ source_node&.qualified_name ||
74
76
  Jazzy::SymbolGraph.demangle(rel.source_usr)
75
77
  end
76
78
 
77
79
  # Protocol conformance is redundant if it's unconditional
78
80
  # and already expressed in the type's declaration.
81
+ #
82
+ # Skip implementation-detail conformances.
79
83
  def redundant_conformance?(rel, type, protocol)
80
- type && rel.constraints.empty? && type.conformance?(protocol)
84
+ return false unless type
85
+
86
+ (rel.constraints.empty? && type.conformance?(protocol)) ||
87
+ (type.actor? && rel.actor_protocol?)
81
88
  end
82
89
 
83
90
  # source is a member/protocol requirement of target
@@ -86,11 +93,11 @@ module Jazzy
86
93
 
87
94
  source.protocol_requirement = rel.protocol_requirement?
88
95
  constraints =
89
- ExtConstraints.new(target && target.constraints,
96
+ ExtConstraints.new(target&.constraints,
90
97
  source.unique_context_constraints(target))
91
98
 
92
99
  # Add to its parent or invent an extension
93
- unless target && target.try_add_child(source, constraints.ext)
100
+ unless target&.try_add_child(source, constraints.ext)
94
101
  add_ext_member(rel.target_usr, source, constraints)
95
102
  end
96
103
  end
@@ -101,7 +108,7 @@ module Jazzy
101
108
 
102
109
  return if redundant_conformance?(rel, source, protocol_name)
103
110
 
104
- type_constraints = (source && source.constraints) || []
111
+ type_constraints = source&.constraints || []
105
112
  constraints =
106
113
  ExtConstraints.new(type_constraints,
107
114
  rel.constraints - type_constraints)
@@ -122,7 +129,7 @@ module Jazzy
122
129
  target_parent.is_a?(SymNode)
123
130
  # Could probably figure this out with demangle, but...
124
131
  warn "Can't resolve membership of default implementation "\
125
- "#{source.symbol.usr}."
132
+ "#{source.symbol.usr}."
126
133
  source.unlisted = true
127
134
  return
128
135
  end
@@ -174,14 +181,14 @@ module Jazzy
174
181
 
175
182
  root_symbol_nodes =
176
183
  symbol_nodes.values
177
- .select(&:top_level_decl?)
178
- .sort
179
- .map(&:to_sourcekit)
184
+ .select(&:top_level_decl?)
185
+ .sort
186
+ .map(&:to_sourcekit)
180
187
 
181
188
  root_ext_nodes =
182
189
  ext_nodes.values
183
- .sort
184
- .map { |n| n.to_sourcekit(module_name) }
190
+ .sort
191
+ .map { |n| n.to_sourcekit(module_name) }
185
192
  {
186
193
  'key.diagnostic_stage' => 'parse',
187
194
  'key.substructure' => root_symbol_nodes + root_ext_nodes,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jazzy
2
4
  module SymbolGraph
3
5
  # A Relationship is a tidied-up SymbolGraph JSON object
@@ -20,11 +22,18 @@ module Jazzy
20
22
  kind == :defaultImplementationOf
21
23
  end
22
24
 
25
+ # Protocol conformances added by compiler to actor decls that
26
+ # users aren't interested in.
27
+ def actor_protocol?
28
+ %w[Actor Sendable].include?(target_fallback)
29
+ end
30
+
23
31
  def initialize(hash)
24
32
  kind = hash[:kind]
25
33
  unless KINDS.include?(kind)
26
34
  raise "Unknown relationship kind '#{kind}'"
27
35
  end
36
+
28
37
  self.kind = kind.to_sym
29
38
  self.source_usr = hash[:source]
30
39
  self.target_usr = hash[:target]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jazzy
2
4
  module SymbolGraph
3
5
  # The rebuilt syntax tree is made of nodes that either match
@@ -23,6 +25,7 @@ module Jazzy
23
25
 
24
26
  # A SymNode is a node of the reconstructed syntax tree holding a symbol.
25
27
  # It can turn itself into SourceKit and helps decode extensions.
28
+ # rubocop:disable Metrics/ClassLength
26
29
  class SymNode < BaseNode
27
30
  attr_accessor :symbol
28
31
  attr_writer :override
@@ -59,6 +62,10 @@ module Jazzy
59
62
  symbol.kind.end_with?('protocol')
60
63
  end
61
64
 
65
+ def actor?
66
+ symbol.kind.end_with?('actor')
67
+ end
68
+
62
69
  def constraints
63
70
  symbol.constraints
64
71
  end
@@ -72,6 +79,7 @@ module Jazzy
72
79
  (!protocol? || node.protocol_requirement?)
73
80
  return false
74
81
  end
82
+
75
83
  add_child(node)
76
84
  true
77
85
  end
@@ -93,24 +101,31 @@ module Jazzy
93
101
  # conformance: don't bother if it's already in the type declaration.
94
102
  def conformance?(protocol)
95
103
  return false unless symbol.declaration =~ /(?<=:).*?(?=(where|$))/
104
+
96
105
  Regexp.last_match[0] =~ /\b#{protocol}\b/
97
106
  end
98
107
 
99
108
  # Generate the 'where' clause for the declaration
100
109
  def where_clause
101
- parent_constraints = (parent && parent.constraints) || []
110
+ parent_constraints = parent&.constraints || []
102
111
  (constraints - parent_constraints).to_where_clause
103
112
  end
104
113
 
105
114
  def inherits_clause
106
115
  return '' unless superclass_name
116
+
107
117
  " : #{superclass_name}"
108
118
  end
109
119
 
120
+ # approximately...
121
+ def async?
122
+ symbol.declaration =~ /\basync\b[^)]*$/
123
+ end
124
+
110
125
  def full_declaration
111
- symbol.availability
112
- .append(symbol.declaration + inherits_clause + where_clause)
113
- .join("\n")
126
+ symbol.attributes
127
+ .append(symbol.declaration + inherits_clause + where_clause)
128
+ .join("\n")
114
129
  end
115
130
 
116
131
  # rubocop:disable Metrics/MethodLength
@@ -120,11 +135,12 @@ module Jazzy
120
135
 
121
136
  hash = {
122
137
  'key.kind' => symbol.kind,
123
- 'key.usr' => symbol.usr,
138
+ 'key.usr' => symbol.usr,
124
139
  'key.name' => symbol.name,
125
140
  'key.accessibility' => symbol.acl,
126
141
  'key.parsed_decl' => declaration,
127
142
  'key.annotated_decl' => xml_declaration,
143
+ 'key.symgraph_async' => async?,
128
144
  }
129
145
  if docs = symbol.doc_comments
130
146
  hash['key.doc.comment'] = docs
@@ -136,12 +152,13 @@ module Jazzy
136
152
  end
137
153
  if location = symbol.location
138
154
  hash['key.filepath'] = location[:filename]
139
- hash['key.doc.line'] = location[:line]
140
- hash['key.doc.column'] = location[:character]
155
+ hash['key.doc.line'] = location[:line] + 1
156
+ hash['key.doc.column'] = location[:character] + 1
141
157
  end
142
158
  unless children.empty?
143
159
  hash['key.substructure'] = children_to_sourcekit
144
160
  end
161
+ hash['key.symgraph_spi'] = true if symbol.spi
145
162
 
146
163
  hash
147
164
  end
@@ -154,5 +171,6 @@ module Jazzy
154
171
  symbol <=> other.symbol
155
172
  end
156
173
  end
174
+ # rubocop:enable Metrics/ClassLength
157
175
  end
158
176
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # rubocop:disable Metrics/ClassLength
2
4
  module Jazzy
3
5
  module SymbolGraph
@@ -8,10 +10,11 @@ module Jazzy
8
10
  attr_accessor :declaration
9
11
  attr_accessor :kind
10
12
  attr_accessor :acl
13
+ attr_accessor :spi
11
14
  attr_accessor :location # can be nil, keys :filename :line :character
12
15
  attr_accessor :constraints # array, can be empty
13
16
  attr_accessor :doc_comments # can be nil
14
- attr_accessor :availability # array, can be empty
17
+ attr_accessor :attributes # array, can be empty
15
18
  attr_accessor :generic_type_params # set, can be empty
16
19
  attr_accessor :parameter_names # array, can be nil
17
20
 
@@ -22,13 +25,14 @@ module Jazzy
22
25
  def initialize(hash)
23
26
  self.usr = hash[:identifier][:precise]
24
27
  self.path_components = hash[:pathComponents]
25
- raw_decl = hash[:declarationFragments].map { |f| f[:spelling] }.join
26
- init_kind(hash[:kind][:identifier])
28
+ raw_decl, keywords = parse_decl_fragments(hash[:declarationFragments])
29
+ init_kind(hash[:kind][:identifier], keywords)
27
30
  init_declaration(raw_decl)
28
31
  if func_signature = hash[:functionSignature]
29
32
  init_func_signature(func_signature)
30
33
  end
31
34
  init_acl(hash[:accessLevel])
35
+ self.spi = hash[:spi]
32
36
  if location = hash[:location]
33
37
  init_location(location)
34
38
  end
@@ -36,19 +40,29 @@ module Jazzy
36
40
  if comments_hash = hash[:docComment]
37
41
  init_doc_comments(comments_hash)
38
42
  end
39
- init_availability(hash[:availability] || [])
43
+ init_attributes(hash[:availability] || [])
40
44
  init_generic_type_params(hash)
41
45
  end
42
46
 
47
+ def parse_decl_fragments(fragments)
48
+ decl = ''
49
+ keywords = Set.new
50
+ fragments.each do |frag|
51
+ decl += frag[:spelling]
52
+ keywords.add(frag[:spelling]) if frag[:kind] == 'keyword'
53
+ end
54
+ [decl, keywords]
55
+ end
56
+
43
57
  # Repair problems with SymbolGraph's declprinter
44
58
 
45
59
  def init_declaration(raw_decl)
46
60
  # Too much 'Self.TypeName'; omitted arg labels look odd;
47
61
  # duplicated constraints; swift 5.3 vs. master workaround
48
- self.declaration =
49
- raw_decl.gsub(/\bSelf\./, '')
50
- .gsub(/(?<=\(|, )_: /, '_ arg: ')
51
- .gsub(/ where.*$/, '')
62
+ self.declaration = raw_decl
63
+ .gsub(/\bSelf\./, '')
64
+ .gsub(/(?<=\(|, )_: /, '_ arg: ')
65
+ .gsub(/ where.*$/, '')
52
66
  if kind == 'source.lang.swift.decl.class'
53
67
  declaration.sub!(/\s*:.*$/, '')
54
68
  end
@@ -85,25 +99,32 @@ module Jazzy
85
99
  'static.subscript' => 'function.subscript',
86
100
  'typealias' => 'typealias',
87
101
  'associatedtype' => 'associatedtype',
102
+ 'actor' => 'actor',
88
103
  }.freeze
89
104
 
90
105
  # We treat 'static var' differently to 'class var'
91
- def adjust_kind_for_declaration(kind)
92
- return kind unless declaration =~ /\bstatic\b/
106
+ # We treat actors as first-class entities
107
+ def adjust_kind_for_declaration(kind, keywords)
108
+ if kind == 'swift.class' && keywords.member?('actor')
109
+ return 'swift.actor'
110
+ end
111
+ return kind unless keywords.member?('static')
112
+
93
113
  kind.gsub(/type/, 'static')
94
114
  end
95
115
 
96
- def init_kind(kind)
97
- adjusted = adjust_kind_for_declaration(kind)
116
+ def init_kind(kind, keywords)
117
+ adjusted = adjust_kind_for_declaration(kind, keywords)
98
118
  sourcekit_kind = KIND_MAP[adjusted.sub('swift.', '')]
99
119
  raise "Unknown symbol kind '#{kind}'" unless sourcekit_kind
100
- self.kind = 'source.lang.swift.decl.' + sourcekit_kind
120
+
121
+ self.kind = "source.lang.swift.decl.#{sourcekit_kind}"
101
122
  end
102
123
 
103
124
  # Mapping SymbolGraph's ACL to SourceKit
104
125
 
105
126
  def init_acl(acl)
106
- self.acl = 'source.lang.swift.accessibility.' + acl
127
+ self.acl = "source.lang.swift.accessibility.#{acl}"
107
128
  end
108
129
 
109
130
  # Symbol location - only available for public+ decls
@@ -120,6 +141,7 @@ module Jazzy
120
141
  def init_constraints(hash, raw_decl)
121
142
  raw_constraints = %i[swiftGenerics swiftExtension].flat_map do |key|
122
143
  next [] unless container = hash[key]
144
+
123
145
  container[:constraints] || []
124
146
  end
125
147
 
@@ -146,16 +168,16 @@ module Jazzy
146
168
  end
147
169
 
148
170
  def init_doc_comments(comments_hash)
149
- self.doc_comments =
150
- comments_hash[:lines].map { |l| l[:text] }
151
- .join("\n")
171
+ self.doc_comments = comments_hash[:lines]
172
+ .map { |l| l[:text] }
173
+ .join("\n")
152
174
  end
153
175
 
154
176
  # Availability
155
177
  # Re-encode this as Swift. Should really teach Jazzy about these,
156
178
  # could maybe then do something smarter here.
157
- def init_availability(avail_hash_list)
158
- self.availability = avail_hash_list.map do |avail|
179
+ def availability_attributes(avail_hash_list)
180
+ avail_hash_list.map do |avail|
159
181
  str = '@available('
160
182
  if avail[:isUnconditionallyDeprecated]
161
183
  str += '*, deprecated'
@@ -171,8 +193,8 @@ module Jazzy
171
193
  next nil
172
194
  end
173
195
 
174
- str += ', message: "' + avail[:message] + '"' if avail[:message]
175
- str += ', renamed: "' + avail[:renamed] + '"' if avail[:renamed]
196
+ str += ", message: \"#{avail[:message]}\"" if avail[:message]
197
+ str += ", renamed: \"#{avail[:renamed]}\"" if avail[:renamed]
176
198
 
177
199
  str + ')'
178
200
  end.compact
@@ -185,11 +207,18 @@ module Jazzy
185
207
  str
186
208
  end
187
209
 
210
+ def spi_attributes
211
+ spi ? ['@_spi(Unknown)'] : []
212
+ end
213
+
214
+ def init_attributes(avail_hash_list)
215
+ self.attributes =
216
+ availability_attributes(avail_hash_list) + spi_attributes
217
+ end
218
+
188
219
  # Sort order
189
220
  include Comparable
190
221
 
191
- # rubocop:disable Metrics/CyclomaticComplexity
192
- # rubocop:disable Metrics/PerceivedComplexity
193
222
  def <=>(other)
194
223
  # Things with location: order by file/line/column
195
224
  # (pls tell what wheel i am reinventing :/)
@@ -198,6 +227,7 @@ module Jazzy
198
227
  if location[:line] == other_loc[:line]
199
228
  return location[:character] <=> other_loc[:character]
200
229
  end
230
+
201
231
  return location[:line] <=> other_loc[:line]
202
232
  end
203
233
  return location[:filename] <=> other_loc[:filename]
@@ -209,10 +239,9 @@ module Jazzy
209
239
 
210
240
  # Things without a location: by name and then USR
211
241
  return usr <=> other.usr if name == other.name
242
+
212
243
  name <=> other.name
213
244
  end
214
- # rubocop:enable Metrics/PerceivedComplexity
215
- # rubocop:enable Metrics/CyclomaticComplexity
216
245
  end
217
246
  end
218
247
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
  require 'jazzy/symbol_graph/graph'
3
5
  require 'jazzy/symbol_graph/constraint'
@@ -12,32 +14,28 @@ require 'jazzy/symbol_graph/ext_node'
12
14
 
13
15
  module Jazzy
14
16
  module SymbolGraph
15
- # Run `swift symbolgraph-extract` with configured args,
16
- # parse the results, and return as JSON in SourceKit[ten]
17
+ # Find swift symbol graph files, either having been passed
18
+ # in directly, or generated by running`swift symbolgraph-extract`
19
+ # with configured args.
20
+ # Then parse the results, and return as JSON in SourceKit[ten]
17
21
  # format.
18
22
  def self.build(config)
19
- Dir.mktmpdir do |tmp_dir|
20
- args = arguments(config, tmp_dir)
23
+ if config.symbolgraph_directory.nil?
24
+ Dir.mktmpdir do |tmp_dir|
25
+ args = arguments(config, tmp_dir)
21
26
 
22
- Executable.execute_command('swift',
23
- args.unshift('symbolgraph-extract'),
24
- true) # raise on error
27
+ Executable.execute_command('swift',
28
+ args.unshift('symbolgraph-extract'),
29
+ true) # raise on error
25
30
 
26
- Dir[tmp_dir + '/*.symbols.json'].map do |filename|
27
- # The @ part is for extensions in our module (before the @)
28
- # of types in another module (after the @).
29
- filename =~ /(.*?)(@(.*?))?\.symbols/
30
- module_name = Regexp.last_match[3] || Regexp.last_match[1]
31
- {
32
- filename =>
33
- Graph.new(File.read(filename), module_name).to_sourcekit,
34
- }
35
- end.to_json
31
+ parse_symbols(tmp_dir)
32
+ end
33
+ else
34
+ parse_symbols(config.symbolgraph_directory.to_s)
36
35
  end
37
36
  end
38
37
 
39
38
  # Figure out the args to pass to symbolgraph-extract
40
- # rubocop:disable Metrics/CyclomaticComplexity
41
39
  def self.arguments(config, output_path)
42
40
  if config.module_name.empty?
43
41
  raise 'error: `--swift-build-tool symbolgraph` requires `--module`.'
@@ -45,29 +43,42 @@ module Jazzy
45
43
 
46
44
  user_args = config.build_tool_arguments.join
47
45
 
48
- if user_args =~ /--(?:module-name|minimum-access-level|output-dir)/
46
+ if user_args =~ /-(?:module-name|minimum-access-level|output-dir)/
49
47
  raise 'error: `--build-tool-arguments` for '\
50
- "`--swift-build-tool symbolgraph` can't use `--module`, "\
51
- '`--minimum-access-level`, or `--output-dir`.'
48
+ "`--swift-build-tool symbolgraph` can't use `-module`, "\
49
+ '`-minimum-access-level`, or `-output-dir`.'
52
50
  end
53
51
 
54
52
  # Default set
55
53
  args = [
56
- "--module-name=#{config.module_name}",
57
- '--minimum-access-level=private',
58
- "--output-dir=#{output_path}",
59
- '--skip-synthesized-members',
54
+ '-module-name', config.module_name,
55
+ '-minimum-access-level', 'private',
56
+ '-output-dir', output_path,
57
+ '-skip-synthesized-members'
60
58
  ]
61
59
 
62
60
  # Things user can override
63
- args.append("--sdk=#{sdk(config)}") unless user_args =~ /--sdk/
64
- args.append("--target=#{target}") unless user_args =~ /--target/
65
- args.append("-F=#{config.source_directory}") unless user_args =~ /-F(?!s)/
66
- args.append("-I=#{config.source_directory}") unless user_args =~ /-I/
61
+ args += ['-sdk', sdk(config)] unless user_args =~ /-sdk/
62
+ args += ['-target', target] unless user_args =~ /-target/
63
+ args += ['-F', config.source_directory.to_s] unless user_args =~ /-F(?!s)/
64
+ args += ['-I', config.source_directory.to_s] unless user_args =~ /-I/
67
65
 
68
66
  args + config.build_tool_arguments
69
67
  end
70
- # rubocop:enable Metrics/CyclomaticComplexity
68
+
69
+ # Parse the symbol files in the given directory
70
+ def self.parse_symbols(directory)
71
+ Dir[directory + '/*.symbols.json'].map do |filename|
72
+ # The @ part is for extensions in our module (before the @)
73
+ # of types in another module (after the @).
74
+ File.basename(filename) =~ /(.*?)(@(.*?))?\.symbols/
75
+ module_name = Regexp.last_match[3] || Regexp.last_match[1]
76
+ {
77
+ filename =>
78
+ Graph.new(File.read(filename), module_name).to_sourcekit,
79
+ }
80
+ end.to_json
81
+ end
71
82
 
72
83
  # Get the SDK path. On !darwin this just isn't needed.
73
84
  def self.sdk(config)
@@ -87,8 +98,8 @@ module Jazzy
87
98
  def self.demangle(usr)
88
99
  args = %w[demangle -simplified -compact].append(usr.sub(/^s:/, 's'))
89
100
  output, = Executable.execute_command('swift', args, true)
90
- return output.chomp
91
- rescue
101
+ output.chomp
102
+ rescue StandardError
92
103
  usr
93
104
  end
94
105
  end
@@ -1,63 +1,67 @@
1
+ /*! Jazzy - https://github.com/realm/jazzy
2
+ * Copyright Realm Inc.
3
+ * SPDX-License-Identifier: MIT
4
+ */
1
5
  /* Credit to https://gist.github.com/wataru420/2048287 */
2
6
 
3
7
  .highlight {
4
- .c { color: #999988; font-style: italic } /* Comment */
5
- .err { color: #a61717; background-color: #e3d2d2 } /* Error */
6
- .k { color: #000000; font-weight: bold } /* Keyword */
7
- .o { color: #000000; font-weight: bold } /* Operator */
8
- .cm { color: #999988; font-style: italic } /* Comment.Multiline */
9
- .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
10
- .c1 { color: #999988; font-style: italic } /* Comment.Single */
11
- .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
12
- .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
13
- .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
14
- .ge { color: #000000; font-style: italic } /* Generic.Emph */
15
- .gr { color: #aa0000 } /* Generic.Error */
16
- .gh { color: #999999 } /* Generic.Heading */
17
- .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
18
- .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
19
- .go { color: #888888 } /* Generic.Output */
20
- .gp { color: #555555 } /* Generic.Prompt */
21
- .gs { font-weight: bold } /* Generic.Strong */
22
- .gu { color: #aaaaaa } /* Generic.Subheading */
23
- .gt { color: #aa0000 } /* Generic.Traceback */
24
- .kc { color: #000000; font-weight: bold } /* Keyword.Constant */
25
- .kd { color: #000000; font-weight: bold } /* Keyword.Declaration */
26
- .kp { color: #000000; font-weight: bold } /* Keyword.Pseudo */
27
- .kr { color: #000000; font-weight: bold } /* Keyword.Reserved */
28
- .kt { color: #445588; } /* Keyword.Type */
29
- .m { color: #009999 } /* Literal.Number */
30
- .s { color: #d14 } /* Literal.String */
31
- .na { color: #008080 } /* Name.Attribute */
32
- .nb { color: #0086B3 } /* Name.Builtin */
33
- .nc { color: #445588; font-weight: bold } /* Name.Class */
34
- .no { color: #008080 } /* Name.Constant */
35
- .ni { color: #800080 } /* Name.Entity */
36
- .ne { color: #990000; font-weight: bold } /* Name.Exception */
37
- .nf { color: #990000; } /* Name.Function */
38
- .nn { color: #555555 } /* Name.Namespace */
39
- .nt { color: #000080 } /* Name.Tag */
40
- .nv { color: #008080 } /* Name.Variable */
41
- .ow { color: #000000; font-weight: bold } /* Operator.Word */
42
- .w { color: #bbbbbb } /* Text.Whitespace */
43
- .mf { color: #009999 } /* Literal.Number.Float */
44
- .mh { color: #009999 } /* Literal.Number.Hex */
45
- .mi { color: #009999 } /* Literal.Number.Integer */
46
- .mo { color: #009999 } /* Literal.Number.Oct */
47
- .sb { color: #d14 } /* Literal.String.Backtick */
48
- .sc { color: #d14 } /* Literal.String.Char */
49
- .sd { color: #d14 } /* Literal.String.Doc */
50
- .s2 { color: #d14 } /* Literal.String.Double */
51
- .se { color: #d14 } /* Literal.String.Escape */
52
- .sh { color: #d14 } /* Literal.String.Heredoc */
53
- .si { color: #d14 } /* Literal.String.Interpol */
54
- .sx { color: #d14 } /* Literal.String.Other */
55
- .sr { color: #009926 } /* Literal.String.Regex */
56
- .s1 { color: #d14 } /* Literal.String.Single */
57
- .ss { color: #990073 } /* Literal.String.Symbol */
58
- .bp { color: #999999 } /* Name.Builtin.Pseudo */
59
- .vc { color: #008080 } /* Name.Variable.Class */
60
- .vg { color: #008080 } /* Name.Variable.Global */
61
- .vi { color: #008080 } /* Name.Variable.Instance */
62
- .il { color: #009999 } /* Literal.Number.Integer.Long */
8
+ .c { color: #999988; font-style: italic } // Comment
9
+ .err { color: #a61717; background-color: #e3d2d2 } // Error
10
+ .k { color: #000000; font-weight: bold } // Keyword
11
+ .o { color: #000000; font-weight: bold } // Operator
12
+ .cm { color: #999988; font-style: italic } // Comment.Multiline
13
+ .cp { color: #999999; font-weight: bold } // Comment.Preproc
14
+ .c1 { color: #999988; font-style: italic } // Comment.Single
15
+ .cs { color: #999999; font-weight: bold; font-style: italic } // Comment.Special
16
+ .gd { color: #000000; background-color: #ffdddd } // Generic.Deleted
17
+ .gd .x { color: #000000; background-color: #ffaaaa } // Generic.Deleted.Specific
18
+ .ge { color: #000000; font-style: italic } // Generic.Emph
19
+ .gr { color: #aa0000 } // Generic.Error
20
+ .gh { color: #999999 } // Generic.Heading
21
+ .gi { color: #000000; background-color: #ddffdd } // Generic.Inserted
22
+ .gi .x { color: #000000; background-color: #aaffaa } // Generic.Inserted.Specific
23
+ .go { color: #888888 } // Generic.Output
24
+ .gp { color: #555555 } // Generic.Prompt
25
+ .gs { font-weight: bold } // Generic.Strong
26
+ .gu { color: #aaaaaa } // Generic.Subheading
27
+ .gt { color: #aa0000 } // Generic.Traceback
28
+ .kc { color: #000000; font-weight: bold } // Keyword.Constant
29
+ .kd { color: #000000; font-weight: bold } // Keyword.Declaration
30
+ .kp { color: #000000; font-weight: bold } // Keyword.Pseudo
31
+ .kr { color: #000000; font-weight: bold } // Keyword.Reserved
32
+ .kt { color: #445588; } // Keyword.Type
33
+ .m { color: #009999 } // Literal.Number
34
+ .s { color: #d14 } // Literal.String
35
+ .na { color: #008080 } // Name.Attribute
36
+ .nb { color: #0086B3 } // Name.Builtin
37
+ .nc { color: #445588; font-weight: bold } // Name.Class
38
+ .no { color: #008080 } // Name.Constant
39
+ .ni { color: #800080 } // Name.Entity
40
+ .ne { color: #990000; font-weight: bold } // Name.Exception
41
+ .nf { color: #990000; } // Name.Function
42
+ .nn { color: #555555 } // Name.Namespace
43
+ .nt { color: #000080 } // Name.Tag
44
+ .nv { color: #008080 } // Name.Variable
45
+ .ow { color: #000000; font-weight: bold } // Operator.Word
46
+ .w { color: #bbbbbb } // Text.Whitespace
47
+ .mf { color: #009999 } // Literal.Number.Float
48
+ .mh { color: #009999 } // Literal.Number.Hex
49
+ .mi { color: #009999 } // Literal.Number.Integer
50
+ .mo { color: #009999 } // Literal.Number.Oct
51
+ .sb { color: #d14 } // Literal.String.Backtick
52
+ .sc { color: #d14 } // Literal.String.Char
53
+ .sd { color: #d14 } // Literal.String.Doc
54
+ .s2 { color: #d14 } // Literal.String.Double
55
+ .se { color: #d14 } // Literal.String.Escape
56
+ .sh { color: #d14 } // Literal.String.Heredoc
57
+ .si { color: #d14 } // Literal.String.Interpol
58
+ .sx { color: #d14 } // Literal.String.Other
59
+ .sr { color: #009926 } // Literal.String.Regex
60
+ .s1 { color: #d14 } // Literal.String.Single
61
+ .ss { color: #990073 } // Literal.String.Symbol
62
+ .bp { color: #999999 } // Name.Builtin.Pseudo
63
+ .vc { color: #008080 } // Name.Variable.Class
64
+ .vg { color: #008080 } // Name.Variable.Global
65
+ .vi { color: #008080 } // Name.Variable.Instance
66
+ .il { color: #009999 } // Literal.Number.Integer.Long
63
67
  }
@@ -1,3 +1,7 @@
1
+ /*! Jazzy - https://github.com/realm/jazzy
2
+ * Copyright Realm Inc.
3
+ * SPDX-License-Identifier: MIT
4
+ */
1
5
  ////////////////////////////////
2
6
  // Constants
3
7
  ////////////////////////////////
@@ -181,7 +185,7 @@ header {
181
185
  z-index: 3;
182
186
  img {
183
187
  padding-right: 6px;
184
- vertical-align: -4px;
188
+ vertical-align: -3px;
185
189
  height: 16px;
186
190
  }
187
191
  a {