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
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #-- Bootstrap --------------------------------------------------------------#
2
4
 
3
5
  desc 'Initializes your working copy to run the specs'
@@ -9,7 +11,7 @@ task :bootstrap do
9
11
  title 'Updating submodules'
10
12
  sh 'git submodule update --init --recursive'
11
13
  else
12
- $stderr.puts "\033[0;31m" \
14
+ warn "\033[0;31m" \
13
15
  "[!] Please install the bundler gem manually:\n" \
14
16
  ' $ [sudo] gem install bundler' \
15
17
  "\e[0m"
@@ -95,7 +97,7 @@ begin
95
97
 
96
98
  desc 'Runs RuboCop linter on Ruby files'
97
99
  task :rubocop do
98
- sh 'bundle exec rubocop lib spec'
100
+ sh 'bundle exec rubocop'
99
101
  end
100
102
 
101
103
  #-- SourceKitten -----------------------------------------------------------#
@@ -103,10 +105,12 @@ begin
103
105
  desc 'Vendors SourceKitten'
104
106
  task :sourcekitten do
105
107
  sk_dir = 'SourceKitten'
106
- Dir.chdir(sk_dir) do
107
- `swift build -c release`
108
+ bin_path = Dir.chdir(sk_dir) do
109
+ build_cmd = 'swift build -c release --arch arm64 --arch x86_64'
110
+ `#{build_cmd}`
111
+ `#{build_cmd} --show-bin-path`.chomp
108
112
  end
109
- FileUtils.cp_r "#{sk_dir}/.build/release/sourcekitten", 'bin'
113
+ FileUtils.cp_r "#{bin_path}/sourcekitten", 'bin'
110
114
  end
111
115
 
112
116
  #-- Theme Dependencies -----------------------------------------------------#
@@ -115,20 +119,20 @@ begin
115
119
  'jquery/dist/jquery.min.js' => [
116
120
  'themes/apple/assets/js',
117
121
  'themes/fullwidth/assets/js',
118
- 'themes/jony/assets/js'
122
+ 'themes/jony/assets/js',
119
123
  ],
120
124
  'lunr/lunr.min.js' => [
121
125
  'themes/apple/assets/js',
122
- 'themes/fullwidth/assets/js'
126
+ 'themes/fullwidth/assets/js',
123
127
  ],
124
128
  'corejs-typeahead/dist/typeahead.jquery.js' => [
125
129
  'themes/apple/assets/js',
126
- 'themes/fullwidth/assets/js'
130
+ 'themes/fullwidth/assets/js',
127
131
  ],
128
132
  'katex/dist/katex.min.css' => ['extensions/katex/css'],
129
133
  'katex/dist/fonts' => ['extensions/katex/css'],
130
- 'katex/dist/katex.min.js' => ['extensions/katex/js']
131
- }
134
+ 'katex/dist/katex.min.js' => ['extensions/katex/js'],
135
+ }.freeze
132
136
 
133
137
  desc 'Copies theme dependencies (`npm update/install` by hand first)'
134
138
  task :theme_deps do
@@ -138,15 +142,14 @@ begin
138
142
  end
139
143
  end
140
144
  end
141
-
142
145
  rescue LoadError, NameError => e
143
- $stderr.puts "\033[0;31m" \
146
+ warn "\033[0;31m" \
144
147
  '[!] Some Rake tasks haven been disabled because the environment' \
145
148
  ' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \
146
149
  "\e[0m"
147
- $stderr.puts e.message
148
- $stderr.puts e.backtrace
149
- $stderr.puts
150
+ warn e.message
151
+ warn e.backtrace
152
+ warn ''
150
153
  end
151
154
 
152
155
  #-- Helpers ------------------------------------------------------------------#
data/bin/jazzy CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  if $PROGRAM_NAME == __FILE__ && !ENV['JAZZY_NO_BUNDLER']
4
- ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
5
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __dir__)
5
6
  require 'rubygems'
