jazzy 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -3
- data/CHANGELOG.md +52 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +44 -44
- data/README.md +44 -6
- data/bin/sourcekitten +0 -0
- data/jazzy.gemspec +5 -5
- data/lib/jazzy/config.rb +8 -3
- data/lib/jazzy/doc_builder.rb +12 -4
- data/lib/jazzy/documentation_generator.rb +0 -7
- data/lib/jazzy/gem_version.rb +1 -1
- data/lib/jazzy/podspec_documenter.rb +19 -2
- data/lib/jazzy/source_declaration.rb +15 -4
- data/lib/jazzy/source_declaration/type.rb +11 -1
- data/lib/jazzy/source_document.rb +18 -2
- data/lib/jazzy/sourcekitten.rb +41 -17
- data/lib/jazzy/themes/apple/assets/css/jazzy.css.scss +9 -5
- data/lib/jazzy/themes/apple/templates/deprecation.mustache +12 -0
- data/lib/jazzy/themes/apple/templates/doc.mustache +1 -0
- data/lib/jazzy/themes/apple/templates/task.mustache +12 -0
- data/lib/jazzy/themes/fullwidth/assets/css/jazzy.css.scss +10 -4
- data/lib/jazzy/themes/fullwidth/assets/js/jazzy.search.js +2 -1
- data/lib/jazzy/themes/fullwidth/templates/deprecation.mustache +12 -0
- data/lib/jazzy/themes/fullwidth/templates/doc.mustache +1 -0
- data/lib/jazzy/themes/fullwidth/templates/task.mustache +12 -0
- data/lib/jazzy/themes/jony/assets/css/jazzy.css.scss +5 -2
- data/lib/jazzy/themes/jony/templates/deprecation.mustache +12 -0
- data/lib/jazzy/themes/jony/templates/doc.mustache +1 -0
- data/lib/jazzy/themes/jony/templates/task.mustache +12 -0
- data/spec/integration_spec.rb +1 -1
- metadata +16 -14
- data/lib/jazzy/readme_generator.rb +0 -61
data/lib/jazzy/doc_builder.rb
CHANGED
@@ -10,7 +10,6 @@ require 'jazzy/documentation_generator'
|
|
10
10
|
require 'jazzy/search_builder'
|
11
11
|
require 'jazzy/jazzy_markdown'
|
12
12
|
require 'jazzy/podspec_documenter'
|
13
|
-
require 'jazzy/readme_generator'
|
14
13
|
require 'jazzy/source_declaration'
|
15
14
|
require 'jazzy/source_document'
|
16
15
|
require 'jazzy/source_module'
|
@@ -95,7 +94,7 @@ module Jazzy
|
|
95
94
|
|
96
95
|
def self.each_doc(output_dir, docs, &block)
|
97
96
|
docs.each do |doc|
|
98
|
-
next unless doc.
|
97
|
+
next unless doc.render_as_page?
|
99
98
|
# Assuming URL is relative to documentation root:
|
100
99
|
path = output_dir + (doc.url || "#{doc.name}.html")
|
101
100
|
block.call(doc, path)
|
@@ -332,6 +331,7 @@ module Jazzy
|
|
332
331
|
# Build mustache item for a top-level doc
|
333
332
|
# @param [Hash] item Parsed doc child item
|
334
333
|
# @param [Config] options Build options
|
334
|
+
# rubocop:disable Metrics/MethodLength
|
335
335
|
def self.render_item(item, source_module)
|
336
336
|
# Combine abstract and discussion into abstract
|
337
337
|
abstract = (item.abstract || '') + (item.discussion || '')
|
@@ -347,11 +347,16 @@ module Jazzy
|
|
347
347
|
from_protocol_extension: item.from_protocol_extension,
|
348
348
|
return: item.return,
|
349
349
|
parameters: (item.parameters if item.parameters.any?),
|
350
|
-
url: (item.url if item.
|
350
|
+
url: (item.url if item.render_as_page?),
|
351
351
|
start_line: item.start_line,
|
352
352
|
end_line: item.end_line,
|
353
|
+
direct_link: item.omit_content_from_parent?,
|
354
|
+
deprecation_message: item.deprecation_message,
|
355
|
+
unavailable_message: item.unavailable_message,
|
356
|
+
usage_discouraged: item.usage_discouraged?,
|
353
357
|
}
|
354
358
|
end
|
359
|
+
# rubocop:enable Metrics/MethodLength
|
355
360
|
|
356
361
|
def self.make_task(mark, uid, items)
|
357
362
|
{
|
@@ -391,7 +396,7 @@ module Jazzy
|
|
391
396
|
# @param [Array] doc_structure doc structure comprised of section names and
|
392
397
|
# child names and URLs. @see doc_structure_for_docs
|
393
398
|
def self.document(source_module, doc_model, path_to_root)
|
394
|
-
if doc_model.type.
|
399
|
+
if doc_model.type.markdown?
|
395
400
|
return document_markdown(source_module, doc_model, path_to_root)
|
396
401
|
end
|
397
402
|
|
@@ -418,6 +423,9 @@ module Jazzy
|
|
418
423
|
doc[:github_url] = source_module.github_url
|
419
424
|
doc[:dash_url] = source_module.dash_url
|
420
425
|
doc[:path_to_root] = path_to_root
|
426
|
+
doc[:deprecation_message] = doc_model.deprecation_message
|
427
|
+
doc[:unavailable_message] = doc_model.unavailable_message
|
428
|
+
doc[:usage_discouraged] = doc_model.usage_discouraged?
|
421
429
|
doc.render.gsub(ELIDED_AUTOLINK_TOKEN, path_to_root)
|
422
430
|
end
|
423
431
|
# rubocop:enable Metrics/MethodLength
|
@@ -11,15 +11,8 @@ module Jazzy
|
|
11
11
|
documentation_entries.map do |file_path|
|
12
12
|
SourceDocument.new.tap do |sd|
|
13
13
|
sd.name = File.basename(file_path, '.md')
|
14
|
-
sd.url = sd.name.downcase.strip
|
15
|
-
.tr(' ', '-').gsub(/[^\w-]/, '') + '.html'
|
16
|
-
sd.type = SourceDeclaration::Type.new 'document.markdown'
|
17
|
-
sd.children = []
|
18
14
|
sd.overview = overview Pathname(file_path)
|
19
15
|
sd.usr = 'documentation.' + sd.name
|
20
|
-
sd.abstract = ''
|
21
|
-
sd.return = ''
|
22
|
-
sd.parameters = []
|
23
16
|
end
|
24
17
|
end
|
25
18
|
end
|
data/lib/jazzy/gem_version.rb
CHANGED
@@ -27,8 +27,8 @@ module Jazzy
|
|
27
27
|
|
28
28
|
targets.map do |t|
|
29
29
|
args = %W[doc --module-name #{podspec.module_name} -- -target #{t}]
|
30
|
-
swift_version = (config.swift_version
|
31
|
-
args << "SWIFT_VERSION
|
30
|
+
swift_version = compiler_swift_version(config.swift_version)
|
31
|
+
args << "SWIFT_VERSION=#{swift_version}"
|
32
32
|
SourceKitten.run_sourcekitten(args)
|
33
33
|
end
|
34
34
|
end
|
@@ -97,6 +97,23 @@ module Jazzy
|
|
97
97
|
|
98
98
|
private_class_method :github_file_prefix
|
99
99
|
|
100
|
+
# Latest valid value for SWIFT_VERSION.
|
101
|
+
LATEST_SWIFT_VERSION = '4.2'.freeze
|
102
|
+
|
103
|
+
# All valid values for SWIFT_VERSION that are longer
|
104
|
+
# than a major version number. Ordered ascending.
|
105
|
+
LONG_SWIFT_VERSIONS = ['4.2'].freeze
|
106
|
+
|
107
|
+
# Go from a full Swift version like 4.2.1 to
|
108
|
+
# something valid for SWIFT_VERSION.
|
109
|
+
def compiler_swift_version(user_version)
|
110
|
+
return LATEST_SWIFT_VERSION unless user_version
|
111
|
+
|
112
|
+
LONG_SWIFT_VERSIONS.select do |version|
|
113
|
+
user_version.start_with?(version)
|
114
|
+
end.last || "#{user_version[0]}.0"
|
115
|
+
end
|
116
|
+
|
100
117
|
# @!group SourceKitten output helper methods
|
101
118
|
|
102
119
|
def pod_path
|
@@ -8,12 +8,15 @@ module Jazzy
|
|
8
8
|
# static type of declared element (e.g. String.Type -> ())
|
9
9
|
attr_accessor :typename
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
# Give the item its own page or just inline into parent?
|
12
|
+
def render_as_page?
|
13
|
+
children.any?
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# When referencing this item from its parent category,
|
17
|
+
# include the content or just link to it directly?
|
18
|
+
def omit_content_from_parent?
|
19
|
+
false
|
17
20
|
end
|
18
21
|
|
19
22
|
# Element containing this declaration in the code
|
@@ -99,6 +102,14 @@ module Jazzy
|
|
99
102
|
attr_accessor :end_line
|
100
103
|
attr_accessor :nav_order
|
101
104
|
attr_accessor :url_name
|
105
|
+
attr_accessor :deprecated
|
106
|
+
attr_accessor :deprecation_message
|
107
|
+
attr_accessor :unavailable
|
108
|
+
attr_accessor :unavailable_message
|
109
|
+
|
110
|
+
def usage_discouraged?
|
111
|
+
unavailable || deprecated
|
112
|
+
end
|
102
113
|
|
103
114
|
def alternative_abstract
|
104
115
|
if file = alternative_abstract_file
|
@@ -129,6 +129,16 @@ module Jazzy
|
|
129
129
|
Type.new('Overview')
|
130
130
|
end
|
131
131
|
|
132
|
+
MARKDOWN_KIND = 'document.markdown'.freeze
|
133
|
+
|
134
|
+
def self.markdown
|
135
|
+
Type.new(MARKDOWN_KIND)
|
136
|
+
end
|
137
|
+
|
138
|
+
def markdown?
|
139
|
+
kind == MARKDOWN_KIND
|
140
|
+
end
|
141
|
+
|
132
142
|
def hash
|
133
143
|
kind.hash
|
134
144
|
end
|
@@ -140,7 +150,7 @@ module Jazzy
|
|
140
150
|
|
141
151
|
TYPES = {
|
142
152
|
# Markdown
|
143
|
-
|
153
|
+
MARKDOWN_KIND => {
|
144
154
|
jazzy: 'Guide',
|
145
155
|
dash: 'Guide',
|
146
156
|
}.freeze,
|
@@ -3,19 +3,35 @@ require 'pathname'
|
|
3
3
|
require 'jazzy/jazzy_markdown'
|
4
4
|
|
5
5
|
module Jazzy
|
6
|
+
# Standalone markdown docs including index.html
|
6
7
|
class SourceDocument < SourceDeclaration
|
7
8
|
attr_accessor :overview
|
8
9
|
attr_accessor :readme_path
|
9
10
|
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
self.children = []
|
14
|
+
self.parameters = []
|
15
|
+
self.abstract = ''
|
16
|
+
self.type = SourceDeclaration::Type.markdown
|
17
|
+
self.mark = SourceMark.new
|
18
|
+
end
|
19
|
+
|
10
20
|
def self.make_index(readme_path)
|
11
21
|
SourceDocument.new.tap do |sd|
|
12
22
|
sd.name = 'index'
|
13
|
-
sd.children = []
|
14
|
-
sd.type = SourceDeclaration::Type.new 'document.markdown'
|
15
23
|
sd.readme_path = readme_path
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
27
|
+
def render_as_page?
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def omit_content_from_parent?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
19
35
|
def config
|
20
36
|
Config.instance
|
21
37
|
end
|
data/lib/jazzy/sourcekitten.rb
CHANGED
@@ -322,6 +322,8 @@ module Jazzy
|
|
322
322
|
Highlighter.highlight(make_swift_declaration(doc, declaration))
|
323
323
|
end
|
324
324
|
|
325
|
+
make_deprecation_info(doc, declaration)
|
326
|
+
|
325
327
|
unless doc['key.doc.full_as_xml']
|
326
328
|
return process_undocumented_token(doc, declaration)
|
327
329
|
end
|
@@ -335,10 +337,23 @@ module Jazzy
|
|
335
337
|
@stats.add_documented
|
336
338
|
end
|
337
339
|
|
340
|
+
def self.make_deprecation_info(doc, declaration)
|
341
|
+
if declaration.deprecated
|
342
|
+
declaration.deprecation_message =
|
343
|
+
Markdown.render(doc['key.deprecation_message'] || '')
|
344
|
+
end
|
345
|
+
if declaration.unavailable
|
346
|
+
declaration.unavailable_message =
|
347
|
+
Markdown.render(doc['key.unavailable_message'] || '')
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
338
351
|
# Strip tags and convert entities
|
339
352
|
def self.xml_to_text(xml)
|
340
353
|
document = REXML::Document.new(xml)
|
341
354
|
REXML::XPath.match(document.root, '//text()').map(&:value).join
|
355
|
+
rescue
|
356
|
+
''
|
342
357
|
end
|
343
358
|
|
344
359
|
# Regexp to match an @attribute. Complex to handle @available().
|
@@ -372,10 +387,11 @@ module Jazzy
|
|
372
387
|
end
|
373
388
|
|
374
389
|
def self.prefer_parsed_decl?(parsed, annotated)
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
390
|
+
annotated.empty? ||
|
391
|
+
parsed &&
|
392
|
+
(annotated.include?(' = default') || # SR-2608
|
393
|
+
parsed.match('@autoclosure|@escaping') || # SR-6321
|
394
|
+
parsed.include?("\n"))
|
379
395
|
end
|
380
396
|
|
381
397
|
# Replace the fully qualified name of a type with its base name
|
@@ -479,6 +495,8 @@ module Jazzy
|
|
479
495
|
declaration.column = doc['key.doc.column']
|
480
496
|
declaration.start_line = doc['key.parsed_scope.start']
|
481
497
|
declaration.end_line = doc['key.parsed_scope.end']
|
498
|
+
declaration.deprecated = doc['key.always_deprecated']
|
499
|
+
declaration.unavailable = doc['key.always_unavailable']
|
482
500
|
|
483
501
|
next unless make_doc_info(doc, declaration)
|
484
502
|
make_substructure(doc, declaration)
|
@@ -739,28 +757,34 @@ module Jazzy
|
|
739
757
|
end
|
740
758
|
end
|
741
759
|
|
760
|
+
AUTOLINK_TEXT_FIELDS = %w[return
|
761
|
+
abstract
|
762
|
+
unavailable_message
|
763
|
+
deprecation_message].freeze
|
764
|
+
|
765
|
+
AUTOLINK_HIGHLIGHT_FIELDS = %w[declaration
|
766
|
+
other_language_declaration].freeze
|
767
|
+
|
742
768
|
def self.autolink(docs, root_decls)
|
743
769
|
@autolink_root_decls = root_decls
|
744
770
|
docs.each do |doc|
|
745
771
|
doc.children = autolink(doc.children, root_decls)
|
746
772
|
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
autolink_text(param[:discussion], doc, root_decls)
|
773
|
+
AUTOLINK_TEXT_FIELDS.each do |field|
|
774
|
+
if text = doc.send(field)
|
775
|
+
doc.send(field + '=', autolink_text(text, doc, root_decls))
|
776
|
+
end
|
752
777
|
end
|
753
778
|
|
754
|
-
|
755
|
-
|
756
|
-
doc.
|
757
|
-
|
779
|
+
AUTOLINK_HIGHLIGHT_FIELDS.each do |field|
|
780
|
+
if text = doc.send(field)
|
781
|
+
doc.send(field + '=', autolink_text(text, doc, root_decls, true))
|
782
|
+
end
|
758
783
|
end
|
759
784
|
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
)
|
785
|
+
(doc.parameters || []).each do |param|
|
786
|
+
param[:discussion] =
|
787
|
+
autolink_text(param[:discussion], doc, root_decls)
|
764
788
|
end
|
765
789
|
end
|
766
790
|
end
|
@@ -240,7 +240,7 @@ header {
|
|
240
240
|
margin-left: $content_body_left_offset;
|
241
241
|
position: absolute;
|
242
242
|
overflow: hidden;
|
243
|
-
padding-bottom:
|
243
|
+
padding-bottom: 20px;
|
244
244
|
top: $content_top_offset;
|
245
245
|
width: $content_wrapper_width - $content_body_left_offset;
|
246
246
|
p, a, code, em, ul, table, blockquote {
|
@@ -333,11 +333,14 @@ header {
|
|
333
333
|
background-color: transparent;
|
334
334
|
padding: 0;
|
335
335
|
}
|
336
|
-
.token {
|
336
|
+
.token, .direct-link {
|
337
337
|
padding-left: 3px;
|
338
338
|
margin-left: 15px;
|
339
339
|
font-size: 11.9px;
|
340
340
|
}
|
341
|
+
.discouraged {
|
342
|
+
text-decoration: line-through;
|
343
|
+
}
|
341
344
|
.declaration-note {
|
342
345
|
font-size: .85em;
|
343
346
|
color: rgba(128,128,128,1);
|
@@ -412,7 +415,7 @@ header {
|
|
412
415
|
}
|
413
416
|
}
|
414
417
|
|
415
|
-
.aside-warning {
|
418
|
+
.aside-warning, .aside-deprecated, .aside-unavailable {
|
416
419
|
border-left: $aside_warning_border;
|
417
420
|
.aside-title {
|
418
421
|
color: $aside_warning_color;
|
@@ -446,8 +449,9 @@ header {
|
|
446
449
|
}
|
447
450
|
|
448
451
|
#footer {
|
449
|
-
position:
|
450
|
-
|
452
|
+
position: relative;
|
453
|
+
top: 10px;
|
454
|
+
bottom: 0px;
|
451
455
|
margin-left: 25px;
|
452
456
|
p {
|
453
457
|
margin: 0;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{{#deprecation_message}}
|
2
|
+
<div class="aside aside-deprecated">
|
3
|
+
<p class="aside-title">Deprecated</p>
|
4
|
+
{{{deprecation_message}}}
|
5
|
+
</div>
|
6
|
+
{{/deprecation_message}}
|
7
|
+
{{#unavailable_message}}
|
8
|
+
<div class="aside aside-unavailable">
|
9
|
+
<p class="aside-title">Unavailable</p>
|
10
|
+
{{{unavailable_message}}}
|
11
|
+
</div>
|
12
|
+
{{/unavailable_message}}
|
@@ -15,7 +15,17 @@
|
|
15
15
|
<code>
|
16
16
|
<a name="/{{usr}}"></a>
|
17
17
|
<a name="//apple_ref/{{language_stub}}/{{dash_type}}/{{name}}" class="dashAnchor"></a>
|
18
|
+
{{#direct_link}}
|
19
|
+
<a class="direct-link" href="{{url}}">{{name}}</a>
|
20
|
+
</code>
|
21
|
+
{{/direct_link}}
|
22
|
+
{{^direct_link}}
|
23
|
+
{{^usage_discouraged}}
|
18
24
|
<a class="token" href="#/{{usr}}">{{name}}</a>
|
25
|
+
{{/usage_discouraged}}
|
26
|
+
{{#usage_discouraged}}
|
27
|
+
<a class="token discouraged" href="#/{{usr}}">{{name}}</a>
|
28
|
+
{{/usage_discouraged}}
|
19
29
|
</code>
|
20
30
|
{{#default_impl_abstract}}
|
21
31
|
<span class="declaration-note">
|
@@ -32,6 +42,7 @@
|
|
32
42
|
<div class="pointer-container"></div>
|
33
43
|
<section class="section">
|
34
44
|
<div class="pointer"></div>
|
45
|
+
{{> deprecation}}
|
35
46
|
{{#abstract}}
|
36
47
|
<div class="abstract">
|
37
48
|
{{{abstract}}}
|
@@ -85,6 +96,7 @@
|
|
85
96
|
</div>
|
86
97
|
{{/github_token_url}}
|
87
98
|
</section>
|
99
|
+
{{/direct_link}}
|
88
100
|
</div>
|
89
101
|
</li>
|
90
102
|
{{/items}}
|
@@ -154,8 +154,14 @@ a {
|
|
154
154
|
outline: 0;
|
155
155
|
text-decoration: underline;
|
156
156
|
}
|
157
|
-
}
|
158
157
|
|
158
|
+
&.discouraged {
|
159
|
+
text-decoration: line-through;
|
160
|
+
&:hover, &:focus {
|
161
|
+
text-decoration: underline line-through;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
159
165
|
|
160
166
|
// ----- Tables
|
161
167
|
|
@@ -404,7 +410,7 @@ pre code {
|
|
404
410
|
}
|
405
411
|
}
|
406
412
|
|
407
|
-
.token {
|
413
|
+
.token, .direct-link {
|
408
414
|
padding-left: 3px;
|
409
415
|
margin-left: 0px;
|
410
416
|
font-size: 1rem;
|
@@ -479,7 +485,7 @@ pre code {
|
|
479
485
|
}
|
480
486
|
}
|
481
487
|
|
482
|
-
.aside-warning {
|
488
|
+
.aside-warning, .aside-deprecated, .aside-unavailable {
|
483
489
|
border-left: $aside_warning_border;
|
484
490
|
.aside-title {
|
485
491
|
color: $aside_warning_color;
|
@@ -612,4 +618,4 @@ form[role=search] {
|
|
612
618
|
.tt-suggestion.tt-cursor .doc-parent-name {
|
613
619
|
color: #fff;
|
614
620
|
}
|
615
|
-
}
|
621
|
+
}
|