jazzy 0.13.5 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/Tests.yml +52 -0
- data/.rubocop.yml +139 -24
- data/CHANGELOG.md +105 -0
- data/CONTRIBUTING.md +5 -5
- data/Dangerfile +11 -8
- data/Gemfile +3 -1
- data/Gemfile.lock +101 -77
- data/README.md +81 -13
- data/Rakefile +13 -12
- data/bin/jazzy +3 -2
- data/bin/sourcekitten +0 -0
- data/jazzy.gemspec +8 -6
- data/js/package-lock.json +30 -25
- data/js/package.json +3 -3
- data/lib/jazzy/config.rb +125 -72
- data/lib/jazzy/doc.rb +3 -1
- data/lib/jazzy/doc_builder.rb +79 -84
- data/lib/jazzy/docset_builder.rb +3 -1
- data/lib/jazzy/documentation_generator.rb +6 -2
- data/lib/jazzy/executable.rb +3 -0
- data/lib/jazzy/extensions/bitbucket/img/bitbucket.svg +11 -0
- data/lib/jazzy/{themes/apple/assets → extensions/github}/img/gh.png +0 -0
- data/lib/jazzy/extensions/gitlab/img/gitlab.svg +23 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_AMS-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_AMS-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Bold.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Bold.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Bold.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Italic.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Italic.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Italic.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Main-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Math-Italic.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Math-Italic.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Math-Italic.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Script-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Script-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Script-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size1-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size1-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size2-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size2-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size3-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size3-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size4-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size4-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- data/lib/jazzy/extensions/katex/css/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- data/lib/jazzy/extensions/katex/css/katex.min.css +1 -1
- data/lib/jazzy/extensions/katex/js/katex.min.js +1 -1
- data/lib/jazzy/gem_version.rb +3 -1
- data/lib/jazzy/highlighter.rb +17 -3
- data/lib/jazzy/jazzy_markdown.rb +112 -31
- data/lib/jazzy/podspec_documenter.rb +14 -16
- data/lib/jazzy/search_builder.rb +4 -3
- data/lib/jazzy/source_declaration/access_control_level.rb +7 -5
- data/lib/jazzy/source_declaration/type.rb +29 -3
- data/lib/jazzy/source_declaration.rb +18 -3
- data/lib/jazzy/source_document.rb +8 -5
- data/lib/jazzy/source_host.rb +111 -0
- data/lib/jazzy/source_mark.rb +8 -6
- data/lib/jazzy/source_module.rb +6 -6
- data/lib/jazzy/sourcekitten.rb +157 -86
- data/lib/jazzy/stats.rb +14 -3
- data/lib/jazzy/symbol_graph/constraint.rb +98 -0
- data/lib/jazzy/symbol_graph/ext_node.rb +116 -0
- data/lib/jazzy/symbol_graph/graph.rb +200 -0
- data/lib/jazzy/symbol_graph/relationship.rb +48 -0
- data/lib/jazzy/symbol_graph/sym_node.rb +176 -0
- data/lib/jazzy/symbol_graph/symbol.rb +248 -0
- data/lib/jazzy/symbol_graph.rb +95 -0
- data/lib/jazzy/themes/apple/assets/css/highlight.css.scss +63 -59
- data/lib/jazzy/themes/apple/assets/css/jazzy.css.scss +26 -2
- data/lib/jazzy/themes/apple/assets/js/jazzy.js +4 -0
- data/lib/jazzy/themes/apple/assets/js/jazzy.search.js +4 -0
- data/lib/jazzy/themes/apple/assets/js/jquery.min.js +2 -2
- data/lib/jazzy/themes/apple/assets/js/lunr.min.js +3 -3
- data/lib/jazzy/themes/apple/templates/doc.mustache +4 -5
- data/lib/jazzy/themes/apple/templates/footer.mustache +1 -1
- data/lib/jazzy/themes/apple/templates/header.mustache +6 -6
- data/lib/jazzy/themes/apple/templates/task.mustache +6 -11
- data/lib/jazzy/themes/fullwidth/assets/css/highlight.css.scss +63 -59
- data/lib/jazzy/themes/fullwidth/assets/css/jazzy.css.scss +11 -2
- data/lib/jazzy/themes/fullwidth/assets/js/jazzy.js +4 -0
- data/lib/jazzy/themes/fullwidth/assets/js/jazzy.search.js +4 -0
- data/lib/jazzy/themes/fullwidth/assets/js/jquery.min.js +2 -2
- data/lib/jazzy/themes/fullwidth/assets/js/lunr.min.js +3 -3
- data/lib/jazzy/themes/fullwidth/templates/doc.mustache +4 -5
- data/lib/jazzy/themes/fullwidth/templates/footer.mustache +1 -1
- data/lib/jazzy/themes/fullwidth/templates/header.mustache +8 -8
- data/lib/jazzy/themes/fullwidth/templates/task.mustache +6 -11
- data/lib/jazzy/themes/jony/assets/css/highlight.css.scss +63 -59
- data/lib/jazzy/themes/jony/assets/css/jazzy.css.scss +26 -2
- data/lib/jazzy/themes/jony/assets/js/jazzy.js +4 -0
- data/lib/jazzy/themes/jony/assets/js/jquery.min.js +2 -2
- data/lib/jazzy/themes/jony/templates/doc.mustache +4 -5
- data/lib/jazzy/themes/jony/templates/footer.mustache +1 -1
- data/lib/jazzy/themes/jony/templates/header.mustache +6 -6
- data/lib/jazzy/themes/jony/templates/task.mustache +6 -11
- data/lib/jazzy.rb +2 -0
- data/spec/integration_spec.rb +59 -45
- data/spec/spec_helper/pre_flight.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- metadata +39 -19
- data/.circleci/config.yml +0 -83
- data/lib/jazzy/themes/fullwidth/assets/img/gh.png +0 -0
- data/lib/jazzy/themes/jony/assets/img/gh.png +0 -0
- data/spec/sourcekitten_spec.rb +0 -6
data/js/package.json
CHANGED
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
|
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
|
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/
|
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
|
-
|
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
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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
|
-
|
177
|
+
'sourcekitten.',
|
174
178
|
default: []
|
175
179
|
|
176
180
|
alias_config_attr :xcodebuild_arguments, :build_tool_arguments,
|
@@ -192,7 +196,7 @@ module Jazzy
|
|
192
196
|
config_attr :excluded_files,
|
193
197
|
command_line: ['-e', '--exclude filepath1,filepath2,…filepathN', Array],
|
194
198
|
description: 'Source file pathnames to be excluded from documentation. '\
|
195
|
-
|
199
|
+
'Supports wildcards.',
|
196
200
|
default: [],
|
197
201
|
parse: ->(files) do
|
198
202
|
Array(files).map { |f| expand_glob_path(f).to_s }
|
@@ -201,7 +205,7 @@ module Jazzy
|
|
201
205
|
config_attr :included_files,
|
202
206
|
command_line: ['-i', '--include filepath1,filepath2,…filepathN', Array],
|
203
207
|
description: 'Source file pathnames to be included in documentation. '\
|
204
|
-
|
208
|
+
'Supports wildcards.',
|
205
209
|
default: [],
|
206
210
|
parse: ->(files) do
|
207
211
|
Array(files).map { |f| expand_glob_path(f).to_s }
|
@@ -213,24 +217,26 @@ module Jazzy
|
|
213
217
|
parse: ->(v) do
|
214
218
|
if v.to_s.empty?
|
215
219
|
nil
|
220
|
+
elsif v.to_f < 2
|
221
|
+
raise 'jazzy only supports Swift 2.0 or later.'
|
216
222
|
else
|
217
|
-
raise 'jazzy only supports Swift 2.0 or later.' if v.to_f < 2
|
218
223
|
v
|
219
224
|
end
|
220
225
|
end
|
221
226
|
|
222
|
-
SWIFT_BUILD_TOOLS = %w[spm xcodebuild].freeze
|
227
|
+
SWIFT_BUILD_TOOLS = %w[spm xcodebuild symbolgraph].freeze
|
223
228
|
|
224
229
|
config_attr :swift_build_tool,
|
225
230
|
command_line: "--swift-build-tool #{SWIFT_BUILD_TOOLS.join(' | ')}",
|
226
|
-
description: 'Control whether Jazzy uses Swift Package Manager
|
227
|
-
|
228
|
-
|
229
|
-
|
231
|
+
description: 'Control whether Jazzy uses Swift Package Manager, '\
|
232
|
+
'xcodebuild, or swift-symbolgraph to build the module '\
|
233
|
+
'to be documented. By default it uses xcodebuild if '\
|
234
|
+
'there is a .xcodeproj file in the source directory.',
|
230
235
|
parse: ->(tool) do
|
231
236
|
return tool.to_sym if SWIFT_BUILD_TOOLS.include?(tool)
|
237
|
+
|
232
238
|
raise "Unsupported swift_build_tool #{tool}, "\
|
233
|
-
|
239
|
+
"supported values: #{SWIFT_BUILD_TOOLS.join(', ')}"
|
234
240
|
end
|
235
241
|
|
236
242
|
# ──────── Metadata ────────
|
@@ -253,14 +259,14 @@ module Jazzy
|
|
253
259
|
|
254
260
|
config_attr :version,
|
255
261
|
command_line: '--module-version VERSION',
|
256
|
-
description: 'Version string to use as part of the
|
257
|
-
|
262
|
+
description: 'Version string to use as part of the default docs '\
|
263
|
+
'title and inside the docset.',
|
258
264
|
default: '1.0'
|
259
265
|
|
260
266
|
config_attr :title,
|
261
267
|
command_line: '--title TITLE',
|
262
268
|
description: 'Title to display at the top of each page, overriding the '\
|
263
|
-
|
269
|
+
'default generated from module name and version.',
|
264
270
|
default: ''
|
265
271
|
|
266
272
|
config_attr :copyright,
|
@@ -285,16 +291,16 @@ module Jazzy
|
|
285
291
|
config_attr :podspec,
|
286
292
|
command_line: '--podspec FILEPATH',
|
287
293
|
description: 'A CocoaPods Podspec that describes the Swift library to '\
|
288
|
-
|
294
|
+
'document',
|
289
295
|
parse: ->(ps) { PodspecDocumenter.create_podspec(Pathname(ps)) if ps },
|
290
296
|
default: Dir['*.podspec{,.json}'].first
|
291
297
|
|
292
298
|
config_attr :pod_sources,
|
293
299
|
command_line: ['--pod-sources url1,url2,…urlN', Array],
|
294
300
|
description: 'A list of sources to find pod dependencies. Used only '\
|
295
|
-
|
296
|
-
|
297
|
-
|
301
|
+
'with --podspec when the podspec contains references to '\
|
302
|
+
'privately hosted pods. You must include the default pod '\
|
303
|
+
'source if public pods are also used.',
|
298
304
|
default: []
|
299
305
|
|
300
306
|
config_attr :docset_icon,
|
@@ -316,30 +322,56 @@ module Jazzy
|
|
316
322
|
config_attr :dash_url,
|
317
323
|
command_line: ['-d', '--dash_url URL'],
|
318
324
|
description: 'Location of the dash XML feed '\
|
319
|
-
|
325
|
+
'e.g. https://realm.io/docsets/realm.xml)',
|
320
326
|
parse: ->(d) { URI(d) }
|
321
327
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
328
|
+
SOURCE_HOSTS = %w[github gitlab bitbucket].freeze
|
329
|
+
|
330
|
+
config_attr :source_host,
|
331
|
+
command_line: "--source-host #{SOURCE_HOSTS.join(' | ')}",
|
332
|
+
description: ['The source-code hosting site to be linked from documentation.',
|
333
|
+
'This setting affects the logo image and link format.',
|
334
|
+
"Default: 'github'"],
|
335
|
+
default: 'github',
|
336
|
+
parse: ->(host) do
|
337
|
+
return host.to_sym if SOURCE_HOSTS.include?(host)
|
338
|
+
|
339
|
+
raise "Unsupported source_host '#{host}', "\
|
340
|
+
"supported values: #{SOURCE_HOSTS.join(', ')}"
|
341
|
+
end
|
342
|
+
|
343
|
+
config_attr :source_host_url,
|
344
|
+
command_line: ['--source-host-url URL'],
|
345
|
+
description: ["URL to link from the source host's logo.",
|
346
|
+
'For example https://github.com/realm/realm-cocoa'],
|
326
347
|
parse: ->(g) { URI(g) }
|
327
348
|
|
328
|
-
|
349
|
+
alias_config_attr :github_url, :source_host_url,
|
350
|
+
command_line: ['-g', '--github_url URL'],
|
351
|
+
description: 'Back-compatibility alias for source_host_url.'
|
352
|
+
|
353
|
+
config_attr :source_host_files_url,
|
354
|
+
command_line: '--source-host-files-url PREFIX',
|
355
|
+
description: [
|
356
|
+
"The base URL on the source host of the project's files, to link "\
|
357
|
+
'from individual declarations.',
|
358
|
+
'For example https://github.com/realm/realm-cocoa/tree/v0.87.1',
|
359
|
+
]
|
360
|
+
|
361
|
+
alias_config_attr :github_file_prefix, :source_host_files_url,
|
329
362
|
command_line: '--github-file-prefix PREFIX',
|
330
|
-
description: '
|
331
|
-
'https://github.com/realm/realm-cocoa/tree/v0.87.1)'
|
363
|
+
description: 'Back-compatibility alias for source_host_files_url'
|
332
364
|
|
333
365
|
config_attr :docset_playground_url,
|
334
366
|
command_line: '--docset-playground-url URL',
|
335
367
|
description: 'URL of an interactive playground to demonstrate the '\
|
336
|
-
|
368
|
+
'framework, linked to from the docset.'
|
337
369
|
|
338
370
|
# ──────── Doc generation options ────────
|
339
371
|
config_attr :disable_search,
|
340
372
|
command_line: '--disable-search',
|
341
|
-
description:
|
342
|
-
|
373
|
+
description: 'Avoid generating a search index. '\
|
374
|
+
'Search is available in some themes.',
|
343
375
|
default: false
|
344
376
|
|
345
377
|
config_attr :skip_documentation,
|
@@ -359,7 +391,7 @@ module Jazzy
|
|
359
391
|
config_attr :skip_undocumented,
|
360
392
|
command_line: '--[no-]skip-undocumented',
|
361
393
|
description: "Don't document declarations that have no documentation "\
|
362
|
-
|
394
|
+
'comments.',
|
363
395
|
default: false
|
364
396
|
|
365
397
|
config_attr :hide_documentation_coverage,
|
@@ -368,22 +400,22 @@ module Jazzy
|
|
368
400
|
default: false
|
369
401
|
|
370
402
|
config_attr :custom_categories,
|
371
|
-
description:
|
372
|
-
|
373
|
-
|
374
|
-
|
403
|
+
description: 'Custom navigation categories to replace the standard '\
|
404
|
+
"'Classes', 'Protocols', etc. Types not explicitly named "\
|
405
|
+
'in a custom category appear in generic groups at the '\
|
406
|
+
'end. Example: https://git.io/v4Bcp',
|
375
407
|
default: []
|
376
408
|
|
377
409
|
config_attr :custom_categories_unlisted_prefix,
|
378
410
|
description: "Prefix for navigation section names that aren't "\
|
379
|
-
|
411
|
+
'explicitly listed in `custom_categories`.',
|
380
412
|
default: 'Other '
|
381
413
|
|
382
414
|
config_attr :hide_unlisted_documentation,
|
383
415
|
command_line: '--[no-]hide-unlisted-documentation',
|
384
416
|
description: "Don't include documentation in the sidebar from the "\
|
385
|
-
|
386
|
-
|
417
|
+
"`documentation` config value that aren't explicitly "\
|
418
|
+
'listed in `custom_categories`.',
|
387
419
|
default: false
|
388
420
|
|
389
421
|
config_attr :custom_head,
|
@@ -391,15 +423,15 @@ module Jazzy
|
|
391
423
|
description: 'Custom HTML to inject into <head></head>.',
|
392
424
|
default: ''
|
393
425
|
|
394
|
-
BUILTIN_THEME_DIR = Pathname(
|
426
|
+
BUILTIN_THEME_DIR = Pathname(__dir__) + 'themes'
|
395
427
|
BUILTIN_THEMES = BUILTIN_THEME_DIR.children(false).map(&:to_s)
|
396
428
|
|
397
429
|
config_attr :theme_directory,
|
398
430
|
command_line: "--theme [#{BUILTIN_THEMES.join(' | ')} | DIRPATH]",
|
399
431
|
description: "Which theme to use. Specify either 'apple' (default), "\
|
400
|
-
|
401
|
-
|
402
|
-
|
432
|
+
'one of the other built-in theme names, or the path to '\
|
433
|
+
'your mustache templates and other assets for a custom '\
|
434
|
+
'theme.',
|
403
435
|
default: 'apple',
|
404
436
|
parse: ->(t) do
|
405
437
|
if BUILTIN_THEMES.include?(t)
|
@@ -412,9 +444,9 @@ module Jazzy
|
|
412
444
|
config_attr :use_safe_filenames,
|
413
445
|
command_line: '--use-safe-filenames',
|
414
446
|
description: 'Replace unsafe characters in filenames with an encoded '\
|
415
|
-
|
416
|
-
|
417
|
-
|
447
|
+
'representation. This will reduce human readability of '\
|
448
|
+
'some URLs, but may be necessary for projects that '\
|
449
|
+
'expose filename-unfriendly functions such as /(_:_:)',
|
418
450
|
default: false
|
419
451
|
|
420
452
|
config_attr :template_directory,
|
@@ -434,17 +466,23 @@ module Jazzy
|
|
434
466
|
config_attr :undocumented_text,
|
435
467
|
command_line: '--undocumented-text UNDOCUMENTED_TEXT',
|
436
468
|
description: 'Default text for undocumented symbols. The default '\
|
437
|
-
|
469
|
+
'is "Undocumented", put "" if no text is required',
|
438
470
|
default: 'Undocumented'
|
439
471
|
|
440
472
|
config_attr :separate_global_declarations,
|
441
473
|
command_line: '--[no-]separate-global-declarations',
|
442
474
|
description: 'Create separate pages for all global declarations '\
|
443
|
-
|
444
|
-
|
475
|
+
"(classes, structures, enums etc.) even if they don't "\
|
476
|
+
'have children.',
|
477
|
+
default: false
|
478
|
+
|
479
|
+
config_attr :include_spi_declarations,
|
480
|
+
command_line: '--[no-]include-spi-declarations',
|
481
|
+
description: 'Include Swift declarations marked `@_spi` even if '\
|
482
|
+
'--min-acl is set to `public` or `open`.',
|
445
483
|
default: false
|
446
484
|
|
447
|
-
# rubocop:enable
|
485
|
+
# rubocop:enable Layout/ArgumentAlignment
|
448
486
|
|
449
487
|
def initialize
|
450
488
|
self.class.all_config_attrs.each do |attr|
|
@@ -457,7 +495,6 @@ module Jazzy
|
|
457
495
|
Doc.template_path = theme_directory + 'templates'
|
458
496
|
end
|
459
497
|
|
460
|
-
# rubocop:disable Metrics/MethodLength
|
461
498
|
def self.parse!
|
462
499
|
config = new
|
463
500
|
config.parse_command_line
|
@@ -471,9 +508,16 @@ module Jazzy
|
|
471
508
|
)
|
472
509
|
end
|
473
510
|
|
511
|
+
config.validate
|
512
|
+
|
474
513
|
config
|
475
514
|
end
|
476
515
|
|
516
|
+
def warning(message)
|
517
|
+
warn "WARNING: #{message}"
|
518
|
+
end
|
519
|
+
|
520
|
+
# rubocop:disable Metrics/MethodLength
|
477
521
|
def parse_command_line
|
478
522
|
OptionParser.new do |opt|
|
479
523
|
opt.banner = 'Usage: jazzy'
|
@@ -485,7 +529,7 @@ module Jazzy
|
|
485
529
|
end
|
486
530
|
|
487
531
|
opt.on('-v', '--version', 'Print version number') do
|
488
|
-
puts
|
532
|
+
puts "jazzy version: #{Jazzy::VERSION}"
|
489
533
|
exit
|
490
534
|
end
|
491
535
|
|
@@ -504,6 +548,10 @@ module Jazzy
|
|
504
548
|
exit
|
505
549
|
end
|
506
550
|
end.parse!
|
551
|
+
|
552
|
+
unless ARGV.empty?
|
553
|
+
warning "Leftover unused command-line text: #{ARGV}"
|
554
|
+
end
|
507
555
|
end
|
508
556
|
|
509
557
|
def parse_config_file
|
@@ -521,13 +569,12 @@ module Jazzy
|
|
521
569
|
|
522
570
|
config_file.each do |key, value|
|
523
571
|
unless attr = attrs_by_conf_key[key]
|
524
|
-
message = "
|
572
|
+
message = "Unknown config file attribute #{key.inspect}"
|
525
573
|
if matching_name = attrs_by_name[key]
|
526
|
-
message
|
527
|
-
|
528
|
-
message << '?)'
|
574
|
+
message +=
|
575
|
+
" (Did you mean #{matching_name.first.config_file_key.inspect}?)"
|
529
576
|
end
|
530
|
-
|
577
|
+
warning message
|
531
578
|
next
|
532
579
|
end
|
533
580
|
|
@@ -537,6 +584,17 @@ module Jazzy
|
|
537
584
|
self.base_path = nil
|
538
585
|
end
|
539
586
|
|
587
|
+
def validate
|
588
|
+
if source_host_configured &&
|
589
|
+
source_host_url.nil? &&
|
590
|
+
source_host_files_url.nil?
|
591
|
+
warning 'Option `source_host` is set but has no effect without either '\
|
592
|
+
'`source_host_url` or `source_host_files_url`.'
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
# rubocop:enable Metrics/MethodLength
|
597
|
+
|
540
598
|
def locate_config_file
|
541
599
|
return config_file if config_file
|
542
600
|
|
@@ -550,15 +608,10 @@ module Jazzy
|
|
550
608
|
|
551
609
|
def read_config_file(file)
|
552
610
|
case File.extname(file)
|
553
|
-
when '.json'
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
else
|
558
|
-
# rubocop:disable Security/YAMLLoad
|
559
|
-
YAML.load(File.read(file))
|
560
|
-
# rubocop:enable Security/YAMLLoad
|
561
|
-
end
|
611
|
+
when '.json'
|
612
|
+
JSON.parse(File.read(file))
|
613
|
+
when '.yaml', '.yml'
|
614
|
+
YAML.safe_load(File.read(file))
|
562
615
|
else raise "Config file must be .yaml or .json, but got #{file.inspect}"
|
563
616
|
end
|
564
617
|
end
|
@@ -575,7 +628,7 @@ module Jazzy
|
|
575
628
|
|
576
629
|
The config file can be in YAML or JSON format. Available options are:
|
577
630
|
|
578
|
-
|
631
|
+
_EOS_
|
579
632
|
.gsub(/^ +/, '')
|
580
633
|
|
581
634
|
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
|
"© #{year} [#{config.author_name}](#{config.author_url}). " \
|
21
|
-
|
23
|
+
"All rights reserved. (Last updated: #{date})"
|
22
24
|
)
|
23
25
|
Markdown.render_copyright(copyright).chomp
|
24
26
|
end
|