6
7
  require 'bundler/setup'
7
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
8
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
8
9
  elsif ENV['JAZZY_NO_BUNDLER']
9
10
  require 'rubygems'
10
11
  gem 'jazzy'
data/bin/sourcekitten CHANGED
Binary file
data/jazzy.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require File.expand_path('lib/jazzy/gem_version.rb', File.dirname(__FILE__))
4
5
 
@@ -9,25 +10,27 @@ Gem::Specification.new do |spec|
9
10
  spec.email = ['jp@jpsim.com']
10
11
  spec.summary = 'Soulful docs for Swift & Objective-C.'
11
12
  spec.description = 'Soulful docs for Swift & Objective-C. ' \
12
- "Run in your Xcode project's root directory for " \
13
- 'instant HTML docs.'
13
+ "Run in your SPM or Xcode project's root directory for " \
14
+ 'instant HTML docs.'
14
15
  spec.homepage = 'https://github.com/realm/jazzy'
15
16
  spec.license = 'MIT'
16
17
 
17
18
  spec.files = `git ls-files`.split($/)
18
- spec.executables << 'jazzy'
19
+ spec.executables << 'jazzy'
19
20
 
20
21
  spec.add_runtime_dependency 'cocoapods', '~> 1.5'
21
22
  spec.add_runtime_dependency 'mustache', '~> 1.1'
22
- spec.add_runtime_dependency 'open4'
23
+ spec.add_runtime_dependency 'open4', '~> 1.3'
23
24
  spec.add_runtime_dependency 'redcarpet', '~> 3.4'
25
+ spec.add_runtime_dependency 'rexml', '~> 3.2'
24
26
  spec.add_runtime_dependency 'rouge', ['>= 2.0.6', '< 4.0']
25
27
  spec.add_runtime_dependency 'sassc', '~> 2.1'
26
28
  spec.add_runtime_dependency 'sqlite3', '~> 1.3'
27
29
  spec.add_runtime_dependency 'xcinvoke', '~> 0.3.0'
28
30
 
29
- spec.add_development_dependency 'bundler', '~> 1.7'
31
+ spec.add_development_dependency 'bundler', '~> 2.1'
30
32
  spec.add_development_dependency 'rake', '~> 13.0'
31
33
 
32
- spec.required_ruby_version = '>= 2.0.0'
34
+ spec.required_ruby_version = '>= 2.6.3'
35
+ spec.metadata['rubygems_mfa_required'] = 'true'
33
36
  end
data/lib/jazzy/config.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'optparse'
2
4
  require 'pathname'
3
5
  require 'uri'
@@ -8,7 +10,7 @@ require 'jazzy/source_declaration/access_control_level'
8
10
  module Jazzy
9
11
  # rubocop:disable Metrics/ClassLength
10
12
  class Config
11
- # rubocop:disable Style/AccessorMethodName
13
+ # rubocop:disable Naming/AccessorMethodName
12
14
  class Attribute
13
15
  attr_reader :name, :description, :command_line, :config_file_key,
14
16
  :default, :parse
@@ -50,6 +52,7 @@ module Jazzy
50
52
 
51
53
  def attach_to_option_parser(config, opt)
52
54
  return if command_line.empty?
55
+
53
56
  opt.on(*command_line, *description) do |val|
54
57
  set(config, val)
55
58
  end
@@ -70,11 +73,12 @@ module Jazzy
70
73
  end
71
74
  end
72
75
  end
73
- # rubocop:enable Style/AccessorMethodName
76
+ # rubocop:enable Naming/AccessorMethodName
74
77
 
75
78
  def self.config_attr(name, **opts)
76
79
  attr_accessor name
77
80
  attr_accessor "#{name}_configured"
81
+
78
82
  @all_config_attrs ||= []
79
83
  @all_config_attrs << Attribute.new(name, **opts)
80
84
  end
@@ -112,7 +116,7 @@ module Jazzy
112
116
 
113
117
  # ──────── Build ────────
