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/lib/jazzy/gem_version.rb
CHANGED
data/lib/jazzy/highlighter.rb
CHANGED
@@ -1,10 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rouge'
|
2
4
|
|
5
|
+
# While Rouge is downlevel (Rouge PR#1715 unreleased)
|
6
|
+
module Rouge
|
7
|
+
module Lexers
|
8
|
+
class Swift
|
9
|
+
prepend :root do
|
10
|
+
rule(/\b(?:async|await|isolated)\b/, Keyword)
|
11
|
+
rule(/\b(?:actor|nonisolated)\b/, Keyword::Declaration)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
3
17
|
module Jazzy
|
4
18
|
# This module helps highlight code
|
5
19
|
module Highlighter
|
6
|
-
SWIFT = 'swift'
|
7
|
-
OBJC = 'objective_c'
|
20
|
+
SWIFT = 'swift'
|
21
|
+
OBJC = 'objective_c'
|
8
22
|
|
9
23
|
class Formatter < Rouge::Formatters::HTML
|
10
24
|
def initialize(language)
|
@@ -12,7 +26,7 @@ module Jazzy
|
|
12
26
|
super()
|
13
27
|
end
|
14
28
|
|
15
|
-
def stream(tokens, &
|
29
|
+
def stream(tokens, &block)
|
16
30
|
yield "<pre class=\"highlight #{@language}\"><code>"
|
17
31
|
super
|
18
32
|
yield "</code></pre>\n"
|
data/lib/jazzy/jazzy_markdown.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'redcarpet'
|
2
4
|
require 'rouge'
|
3
5
|
require 'rouge/plugins/redcarpet'
|
@@ -7,32 +9,73 @@ module Jazzy
|
|
7
9
|
# Publish if generated HTML needs math support
|
8
10
|
class << self; attr_accessor :has_math; end
|
9
11
|
|
12
|
+
module Footnotes
|
13
|
+
# Global unique footnote ID
|
14
|
+
def self.next_footnote
|
15
|
+
@next_footnote ||= 0
|
16
|
+
@next_footnote += 1
|
17
|
+
end
|
18
|
+
|
19
|
+
# Per-render map from user to global ID
|
20
|
+
attr_accessor :footnotes_hash
|
21
|
+
|
22
|
+
def reset
|
23
|
+
@footnotes_hash = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def map_footnote(user_num)
|
27
|
+
footnotes_hash.fetch(user_num) do
|
28
|
+
footnotes_hash[user_num] = Footnotes.next_footnote
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def footnote_ref(num)
|
33
|
+
mapped = map_footnote(num)
|
34
|
+
"<span class='footnote-ref' id=\"fnref#{mapped}\">" \
|
35
|
+
"<sup><a href=\"#fn#{mapped}\">#{num}</a></sup></span>"
|
36
|
+
end
|
37
|
+
|
38
|
+
# follow native redcarpet: backlink goes before the first </p> tag
|
39
|
+
def footnote_def(text, num)
|
40
|
+
mapped = map_footnote(num)
|
41
|
+
"\n<li><div class='footnote-def' id=\"fn#{mapped}\">" +
|
42
|
+
text.sub(%r{(?=</p>)},
|
43
|
+
" <a href=\"#fnref#{mapped}\">↩</a>") +
|
44
|
+
'</div></li>'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# rubocop:disable Metrics/ClassLength
|
10
49
|
class JazzyHTML < Redcarpet::Render::HTML
|
11
50
|
include Redcarpet::Render::SmartyPants
|
12
51
|
include Rouge::Plugins::Redcarpet
|
52
|
+
include Footnotes
|
13
53
|
|
14
54
|
attr_accessor :default_language
|
15
55
|
|
16
56
|
def header(text, header_level)
|
17
57
|
text_slug = text.gsub(/[^[[:word:]]]+/, '-')
|
18
|
-
|
19
|
-
|
20
|
-
|
58
|
+
.downcase
|
59
|
+
.sub(/^-/, '')
|
60
|
+
.sub(/-$/, '')
|
21
61
|
|
22
62
|
"<h#{header_level} id='#{text_slug}' class='heading'>" \
|
23
63
|
"#{text}" \
|
24
|
-
|
64
|
+
"</h#{header_level}>\n"
|
25
65
|
end
|
26
66
|
|
27
67
|
def codespan(text)
|
28
|
-
|
29
|
-
|
68
|
+
case text
|
69
|
+
when /^\$\$(.*)\$\$$/m
|
70
|
+
o = ["</p><div class='math m-block'>",
|
71
|
+
Regexp.last_match[1],
|
72
|
+
'</div><p>']
|
30
73
|
Markdown.has_math = true
|
31
|
-
|
74
|
+
when /^\$(.*)\$$/m
|
32
75
|
o = ["<span class='math m-inline'>", Regexp.last_match[1], '</span>']
|
33
76
|
Markdown.has_math = true
|
34
77
|
else
|
35
|
-
o = ['<code>', text, '</code>']
|
78
|
+
o = ['<code>', text.to_s, '</code>']
|
36
79
|
end
|
37
80
|
|
38
81
|
o[0] + CGI.escapeHTML(o[1]) + o[2]
|
@@ -79,10 +122,10 @@ module Jazzy
|
|
79
122
|
# any one of our special list types
|
80
123
|
(#{SPECIAL_LIST_TYPES.map(&Regexp.method(:escape)).join('|')})
|
81
124
|
[\s:] # followed by either a space or a colon
|
82
|
-
|
125
|
+
}ix.freeze
|
83
126
|
|
84
127
|
ELIDED_LI_TOKEN =
|
85
|
-
'7wNVzLB0OYPL2eGlPKu8q4vITltqh0Y6DPZf659TPMAeYh49o'
|
128
|
+
'7wNVzLB0OYPL2eGlPKu8q4vITltqh0Y6DPZf659TPMAeYh49o'
|
86
129
|
|
87
130
|
def list_item(text, _list_type)
|
88
131
|
if text =~ SPECIAL_LIST_TYPE_REGEX
|
@@ -90,30 +133,58 @@ module Jazzy
|
|
90
133
|
if UNIQUELY_HANDLED_CALLOUTS.include? type.downcase
|
91
134
|
return ELIDED_LI_TOKEN
|
92
135
|
end
|
93
|
-
|
136
|
+
|
137
|
+
return render_list_aside(type,
|
138
|
+
text.sub(/#{Regexp.escape(type)}:\s+/, ''))
|
94
139
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
140
|
+
"<li>#{text.strip}</li>\n"
|
141
|
+
end
|
142
|
+
|
143
|
+
def render_list_aside(type, text)
|
144
|
+
"</ul>#{render_aside(type, text).chomp}<ul>\n"
|
98
145
|
end
|
99
146
|
|
100
147
|
def render_aside(type, text)
|
101
148
|
<<-HTML
|
102
|
-
|
149
|
+
<div class="aside aside-#{type.underscore.tr('_', '-')}">
|
103
150
|
<p class="aside-title">#{type.underscore.humanize}</p>
|
104
151
|
#{text}
|
105
|
-
</div
|
152
|
+
</div>
|
106
153
|
HTML
|
107
154
|
end
|
108
155
|
|
109
156
|
def list(text, list_type)
|
110
157
|
elided = text.gsub!(ELIDED_LI_TOKEN, '')
|
111
158
|
return if text =~ /\A\s*\Z/ && elided
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
159
|
+
|
160
|
+
tag = list_type == :ordered ? 'ol' : 'ul'
|
161
|
+
"\n<#{tag}>\n#{text}</#{tag}>\n"
|
162
|
+
.gsub(%r{\n?<ul>\n?</ul>}, '')
|
163
|
+
end
|
164
|
+
|
165
|
+
# List from
|
166
|
+
# https://developer.apple.com/documentation/xcode/formatting-your-documentation-content#Add-Notes-and-Other-Asides
|
167
|
+
DOCC_CALLOUTS = %w[note
|
168
|
+
important
|
169
|
+
warning
|
170
|
+
tip
|
171
|
+
experiment].freeze
|
172
|
+
|
173
|
+
DOCC_CALLOUT_REGEX = %r{
|
174
|
+
\A\s* # optional leading spaces
|
175
|
+
(?:<p>\s*)? # optional opening p tag
|
176
|
+
# any one of the callout names
|
177
|
+
(#{DOCC_CALLOUTS.map(&Regexp.method(:escape)).join('|')})
|
178
|
+
: # followed directly by a colon
|
179
|
+
}ix.freeze
|
180
|
+
|
181
|
+
def block_quote(html)
|
182
|
+
if html =~ DOCC_CALLOUT_REGEX
|
183
|
+
type = Regexp.last_match[1]
|
184
|
+
render_aside(type, html.sub(/#{Regexp.escape(type)}:\s*/, ''))
|
185
|
+
else
|
186
|
+
"\n<blockquote>\n#{html}</blockquote>\n"
|
187
|
+
end
|
117
188
|
end
|
118
189
|
|
119
190
|
def block_code(code, language)
|
@@ -124,6 +195,7 @@ module Jazzy
|
|
124
195
|
Highlighter::Formatter.new(lexer.tag)
|
125
196
|
end
|
126
197
|
end
|
198
|
+
# rubocop:enable Metrics/ClassLength
|
127
199
|
|
128
200
|
REDCARPET_OPTIONS = {
|
129
201
|
autolink: true,
|
@@ -133,6 +205,7 @@ module Jazzy
|
|
133
205
|
space_after_headers: false,
|
134
206
|
tables: true,
|
135
207
|
lax_spacing: true,
|
208
|
+
footnotes: true,
|
136
209
|
}.freeze
|
137
210
|
|
138
211
|
# Spot and capture returns & param HTML for separate display.
|
@@ -142,24 +215,25 @@ module Jazzy
|
|
142
215
|
def reset
|
143
216
|
@returns = nil
|
144
217
|
@parameters = {}
|
218
|
+
super
|
145
219
|
end
|
146
220
|
|
147
|
-
INTRO_PAT = '\A(?<intro>\s*(<p>\s*)?)'
|
148
|
-
OUTRO_PAT = '(?<outro>.*)\z'
|
221
|
+
INTRO_PAT = '\A(?<intro>\s*(<p>\s*)?)'
|
222
|
+
OUTRO_PAT = '(?<outro>.*)\z'
|
149
223
|
|
150
|
-
RETURNS_REGEX = /#{INTRO_PAT}returns:#{OUTRO_PAT}/im
|
224
|
+
RETURNS_REGEX = /#{INTRO_PAT}returns:#{OUTRO_PAT}/im.freeze
|
151
225
|
|
152
|
-
IDENT_PAT = '(?<param>\S+)'
|
226
|
+
IDENT_PAT = '(?<param>\S+)'
|
153
227
|
|
154
228
|
# Param formats: normal swift, objc via sourcekitten, and
|
155
229
|
# possibly inside 'Parameters:'
|
156
|
-
PARAM_PAT1 = "(parameter +#{IDENT_PAT}\\s*:)"
|
157
|
-
PARAM_PAT2 = "(parameter:\\s*#{IDENT_PAT}\\s+)"
|
158
|
-
PARAM_PAT3 = "(#{IDENT_PAT}\\s*:)"
|
230
|
+
PARAM_PAT1 = "(parameter +#{IDENT_PAT}\\s*:)"
|
231
|
+
PARAM_PAT2 = "(parameter:\\s*#{IDENT_PAT}\\s+)"
|
232
|
+
PARAM_PAT3 = "(#{IDENT_PAT}\\s*:)"
|
159
233
|
|
160
|
-
PARAM_PAT = "(?:#{PARAM_PAT1}|#{PARAM_PAT2}|#{PARAM_PAT3})"
|
234
|
+
PARAM_PAT = "(?:#{PARAM_PAT1}|#{PARAM_PAT2}|#{PARAM_PAT3})"
|
161
235
|
|
162
|
-
PARAM_REGEX = /#{INTRO_PAT}#{PARAM_PAT}#{OUTRO_PAT}/im
|
236
|
+
PARAM_REGEX = /#{INTRO_PAT}#{PARAM_PAT}#{OUTRO_PAT}/im.freeze
|
163
237
|
|
164
238
|
def list_item(text, _list_type)
|
165
239
|
if text =~ RETURNS_REGEX
|
@@ -187,12 +261,19 @@ module Jazzy
|
|
187
261
|
@markdown ||= Redcarpet::Markdown.new(renderer, REDCARPET_OPTIONS)
|
188
262
|
end
|
189
263
|
|
264
|
+
# Produces <p>-delimited block content
|
190
265
|
def self.render(markdown_text, default_language = nil)
|
191
266
|
renderer.reset
|
192
267
|
renderer.default_language = default_language
|
193
268
|
markdown.render(markdown_text)
|
194
269
|
end
|
195
270
|
|
271
|
+
# Produces <span>-delimited inline content
|
272
|
+
def self.render_inline(markdown_text, default_language = nil)
|
273
|
+
render(markdown_text, default_language)
|
274
|
+
.sub(%r{^<p>(.*)</p>$}, '<span>\1</span>')
|
275
|
+
end
|
276
|
+
|
196
277
|
def self.rendered_returns
|
197
278
|
renderer.returns
|
198
279
|
end
|
@@ -204,7 +285,7 @@ module Jazzy
|
|
204
285
|
class JazzyCopyright < Redcarpet::Render::HTML
|
205
286
|
def link(link, _title, content)
|
206
287
|
%(<a class="link" href="#{link}" target="_blank" \
|
207
|
-
rel="external">#{content}</a>)
|
288
|
+
rel="external noopener">#{content}</a>)
|
208
289
|
end
|
209
290
|
end
|
210
291
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'tmpdir'
|
2
4
|
require 'json'
|
3
5
|
|
@@ -22,8 +24,8 @@ module Jazzy
|
|
22
24
|
installer.install!
|
23
25
|
stdout = Dir.chdir(sandbox.root) do
|
24
26
|
targets = installer.pod_targets
|
25
|
-
|
26
|
-
|
27
|
+
.select { |pt| pt.pod_name == podspec.root.name }
|
28
|
+
.map(&:label)
|
27
29
|
|
28
30
|
targets.map do |t|
|
29
31
|
args = %W[doc --module-name #{podspec.module_name} -- -target #{t}]
|
@@ -42,8 +44,6 @@ module Jazzy
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
46
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
47
47
|
# rubocop:disable Metrics/MethodLength
|
48
48
|
def self.apply_config_defaults(podspec, config)
|
49
49
|
return unless podspec
|
@@ -64,9 +64,9 @@ module Jazzy
|
|
64
64
|
config.version = podspec.version.to_s
|
65
65
|
config.version_configured = true
|
66
66
|
end
|
67
|
-
unless config.
|
68
|
-
config.
|
69
|
-
config.
|
67
|
+
unless config.source_host_files_url_configured
|
68
|
+
config.source_host_files_url = github_file_prefix(podspec)
|
69
|
+
config.source_host_files_url_configured = true
|
70
70
|
end
|
71
71
|
unless config.swift_version_configured
|
72
72
|
trunk_swift_build = podspec.attributes_hash['pushed_with_swift_version']
|
@@ -74,8 +74,6 @@ module Jazzy
|
|
74
74
|
config.swift_version_configured = true
|
75
75
|
end
|
76
76
|
end
|
77
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
78
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
79
77
|
# rubocop:enable Metrics/MethodLength
|
80
78
|
|
81
79
|
private
|
@@ -94,17 +92,17 @@ module Jazzy
|
|
94
92
|
|
95
93
|
def self.github_file_prefix(podspec)
|
96
94
|
return unless podspec.source[:url] =~ %r{github.com[:/]+(.+)/(.+)}
|
95
|
+
|
97
96
|
org, repo = Regexp.last_match
|
98
|
-
return unless org && repo
|
99
|
-
repo.sub!(/\.git$/, '')
|
100
97
|
return unless rev = podspec.source[:tag] || podspec.source[:commit]
|
101
|
-
|
98
|
+
|
99
|
+
"https://github.com/#{org}/#{repo.sub(/\.git$/, '')}/blob/#{rev}"
|
102
100
|
end
|
103
101
|
|
104
102
|
private_class_method :github_file_prefix
|
105
103
|
|
106
104
|
# Latest valid value for SWIFT_VERSION.
|
107
|
-
LATEST_SWIFT_VERSION = '5'
|
105
|
+
LATEST_SWIFT_VERSION = '5'
|
108
106
|
|
109
107
|
# All valid values for SWIFT_VERSION that are longer
|
110
108
|
# than a major version number. Ordered ascending.
|
@@ -162,9 +160,8 @@ module Jazzy
|
|
162
160
|
# Travis builds take too long when building docs for all available
|
163
161
|
# platforms for the Moya integration spec, so we just document OSX.
|
164
162
|
# TODO: remove once jazzy is fast enough.
|
165
|
-
if ENV['JAZZY_INTEGRATION_SPECS']
|
166
|
-
|
167
|
-
end
|
163
|
+
next if ENV['JAZZY_INTEGRATION_SPECS'] && p.name != :osx
|
164
|
+
|
168
165
|
target("Jazzy-#{ss.name.gsub('/', '__')}-#{p.name}") do
|
169
166
|
use_frameworks!
|
170
167
|
platform p.name, p.deployment_target
|
@@ -177,4 +174,5 @@ module Jazzy
|
|
177
174
|
end
|
178
175
|
# rubocop:enable Metrics/MethodLength
|
179
176
|
end
|
177
|
+
# rubocop:enable Metrics/ClassLength
|
180
178
|
end
|
data/lib/jazzy/search_builder.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jazzy
|
2
4
|
module SearchBuilder
|
3
5
|
def self.build(source_module, output_dir)
|
4
6
|
decls = source_module.all_declarations.select do |d|
|
5
7
|
d.type && d.name && !d.name.empty?
|
6
8
|
end
|
7
|
-
index =
|
9
|
+
index = decls.map do |d|
|
8
10
|
[d.url,
|
9
11
|
{
|
10
12
|
name: d.name,
|
11
13
|
abstract: d.abstract && d.abstract.split(/\n/).map(&:strip).first,
|
12
14
|
parent_name: d.parent_in_code && d.parent_in_code.name,
|
13
15
|
}.reject { |_, v| v.nil? || v.empty? }]
|
14
|
-
end
|
15
|
-
]
|
16
|
+
end.to_h
|
16
17
|
File.open(File.join(output_dir, 'search.json'), 'w') do |f|
|
17
18
|
f.write(index.to_json)
|
18
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Jazzy
|
2
4
|
class SourceDeclaration
|
3
5
|
class AccessControlLevel
|
@@ -5,12 +7,12 @@ module Jazzy
|
|
5
7
|
|
6
8
|
attr_reader :level
|
7
9
|
|
8
|
-
ACCESSIBILITY_PRIVATE = 'source.lang.swift.accessibility.private'
|
10
|
+
ACCESSIBILITY_PRIVATE = 'source.lang.swift.accessibility.private'
|
9
11
|
ACCESSIBILITY_FILEPRIVATE =
|
10
|
-
'source.lang.swift.accessibility.fileprivate'
|
11
|
-
ACCESSIBILITY_INTERNAL = 'source.lang.swift.accessibility.internal'
|
12
|
-
ACCESSIBILITY_PUBLIC = 'source.lang.swift.accessibility.public'
|
13
|
-
ACCESSIBILITY_OPEN = 'source.lang.swift.accessibility.open'
|
12
|
+
'source.lang.swift.accessibility.fileprivate'
|
13
|
+
ACCESSIBILITY_INTERNAL = 'source.lang.swift.accessibility.internal'
|
14
|
+
ACCESSIBILITY_PUBLIC = 'source.lang.swift.accessibility.public'
|
15
|
+
ACCESSIBILITY_OPEN = 'source.lang.swift.accessibility.open'
|
14
16
|
|
15
17
|
def initialize(accessibility)
|
16
18
|
@level = case accessibility
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/inflector'
|
2
4
|
|
3
5
|
module Jazzy
|
@@ -10,11 +12,24 @@ module Jazzy
|
|
10
12
|
|
11
13
|
attr_reader :kind
|
12
14
|
|
13
|
-
def initialize(kind)
|
15
|
+
def initialize(kind, declaration = nil)
|
16
|
+
kind = fixup_kind(kind, declaration) if declaration
|
14
17
|
@kind = kind
|
15
18
|
@type = TYPES[kind]
|
16
19
|
end
|
17
20
|
|
21
|
+
# Improve kind from full declaration
|
22
|
+
def fixup_kind(kind, declaration)
|
23
|
+
if kind == 'source.lang.swift.decl.class' &&
|
24
|
+
declaration.include?(
|
25
|
+
'<syntaxtype.keyword>actor</syntaxtype.keyword>',
|
26
|
+
)
|
27
|
+
'source.lang.swift.decl.actor'
|
28
|
+
else
|
29
|
+
kind
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
18
33
|
def dash_type
|
19
34
|
@type && @type[:dash]
|
20
35
|
end
|
@@ -113,7 +128,8 @@ module Jazzy
|
|
113
128
|
end
|
114
129
|
|
115
130
|
def swift_extensible?
|
116
|
-
kind =~
|
131
|
+
kind =~
|
132
|
+
/^source\.lang\.swift\.decl\.(class|struct|protocol|enum|actor)$/
|
117
133
|
end
|
118
134
|
|
119
135
|
def swift_protocol?
|
@@ -151,7 +167,7 @@ module Jazzy
|
|
151
167
|
Type.new('Overview')
|
152
168
|
end
|
153
169
|
|
154
|
-
MARKDOWN_KIND = 'document.markdown'
|
170
|
+
MARKDOWN_KIND = 'document.markdown'
|
155
171
|
|
156
172
|
def self.markdown
|
157
173
|
Type.new(MARKDOWN_KIND)
|
@@ -253,6 +269,11 @@ module Jazzy
|
|
253
269
|
dash: 'Struct',
|
254
270
|
global: true,
|
255
271
|
}.freeze,
|
272
|
+
'sourcekitten.source.lang.objc.decl.union' => {
|
273
|
+
jazzy: 'Union',
|
274
|
+
dash: 'Union',
|
275
|
+
global: true,
|
276
|
+
}.freeze,
|
256
277
|
'sourcekitten.source.lang.objc.decl.field' => {
|
257
278
|
jazzy: 'Field',
|
258
279
|
dash: 'Field',
|
@@ -267,6 +288,11 @@ module Jazzy
|
|
267
288
|
}.freeze,
|
268
289
|
|
269
290
|
# Swift
|
291
|
+
'source.lang.swift.decl.actor' => {
|
292
|
+
jazzy: 'Actor',
|
293
|
+
dash: 'Actor',
|
294
|
+
global: true,
|
295
|
+
}.freeze,
|
270
296
|
'source.lang.swift.decl.function.accessor.address' => {
|
271
297
|
jazzy: 'Addressor',
|
272
298
|
dash: 'Function',
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'jazzy/source_declaration/access_control_level'
|
2
4
|
require 'jazzy/source_declaration/type'
|
3
5
|
|
4
|
-
# rubocop:disable Metrics/ClassLength
|
5
6
|
module Jazzy
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
6
8
|
class SourceDeclaration
|
7
9
|
# kind of declaration (e.g. class, variable, function)
|
8
10
|
attr_accessor :type
|
@@ -39,7 +41,7 @@ module Jazzy
|
|
39
41
|
attr_accessor :parent_in_docs
|
40
42
|
|
41
43
|
# counterpart of parent_in_docs
|
42
|
-
|
44
|
+
attr_reader :children
|
43
45
|
|
44
46
|
def children=(new_children)
|
45
47
|
# Freeze to ensure that parent_in_docs stays in sync
|
@@ -76,7 +78,7 @@ module Jazzy
|
|
76
78
|
# of the extended objc class and the category name itself, i.e.
|
77
79
|
# ["NSString", "MyMethods"], nil otherwise.
|
78
80
|
def objc_category_name
|
79
|
-
name.split(/[
|
81
|
+
name.split(/[()]/) if type.objc_category?
|
80
82
|
end
|
81
83
|
|
82
84
|
def swift_objc_extension?
|
@@ -136,6 +138,7 @@ module Jazzy
|
|
136
138
|
attr_accessor :unavailable_message
|
137
139
|
attr_accessor :generic_requirements
|
138
140
|
attr_accessor :inherited_types
|
141
|
+
attr_accessor :async
|
139
142
|
|
140
143
|
def usage_discouraged?
|
141
144
|
unavailable || deprecated
|
@@ -151,6 +154,7 @@ module Jazzy
|
|
151
154
|
# Workaround functions sharing names with
|
152
155
|
# different argument types (f(a:Int) vs. f(a:String))
|
153
156
|
return result unless type.swift_global_function?
|
157
|
+
|
154
158
|
result + "_#{type_usr}"
|
155
159
|
end
|
156
160
|
|
@@ -175,6 +179,7 @@ module Jazzy
|
|
175
179
|
# Is there at least one inherited type that is not in the given list?
|
176
180
|
def other_inherited_types?(unwanted)
|
177
181
|
return false unless inherited_types?
|
182
|
+
|
178
183
|
inherited_types.any? { |t| !unwanted.include?(t) }
|
179
184
|
end
|
180
185
|
|
@@ -184,6 +189,14 @@ module Jazzy
|
|
184
189
|
(swift? && usr && modulename.nil?)
|
185
190
|
end
|
186
191
|
|
192
|
+
# Info text for contents page by collapsed item name
|
193
|
+
def declaration_note
|
194
|
+
notes = [default_impl_abstract ? 'default implementation' : nil,
|
195
|
+
from_protocol_extension ? 'extension method' : nil,
|
196
|
+
async ? 'asynchronous' : nil].compact
|
197
|
+
notes.join(', ').humanize unless notes.empty?
|
198
|
+
end
|
199
|
+
|
187
200
|
def alternative_abstract
|
188
201
|
if file = alternative_abstract_file
|
189
202
|
Pathname(file).read
|
@@ -201,7 +214,9 @@ module Jazzy
|
|
201
214
|
return [] unless
|
202
215
|
Config.instance.abstract_glob_configured &&
|
203
216
|
Config.instance.abstract_glob
|
217
|
+
|
204
218
|
Config.instance.abstract_glob.select { |e| File.file? e }
|
205
219
|
end
|
206
220
|
end
|
221
|
+
# rubocop:enable Metrics/ClassLength
|
207
222
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
|
3
5
|
require 'jazzy/jazzy_markdown'
|
@@ -43,6 +45,7 @@ module Jazzy
|
|
43
45
|
|
44
46
|
def content(source_module)
|
45
47
|
return readme_content(source_module) if name == 'index'
|
48
|
+
|
46
49
|
overview
|
47
50
|
end
|
48
51
|
|
@@ -51,7 +54,7 @@ module Jazzy
|
|
51
54
|
end
|
52
55
|
|
53
56
|
def config_readme
|
54
|
-
readme_path.read if readme_path
|
57
|
+
readme_path.read if readme_path&.exist?
|
55
58
|
end
|
56
59
|
|
57
60
|
def fallback_readme
|
@@ -67,7 +70,7 @@ module Jazzy
|
|
67
70
|
### License
|
68
71
|
|
69
72
|
# <a href="#{license[:url]}">#{license[:license]}</a>
|
70
|
-
<<-
|
73
|
+
<<-README
|
71
74
|
# #{podspec.name}
|
72
75
|
|
73
76
|
### #{podspec.summary}
|
@@ -83,15 +86,15 @@ pod '#{podspec.name}'
|
|
83
86
|
### Authors
|
84
87
|
|
85
88
|
#{source_module.author_name}
|
86
|
-
|
89
|
+
README
|
87
90
|
else
|
88
|
-
<<-
|
91
|
+
<<-README
|
89
92
|
# #{source_module.name}
|
90
93
|
|
91
94
|
### Authors
|
92
95
|
|
93
96
|
#{source_module.author_name}
|
94
|
-
|
97
|
+
README
|
95
98
|
end
|
96
99
|
end
|
97
100
|
end
|