114
118
 
115
- # rubocop:disable Layout/AlignParameters
119
+ # rubocop:disable Layout/ArgumentAlignment
116
120
 
117
121
  config_attr :output,
118
122
  description: 'Folder to output the HTML docs to',
@@ -124,7 +128,7 @@ module Jazzy
124
128
  command_line: ['-c', '--[no-]clean'],
125
129
  description: ['Delete contents of output directory before running. ',
126
130
  'WARNING: If --output is set to ~/Desktop, this will '\
127
- 'delete the ~/Desktop directory.'],
131
+ 'delete the ~/Desktop directory.'],
128
132
  default: false
129
133
 
130
134
  config_attr :objc_mode,
@@ -150,10 +154,10 @@ module Jazzy
150
154
  config_attr :hide_declarations,
151
155
  command_line: '--hide-declarations [objc|swift] ',
152
156
  description: 'Hide declarations in the specified language. Given that ' \
153
- 'generating Swift docs only generates Swift declarations, ' \
154
- 'this is useful for hiding a specific interface for ' \
155
- 'either Objective-C or mixed Objective-C and Swift ' \
156
- 'projects.',
157
+ 'generating Swift docs only generates Swift declarations, ' \
158
+ 'this is useful for hiding a specific interface for ' \
159
+ 'either Objective-C or mixed Objective-C and Swift ' \
160
+ 'projects.',
157
161
  default: ''
158
162
 
159
163
  config_attr :keep_property_attributes,
@@ -170,7 +174,7 @@ module Jazzy
170
174
  config_attr :build_tool_arguments,
171
175
  command_line: ['-b', '--build-tool-arguments arg1,arg2,…argN', Array],
172
176
  description: 'Arguments to forward to xcodebuild, swift build, or ' \
173
- 'sourcekitten.',
177
+ 'sourcekitten.',
174
178
  default: []
175
179
 
176
180
  alias_config_attr :xcodebuild_arguments, :build_tool_arguments,
@@ -189,10 +193,16 @@ module Jazzy
189
193
  default: Pathname.pwd,
190
194
  parse: ->(sd) { expand_path(sd) }
191
195
 
196
+ config_attr :symbolgraph_directory,
197
+ command_line: '--symbolgraph-directory DIRPATH',
198
+ description: 'A directory containing a set of Swift Symbolgraph files ' \
199
+ 'representing the module to be documented',
200
+ parse: ->(sd) { expand_path(sd) }
201
+
192
202
  config_attr :excluded_files,
193
203
  command_line: ['-e', '--exclude filepath1,filepath2,…filepathN', Array],
194
204
  description: 'Source file pathnames to be excluded from documentation. '\
195
- 'Supports wildcards.',
205
+ 'Supports wildcards.',
196
206
  default: [],
197
207
  parse: ->(files) do
198
208
  Array(files).map { |f| expand_glob_path(f).to_s }
@@ -201,7 +211,7 @@ module Jazzy
201
211
  config_attr :included_files,
202
212
  command_line: ['-i', '--include filepath1,filepath2,…filepathN', Array],
203
213
  description: 'Source file pathnames to be included in documentation. '\
204
- 'Supports wildcards.',
214
+ 'Supports wildcards.',
205
215
  default: [],
206
216
  parse: ->(files) do
207
217
  Array(files).map { |f| expand_glob_path(f).to_s }
@@ -213,8 +223,9 @@ module Jazzy
213
223
  parse: ->(v) do
214
224
  if v.to_s.empty?
215
225
  nil
226
+ elsif v.to_f < 2
227
+ raise 'jazzy only supports Swift 2.0 or later.'
216
228
  else
217
- raise 'jazzy only supports Swift 2.0 or later.' if v.to_f < 2
218
229
  v
219
230
  end
220
231
  end
@@ -224,13 +235,14 @@ module Jazzy
224
235
  config_attr :swift_build_tool,
225
236
  command_line: "--swift-build-tool #{SWIFT_BUILD_TOOLS.join(' | ')}",
226
237
  description: 'Control whether Jazzy uses Swift Package Manager, '\
227
- 'xcodebuild, or swift-symbolgraph to build the module '\
228
- 'to be documented. By default it uses xcodebuild if '\
229
- 'there is a .xcodeproj file in the source directory.',
238
+ 'xcodebuild, or swift-symbolgraph to build the module '\
239
+ 'to be documented. By default it uses xcodebuild if '\
240
+ 'there is a .xcodeproj file in the source directory.',
230
241
  parse: ->(tool) do
231
242
  return tool.to_sym if SWIFT_BUILD_TOOLS.include?(tool)
243
+
232
244
  raise "Unsupported swift_build_tool #{tool}, "\
233
- "supported values: #{SWIFT_BUILD_TOOLS.join(', ')}"
245
+ "supported values: #{SWIFT_BUILD_TOOLS.join(', ')}"
234
246
  end
235
247
 
236
248
  # ──────── Metadata ────────
@@ -254,13 +266,13 @@ module Jazzy
254
266
  config_attr :version,
255
267
  command_line: '--module-version VERSION',
256
268
  description: 'Version string to use as part of the default docs '\
257
- 'title and inside the docset.',
269
+ 'title and inside the docset.',
258
270
  default: '1.0'
259
271
 
260
272
  config_attr :title,
261
273
  command_line: '--title TITLE',
262
274
  description: 'Title to display at the top of each page, overriding the '\
263
- 'default generated from module name and version.',
275
+ 'default generated from module name and version.',
264
276
  default: ''
265
277
 
266
278
  config_attr :copyright,
@@ -285,16 +297,16 @@ module Jazzy
285
297
  config_attr :podspec,
286
298
  command_line: '--podspec FILEPATH',
287
299
  description: 'A CocoaPods Podspec that describes the Swift library to '\
288
- 'document',
300
+ 'document',
289
301
  parse: ->(ps) { PodspecDocumenter.create_podspec(Pathname(ps)) if ps },
290
302
  default: Dir['*.podspec{,.json}'].first
291
303
 
292
304
  config_attr :pod_sources,
293
305
  command_line: ['--pod-sources url1,url2,…urlN', Array],
294
306
  description: 'A list of sources to find pod dependencies. Used only '\
295
- 'with --podspec when the podspec contains references to '\
296
- 'privately hosted pods. You must include the default pod '\
297
- 'source if public pods are also used.',
307
+ 'with --podspec when the podspec contains references to '\
308
+ 'privately hosted pods. You must include the default pod '\
309
+ 'source if public pods are also used.',
298
310
  default: []
299
311
 
300
312
  config_attr :docset_icon,
@@ -316,30 +328,56 @@ module Jazzy
316
328
  config_attr :dash_url,
317
329
  command_line: ['-d', '--dash_url URL'],
318
330
  description: 'Location of the dash XML feed '\
319
- 'e.g. https://realm.io/docsets/realm.xml)',
331
+ 'e.g. https://realm.io/docsets/realm.xml)',
320
332
  parse: ->(d) { URI(d) }
321
333
 
322
- config_attr :github_url,
323
- command_line: ['-g', '--github_url URL'],
324
- description: 'GitHub URL of this project (e.g. '\
325
- 'https://github.com/realm/realm-cocoa)',
334
+ SOURCE_HOSTS = %w[github gitlab bitbucket].freeze
335
+
336
+ config_attr :source_host,
337
+ command_line: "--source-host #{SOURCE_HOSTS.join(' | ')}",
338
+ description: ['The source-code hosting site to be linked from documentation.',
339
+ 'This setting affects the logo image and link format.',
340
+ "Default: 'github'"],
341
+ default: 'github',
342
+ parse: ->(host) do
343
+ return host.to_sym if SOURCE_HOSTS.include?(host)
344
+
345
+ raise "Unsupported source_host '#{host}', "\
346
+ "supported values: #{SOURCE_HOSTS.join(', ')}"
347
+ end
348
+
349
+ config_attr :source_host_url,
350
+ command_line: ['--source-host-url URL'],
351
+ description: ["URL to link from the source host's logo.",
352
+ 'For example https://github.com/realm/realm-cocoa'],
326
353
  parse: ->(g) { URI(g) }
327
354
 
328
- config_attr :github_file_prefix,
355
+ alias_config_attr :github_url, :source_host_url,
356
+ command_line: ['-g', '--github_url URL'],
357
+ description: 'Back-compatibility alias for source_host_url.'
358
+
359
+ config_attr :source_host_files_url,
360
+ command_line: '--source-host-files-url PREFIX',
361
+ description: [
362
+ "The base URL on the source host of the project's files, to link "\
363
+ 'from individual declarations.',
364
+ 'For example https://github.com/realm/realm-cocoa/tree/v0.87.1',
365
+ ]
366
+
367
+ alias_config_attr :github_file_prefix, :source_host_files_url,
329
368
  command_line: '--github-file-prefix PREFIX',
330
- description: 'GitHub URL file prefix of this project (e.g. '\
331
- 'https://github.com/realm/realm-cocoa/tree/v0.87.1)'
369
+ description: 'Back-compatibility alias for source_host_files_url'
332
370
 
333
371
  config_attr :docset_playground_url,
334
372
  command_line: '--docset-playground-url URL',
335
373
  description: 'URL of an interactive playground to demonstrate the '\
336
- 'framework, linked to from the docset.'
374
+ 'framework, linked to from the docset.'
337
375
 
338
376
  # ──────── Doc generation options ────────
339
377
  config_attr :disable_search,
340
378
  command_line: '--disable-search',
341
- description: ['Avoid generating a search index. '\
342
- 'Search is available in some themes.'],
379
+ description: 'Avoid generating a search index. '\
380
+ 'Search is available in some themes.',
343
381
  default: false
344
382
 
345
383
  config_attr :skip_documentation,
@@ -359,7 +397,7 @@ module Jazzy
359
397
  config_attr :skip_undocumented,
360
398
  command_line: '--[no-]skip-undocumented',
361
399
  description: "Don't document declarations that have no documentation "\
362
- 'comments.',
400
+ 'comments.',
363
401
  default: false
364
402
 
365
403
  config_attr :hide_documentation_coverage,
@@ -368,22 +406,22 @@ module Jazzy
368
406
  default: false
369
407
 
370
408
  config_attr :custom_categories,
371
- description: ['Custom navigation categories to replace the standard '\
372
- 'Classes, Protocols, etc.”', 'Types not explicitly named '\
373
- 'in a custom category appear in generic groups at the end.',
374
- 'Example: https://git.io/v4Bcp'],
409
+ description: 'Custom navigation categories to replace the standard '\
410
+ "'Classes', 'Protocols', etc. Types not explicitly named "\
411
+ 'in a custom category appear in generic groups at the '\
412
+ 'end. Example: https://git.io/v4Bcp',
375
413
  default: []
376
414
 
377
415
  config_attr :custom_categories_unlisted_prefix,
378
416
  description: "Prefix for navigation section names that aren't "\
379
- 'explicitly listed in `custom_categories`.',
417
+ 'explicitly listed in `custom_categories`.',
380
418
  default: 'Other '
381
419
 
382
420
  config_attr :hide_unlisted_documentation,
383
421
  command_line: '--[no-]hide-unlisted-documentation',
384
422
  description: "Don't include documentation in the sidebar from the "\
385
- "`documentation` config value that aren't explicitly "\
386
- 'listed in `custom_categories`.',
423
+ "`documentation` config value that aren't explicitly "\
424
+ 'listed in `custom_categories`.',
387
425
  default: false
388
426
 
389
427
  config_attr :custom_head,
@@ -391,15 +429,15 @@ module Jazzy
391
429
  description: 'Custom HTML to inject into <head></head>.',
392
430
  default: ''
393
431
 
394
- BUILTIN_THEME_DIR = Pathname(__FILE__).parent + 'themes'
432
+ BUILTIN_THEME_DIR = Pathname(__dir__) + 'themes'
395
433
  BUILTIN_THEMES = BUILTIN_THEME_DIR.children(false).map(&:to_s)
396
434
 
397
435
  config_attr :theme_directory,
398
436
  command_line: "--theme [#{BUILTIN_THEMES.join(' | ')} | DIRPATH]",
399
437
  description: "Which theme to use. Specify either 'apple' (default), "\
400
- 'one of the other built-in theme names, or the path to '\
401
- 'your mustache templates and other assets for a custom '\
402
- 'theme.',
438
+ 'one of the other built-in theme names, or the path to '\
439
+ 'your mustache templates and other assets for a custom '\
440
+ 'theme.',
403
441
  default: 'apple',
404
442
  parse: ->(t) do
405
443
  if BUILTIN_THEMES.include?(t)
@@ -412,9 +450,9 @@ module Jazzy
412
450
  config_attr :use_safe_filenames,
413
451
  command_line: '--use-safe-filenames',
414
452
  description: 'Replace unsafe characters in filenames with an encoded '\
415
- 'representation. This will reduce human readability of '\
416
- 'some URLs, but may be necessary for projects that '\
417
- 'expose filename-unfriendly functions such as /(_:_:)',
453
+ 'representation. This will reduce human readability of '\
454
+ 'some URLs, but may be necessary for projects that '\
455
+ 'expose filename-unfriendly functions such as /(_:_:)',
418
456
  default: false
419
457
 
420
458
  config_attr :template_directory,
@@ -434,17 +472,23 @@ module Jazzy
434
472
  config_attr :undocumented_text,
435
473
  command_line: '--undocumented-text UNDOCUMENTED_TEXT',
436
474
  description: 'Default text for undocumented symbols. The default '\
437
- 'is "Undocumented", put "" if no text is required',
475
+ 'is "Undocumented", put "" if no text is required',
438
476
  default: 'Undocumented'
439
477
 
440
478
  config_attr :separate_global_declarations,
441
479
  command_line: '--[no-]separate-global-declarations',
442
480
  description: 'Create separate pages for all global declarations '\
443
- "(classes, structures, enums etc.) even if they don't "\
444
- 'have children.',
481
+ "(classes, structures, enums etc.) even if they don't "\
482
+ 'have children.',
483
+ default: false
484
+
485
+ config_attr :include_spi_declarations,
486
+ command_line: '--[no-]include-spi-declarations',
487
+ description: 'Include Swift declarations marked `@_spi` even if '\
488
+ '--min-acl is set to `public` or `open`.',
445
489
  default: false
446
490
 
447
- # rubocop:enable Style/AlignParameter
491
+ # rubocop:enable Layout/ArgumentAlignment
448
492
 
449
493
  def initialize
450
494
  self.class.all_config_attrs.each do |attr|
@@ -457,7 +501,6 @@ module Jazzy
457
501
  Doc.template_path = theme_directory + 'templates'
458
502
  end
459
503
 
460
- # rubocop:disable Metrics/MethodLength
461
504
  def self.parse!
462
505
  config = new
463
506
  config.parse_command_line
@@ -471,9 +514,16 @@ module Jazzy
471
514
  )
472
515
  end
473
516
 
517
+ config.validate
518
+
474
519
  config
475
520
  end
476
521
 
522
+ def warning(message)
523
+ warn "WARNING: #{message}"
524
+ end
525
+
526
+ # rubocop:disable Metrics/MethodLength
477
527
  def parse_command_line
478
528
  OptionParser.new do |opt|
479
529
  opt.banner = 'Usage: jazzy'
@@ -485,7 +535,7 @@ module Jazzy
485
535
  end
486
536
 
487
537
  opt.on('-v', '--version', 'Print version number') do
488
- puts 'jazzy version: ' + Jazzy::VERSION
538
+ puts "jazzy version: #{Jazzy::VERSION}"
489
539
  exit
490
540
  end
491
541
 
@@ -504,6 +554,10 @@ module Jazzy
504
554
  exit
505
555
  end
506
556
  end.parse!
557
+
558
+ unless ARGV.empty?
559
+ warning "Leftover unused command-line text: #{ARGV}"
560
+ end
507
561
  end
508
562
 
509
563
  def parse_config_file
@@ -521,13 +575,12 @@ module Jazzy
521
575
 
522
576
  config_file.each do |key, value|
523
577
  unless attr = attrs_by_conf_key[key]
524
- message = "WARNING: Unknown config file attribute #{key.inspect}"
578
+ message = "Unknown config file attribute #{key.inspect}"
525
579
  if matching_name = attrs_by_name[key]
526
- message << ' (Did you mean '
527
- message << matching_name.first.config_file_key.inspect
528
- message << '?)'
580
+ message +=
581
+ " (Did you mean #{matching_name.first.config_file_key.inspect}?)"
529
582
  end
530
- warn message
583
+ warning message
531
584
  next
532
585
  end
533
586
 
@@ -537,6 +590,24 @@ module Jazzy
537
590
  self.base_path = nil
538
591
  end
539
592
 
593
+ def validate
594
+ if source_host_configured &&
595
+ source_host_url.nil? &&
596
+ source_host_files_url.nil?
597
+ warning 'Option `source_host` is set but has no effect without either '\
598
+ '`source_host_url` or `source_host_files_url`.'
599
+ end
600
+
601
+ if objc_mode &&
602
+ build_tool_arguments_configured &&
603
+ (framework_root_configured || umbrella_header_configured)
604
+ warning 'Option `build_tool_arguments` is set: values passed to '\
605
+ '`framework_root` or `umbrella_header` may be ignored.'
606
+ end
607
+ end
608
+
609
+ # rubocop:enable Metrics/MethodLength
610
+
540
611
  def locate_config_file
541
612
  return config_file if config_file
542
613
 
@@ -550,15 +621,10 @@ module Jazzy
550
621
 
551
622
  def read_config_file(file)
552
623
  case File.extname(file)
553
- when '.json' then JSON.parse(File.read(file))
554
- when '.yaml', '.yml' then
555
- if YAML.respond_to?('safe_load') # ruby >= 2.1.0
556
- YAML.safe_load(File.read(file))
557
- else
558
- # rubocop:disable Security/YAMLLoad
559
- YAML.load(File.read(file))
560
- # rubocop:enable Security/YAMLLoad
561
- end
624
+ when '.json'
625
+ JSON.parse(File.read(file))
626
+ when '.yaml', '.yml'
627
+ YAML.safe_load(File.read(file))
562
628
  else raise "Config file must be .yaml or .json, but got #{file.inspect}"
563
629
  end
564
630
  end
@@ -575,7 +641,7 @@ module Jazzy
575
641
 
576
642
  The config file can be in YAML or JSON format. Available options are:
577
643
 
578
- _EOS_
644
+ _EOS_
579
645
  .gsub(/^ +/, '')
580
646
 
581
647
  print_option_help
data/lib/jazzy/doc.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
  require 'pathname'
3
5
  require 'mustache'
@@ -18,7 +20,7 @@ module Jazzy
18
20
  date = ENV['JAZZY_FAKE_DATE'] || DateTime.now.strftime('%Y-%m-%d')
19
21
  year = date[0..3]
20
22
  "&copy; #{year} [#{config.author_name}](#{config.author_url}). " \
21
- "All rights reserved. (Last updated: #{date})"
23
+ "All rights reserved. (Last updated: #{date})"
22
24
  )
23
25
  Markdown.render_copyright(copyright).chomp
24
26
  end