jazzy 0.0.14 → 0.0.15

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -4
  3. data/README.md +2 -2
  4. data/jazzy.gemspec +1 -0
  5. data/lib/jazzy/assets/css/github_syntax_highlighting.css.scss +142 -0
  6. data/lib/jazzy/assets/css/jazzy.css.scss +321 -0
  7. data/lib/jazzy/config.rb +1 -0
  8. data/lib/jazzy/doc.mustache +1 -0
  9. data/lib/jazzy/doc_builder.rb +30 -22
  10. data/lib/jazzy/gem_version.rb +1 -1
  11. data/lib/jazzy/jazzy_markdown.rb +27 -1
  12. data/lib/jazzy/partials/task.mustache +7 -0
  13. data/lib/jazzy/readme_generator.rb +35 -0
  14. data/lib/jazzy/source_declaration.rb +1 -0
  15. data/lib/jazzy/source_mark.rb +31 -0
  16. data/lib/jazzy/sourcekitten.rb +7 -0
  17. data/logo.jpg +0 -0
  18. data/spec/integration_specs/document_alamofire/after/docs/Classes.html +15 -4
  19. data/spec/integration_specs/document_alamofire/after/docs/Classes/Manager.html +14 -4
  20. data/spec/integration_specs/document_alamofire/after/docs/Classes/Manager/init(configuration:).html +4 -4
  21. data/spec/integration_specs/document_alamofire/after/docs/Classes/Request.html +40 -4
  22. data/spec/integration_specs/document_alamofire/after/docs/Enums.html +5 -4
  23. data/spec/integration_specs/document_alamofire/after/docs/Enums/ParameterEncoding.html +4 -4
  24. data/spec/integration_specs/document_alamofire/after/docs/Extensions.html +112 -4
  25. data/spec/integration_specs/document_alamofire/after/docs/Extensions/Manager.html +18 -3
  26. data/spec/integration_specs/document_alamofire/after/docs/Extensions/Request.html +4 -4
  27. data/spec/integration_specs/document_alamofire/after/docs/Functions.html +66 -3
  28. data/spec/integration_specs/document_alamofire/after/docs/Global Variables.html +4 -4
  29. data/spec/integration_specs/document_alamofire/after/docs/Protocols.html +20 -3
  30. data/spec/integration_specs/document_alamofire/after/docs/Protocols/URLRequestConvertible.html +4 -4
  31. data/spec/integration_specs/document_alamofire/after/docs/Protocols/URLStringConvertible.html +4 -4
  32. data/spec/integration_specs/document_alamofire/after/docs/css/github_syntax_highlighting.css +98 -0
  33. data/spec/integration_specs/document_alamofire/after/docs/css/jazzy.css +250 -0
  34. data/spec/integration_specs/document_alamofire/after/docs/index.html +572 -1
  35. data/spec/integration_specs/misc_jazzy_features/after/docs/Classes.html +7 -3
  36. data/spec/integration_specs/misc_jazzy_features/after/docs/Classes/ImplicitlyInternalTopLevelClass.html +4 -4
  37. data/spec/integration_specs/misc_jazzy_features/after/docs/Enums.html +7 -3
  38. data/spec/integration_specs/misc_jazzy_features/after/docs/Enums/DocumentedEnum.html +4 -4
  39. data/spec/integration_specs/misc_jazzy_features/after/docs/Global Variables.html +6 -3
  40. data/spec/integration_specs/misc_jazzy_features/after/docs/css/github_syntax_highlighting.css +98 -0
  41. data/spec/integration_specs/misc_jazzy_features/after/docs/css/jazzy.css +250 -0
  42. data/spec/integration_specs/misc_jazzy_features/after/docs/index.html +4 -1
  43. data/spec/integration_specs/misc_jazzy_features/before/docs/css/jazzy.css +48 -0
  44. metadata +22 -2
@@ -13,6 +13,7 @@ module Jazzy
13
13
  attr_accessor :dash_url
14
14
  attr_accessor :sourcekitten_sourcefile
15
15
  attr_accessor :clean
16
+ attr_accessor :readme_path
16
17
 
17
18
  def initialize
18
19
  self.output = Pathname('docs')
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>{{name}} {{kind}} Reference</title>
5
5
  <link rel="stylesheet" type="text/css" href="{{path_to_root}}css/jazzy.css" />
6
+ <link rel="stylesheet" type="text/css" href="{{path_to_root}}css/github_syntax_highlighting.css" />
6
7
  <meta charset='utf-8'>
7
8
  <script src="{{path_to_root}}js/jquery.min.js" defer></script>
8
9
  <script src="{{path_to_root}}js/jazzy.js" defer></script>
@@ -7,6 +7,7 @@ require 'sass'
7
7
  require 'jazzy/config'
8
8
  require 'jazzy/doc'
9
9
  require 'jazzy/jazzy_markdown'
10
+ require 'jazzy/readme_generator'
10
11
  require 'jazzy/source_declaration'
11
12
  require 'jazzy/source_module'
12
13
  require 'jazzy/sourcekitten'
@@ -125,10 +126,7 @@ module Jazzy
125
126
  def self.document_index(source_module, path_to_root)
126
127
  doc = Doc.new # Mustache model instance
127
128
  doc[:name] = source_module.name
128
- doc[:overview] = Jazzy.markdown.render(
129
- "This is the index page for #{source_module.name} docs. " \
130
- 'Navigate using the links on the left.',
131
- )
129
+ doc[:overview] = ReadmeGenerator.generate(source_module)
132
130
  doc[:doc_coverage] = source_module.doc_coverage
133
131
  doc[:structure] = source_module.doc_structure
134
132
  doc[:module_name] = source_module.name
@@ -165,31 +163,41 @@ module Jazzy
165
163
  usr: item.usr,
166
164
  }
167
165
  gh_token_url = gh_token_url(item, source_module)
168
- item_render[:github_token_url] = gh_token_url if gh_token_url
166
+ item_render[:github_token_url] = gh_token_url
169
167
  item_render[:return] = Jazzy.markdown.render(item.return) if item.return
170
- item_render[:parameters] = item.parameters if item.parameters.length > 0
171
- item_render
168
+ item_render[:parameters] = item.parameters if item.parameters.any?
169
+ item_render[:url] = item.url if item.children.any?
170
+ item_render.reject { |_, v| v.nil? }
171
+ end
172
+
173
+ def self.make_task(mark, uid, items)
174
+ {
175
+ name: mark.name,
176
+ uid: URI.encode(uid),
177
+ items: items,
178
+ pre_separator: mark.has_start_dash,
179
+ post_separator: mark.has_end_dash,
180
+ }
172
181
  end
173
182
 
174
183
  # Render tasks for Mustache document
175
184
  # @param [Config] options Build options
176
185
  # @param [Hash] doc_model Parsed doc. @see SourceKitten.parse
177
- def self.render_tasks(source_module, doc_model)
178
- tasks = []
179
- # @todo parse mark-style comments and use as task names
180
- tasknames = ['Children']
181
- tasknames.each do |taskname|
182
- items = []
183
- doc_model.children.each do |item|
184
- items << render_item(item, source_module)
186
+ def self.render_tasks(source_module, children)
187
+ marks = children.map(&:mark).uniq
188
+ mark_names_counts = {}
189
+ marks.map do |mark|
190
+ mark_children = children.select { |child| child.mark == mark }
191
+ items = mark_children.map { |child| render_item(child, source_module) }
192
+ uid = "#{mark.name || 'Unnamed'}"
193
+ if mark_names_counts.key?(uid)
194
+ mark_names_counts[uid] += 1
195
+ uid += "#{mark_names_counts[uid]}"
196
+ else
197
+ mark_names_counts[uid] = 1
185
198
  end
186
- tasks << {
187
- name: '',
188
- uid: URI.encode(taskname),
189
- items: items,
190
- }
199
+ make_task(mark, uid, items)
191
200
  end
192
- tasks
193
201
  end
194
202
 
195
203
  # Build Mustache document from single parsed doc
@@ -210,7 +218,7 @@ module Jazzy
210
218
  doc[:kind] = doc_model.kindName
211
219
  doc[:overview] = Jazzy.markdown.render(doc_model.abstract || '')
212
220
  doc[:structure] = source_module.doc_structure
213
- doc[:tasks] = render_tasks(source_module, doc_model)
221
+ doc[:tasks] = render_tasks(source_module, doc_model.children)
214
222
  doc[:module_name] = source_module.name
215
223
  doc[:author_name] = source_module.author_name
216
224
  doc[:author_website] = source_module.author_url
@@ -1,3 +1,3 @@
1
1
  module Jazzy
2
- VERSION = '0.0.14' unless defined? Jazzy::VERSION
2
+ VERSION = '0.0.15' unless defined? Jazzy::VERSION
3
3
  end
@@ -1,13 +1,39 @@
1
1
  require 'redcarpet'
2
+ require 'rouge'
3
+ require 'rouge/plugins/redcarpet'
2
4
 
3
5
  module Jazzy
4
6
  class JazzyHTML < Redcarpet::Render::HTML
7
+ include Redcarpet::Render::SmartyPants
8
+ include Rouge::Plugins::Redcarpet
9
+
5
10
  def paragraph(text)
6
11
  "<p class=\"para\">#{text}</p>"
7
12
  end
13
+
14
+ def header(text, header_level)
15
+ text_slug = text.gsub(/[^a-zA-Z0-9]+/, '_')
16
+ .downcase
17
+ .sub(/^_/, '')
18
+ .sub(/_$/, '')
19
+
20
+ "<a href='##{text_slug}' class='anchor' aria-hidden=true>" \
21
+ '<span class="header-anchor"></span>' \
22
+ '</a>' \
23
+ "<h#{header_level} id='#{text_slug}'>#{text}</h#{header_level}>\n"
24
+ end
25
+
26
+ OPTIONS = {
27
+ autolink: true,
28
+ fenced_code_blocks: true,
29
+ no_intra_emphasis: true,
30
+ quote: true,
31
+ strikethrough: true,
32
+ space_after_headers: true,
33
+ }.freeze
8
34
  end
9
35
 
10
36
  def self.markdown
11
- @markdown ||= Redcarpet::Markdown.new(JazzyHTML, autolink: true)
37
+ @markdown ||= Redcarpet::Markdown.new(JazzyHTML, JazzyHTML::OPTIONS)
12
38
  end
13
39
  end
@@ -1,9 +1,13 @@
1
1
  <div class="task-group">
2
2
  <div class="task-name-container">
3
+ {{#pre_separator}}<hr/>{{/pre_separator}}
3
4
  <a name="/{{uid}}"></a>
5
+ {{#name}}
4
6
  <a href="#/{{uid}}">
5
7
  <h3 class="section-name">{{name}}</h3>
6
8
  </a>
9
+ {{/name}}
10
+ {{#post_separator}}<hr/>{{/post_separator}}
7
11
  </div>
8
12
  <ul class="task-group-list">
9
13
  {{#items}}
@@ -21,6 +25,9 @@
21
25
  {{#abstract}}
22
26
  <div class="abstract">
23
27
  {{{abstract}}}
28
+ {{#url}}
29
+ <a href="{{{url}}}" class="see-more">See more</a>
30
+ {{/url}}
24
31
  </div>
25
32
  {{/abstract}}
26
33
  {{#declaration}}
@@ -0,0 +1,35 @@
1
+ require 'jazzy/jazzy_markdown'
2
+
3
+ module Jazzy
4
+ module ReadmeGenerator
5
+ def self.generate(source_module)
6
+ readme = readme_path
7
+
8
+ unless readme && File.exist?(readme) && readme = File.read(readme)
9
+ readme = generated_readme(source_module)
10
+ end
11
+
12
+ rendered_readme = Jazzy.markdown.render(readme)
13
+ "<div class='readme'>#{rendered_readme}</div>"
14
+ end
15
+
16
+ def self.readme_path
17
+ %w(README.md README.markdown README.mdown README).each do |potential_name|
18
+ if File.exist? potential_name
19
+ return potential_name
20
+ end
21
+ end
22
+ nil
23
+ end
24
+
25
+ def self.generated_readme(source_module)
26
+ %(
27
+ # #{ source_module.name }
28
+
29
+ ### Authors
30
+
31
+ #{ source_module.author_name }
32
+ )
33
+ end
34
+ end
35
+ end
@@ -15,5 +15,6 @@ module Jazzy
15
15
  attr_accessor :children
16
16
  attr_accessor :parameters
17
17
  attr_accessor :url
18
+ attr_accessor :mark
18
19
  end
19
20
  end
@@ -0,0 +1,31 @@
1
+ module Jazzy
2
+ class SourceMark
3
+ attr_accessor :name
4
+ attr_accessor :has_start_dash
5
+ attr_accessor :has_end_dash
6
+
7
+ def initialize(mark_string = nil)
8
+ return unless mark_string
9
+
10
+ # Format: 'MARK: - NAME -' with dashes optional
11
+ mark_string.sub!(/^MARK: /, '')
12
+
13
+ if mark_string.length == 0
14
+ # Empty
15
+ return
16
+ elsif mark_string == '-'
17
+ # Separator
18
+ self.has_start_dash = true
19
+ return
20
+ end
21
+
22
+ self.has_start_dash = mark_string.start_with?('- ')
23
+ self.has_end_dash = mark_string.end_with?(' -')
24
+
25
+ start_index = has_start_dash ? 2 : 0
26
+ end_index = has_end_dash ? -3 : -1
27
+
28
+ self.name = mark_string[start_index..end_index]
29
+ end
30
+ end
31
+ end
@@ -4,6 +4,7 @@ require 'pathname'
4
4
 
5
5
  require 'jazzy/config'
6
6
  require 'jazzy/source_declaration'
7
+ require 'jazzy/source_mark'
7
8
  require 'jazzy/xml_helper'
8
9
 
9
10
  module Jazzy
@@ -117,6 +118,7 @@ module Jazzy
117
118
  # rubocop:disable Metrics/MethodLength
118
119
  def self.make_source_declarations(docs)
119
120
  declarations = []
121
+ current_mark = SourceMark.new
120
122
  docs.each do |doc|
121
123
  if doc.key?('key.diagnostic_stage')
122
124
  declarations += make_source_declarations(doc['key.substructure'])
@@ -124,6 +126,10 @@ module Jazzy
124
126
  end
125
127
  declaration = SourceDeclaration.new
126
128
  declaration.kind = doc['key.kind']
129
+ if declaration.kind == 'source.lang.swift.syntaxtype.comment.mark' &&
130
+ doc['key.name'].start_with?('MARK: ')
131
+ current_mark = SourceMark.new(doc['key.name'])
132
+ end
127
133
  next unless declaration.kind =~ /^source\.lang\.swift\.decl\..*/
128
134
 
129
135
  unless declaration.kindName = @kinds[declaration.kind]
@@ -136,6 +142,7 @@ module Jazzy
136
142
  declaration.file = doc['key.filepath']
137
143
  declaration.usr = doc['key.usr']
138
144
  declaration.name = doc['key.name']
145
+ declaration.mark = current_mark
139
146
 
140
147
  make_doc_info(doc, declaration)
141
148
  make_substructure(doc, declaration)
Binary file
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>Classes Reference</title>
5
5
  <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
6
+ <link rel="stylesheet" type="text/css" href="css/github_syntax_highlighting.css" />
6
7
  <meta charset='utf-8'>
7
8
  <script src="js/jquery.min.js" defer></script>
8
9
  <script src="js/jazzy.js" defer></script>
@@ -164,10 +165,9 @@
164
165
  <section class="section task-group-section">
165
166
  <div class="task-group">
166
167
  <div class="task-name-container">
167
- <a name="/Children"></a>
168
- <a href="#/Children">
169
- <h3 class="section-name"></h3>
170
- </a>
168
+ <hr/>
169
+ <a name="/Unnamed"></a>
170
+
171
171
  </div>
172
172
  <ul class="task-group-list">
173
173
  <li class="item symbol">
@@ -183,6 +183,7 @@
183
183
  <div class="pointy-thing"></div>
184
184
  <div class="abstract">
185
185
  <p class="para">Responsible for creating and managing <code>Request</code> objects, as well as their underlying <code>NSURLSession</code>.</p>
186
+ <a href="Classes/Manager.html" class="see-more">See more</a>
186
187
  </div>
187
188
  <div class="declaration">
188
189
  <h4>Declaration</h4>
@@ -200,6 +201,15 @@
200
201
  </section>
201
202
  </div>
202
203
  </li>
204
+ </ul>
205
+ </div>
206
+ <div class="task-group">
207
+ <div class="task-name-container">
208
+ <hr/>
209
+ <a name="/Unnamed2"></a>
210
+
211
+ </div>
212
+ <ul class="task-group-list">
203
213
  <li class="item symbol">
204
214
  <div class="task-group-term">
205
215
  <code>
@@ -213,6 +223,7 @@
213
223
  <div class="pointy-thing"></div>
214
224
  <div class="abstract">
215
225
  <p class="para">Responsible for sending a request and receiving the response and associated data from the server, as well as managing its underlying <code>NSURLSessionTask</code>.</p>
226
+ <a href="Classes/Request.html" class="see-more">See more</a>
216
227
  </div>
217
228
  <div class="declaration">
218
229
  <h4>Declaration</h4>
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>Manager Class Reference</title>
5
5
  <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
6
+ <link rel="stylesheet" type="text/css" href="../css/github_syntax_highlighting.css" />
6
7
  <meta charset='utf-8'>
7
8
  <script src="../js/jquery.min.js" defer></script>
8
9
  <script src="../js/jazzy.js" defer></script>
@@ -164,10 +165,9 @@
164
165
  <section class="section task-group-section">
165
166
  <div class="task-group">
166
167
  <div class="task-name-container">
167
- <a name="/Children"></a>
168
- <a href="#/Children">
169
- <h3 class="section-name"></h3>
170
- </a>
168
+
169
+ <a name="/Unnamed"></a>
170
+
171
171
  </div>
172
172
  <ul class="task-group-list">
173
173
  <li class="item symbol">
@@ -273,6 +273,7 @@
273
273
  <div class="pointy-thing"></div>
274
274
  <div class="abstract">
275
275
 
276
+ <a href="Classes/Manager/init(configuration:).html" class="see-more">See more</a>
276
277
  </div>
277
278
  <div class="declaration">
278
279
  <h4>Declaration</h4>
@@ -309,6 +310,15 @@
309
310
  </section>
310
311
  </div>
311
312
  </li>
313
+ </ul>
314
+ </div>
315
+ <div class="task-group">
316
+ <div class="task-name-container">
317
+ <hr/>
318
+ <a name="/Unnamed2"></a>
319
+
320
+ </div>
321
+ <ul class="task-group-list">
312
322
  <li class="item symbol">
313
323
  <div class="task-group-term">
314
324
  <code>
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>init(configuration:) Instance Method Reference</title>
5
5
  <link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
6
+ <link rel="stylesheet" type="text/css" href="../../css/github_syntax_highlighting.css" />
6
7
  <meta charset='utf-8'>
7
8
  <script src="../../js/jquery.min.js" defer></script>
8
9
  <script src="../../js/jazzy.js" defer></script>
@@ -164,10 +165,9 @@
164
165
  <section class="section task-group-section">
165
166
  <div class="task-group">
166
167
  <div class="task-name-container">
167
- <a name="/Children"></a>
168
- <a href="#/Children">
169
- <h3 class="section-name"></h3>
170
- </a>
168
+
169
+ <a name="/Unnamed"></a>
170
+
171
171
  </div>
172
172
  <ul class="task-group-list">
173
173
  <li class="item symbol">
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>Request Class Reference</title>
5
5
  <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
6
+ <link rel="stylesheet" type="text/css" href="../css/github_syntax_highlighting.css" />
6
7
  <meta charset='utf-8'>
7
8
  <script src="../js/jquery.min.js" defer></script>
8
9
  <script src="../js/jazzy.js" defer></script>
@@ -164,10 +165,9 @@
164
165
  <section class="section task-group-section">
165
166
  <div class="task-group">
166
167
  <div class="task-name-container">
167
- <a name="/Children"></a>
168
- <a href="#/Children">
169
- <h3 class="section-name"></h3>
170
- </a>
168
+
169
+ <a name="/Unnamed"></a>
170
+
171
171
  </div>
172
172
  <ul class="task-group-list">
173
173
  <li class="item symbol">
@@ -350,6 +350,18 @@
350
350
  </section>
351
351
  </div>
352
352
  </li>
353
+ </ul>
354
+ </div>
355
+ <div class="task-group">
356
+ <div class="task-name-container">
357
+
358
+ <a name="/Authentication"></a>
359
+ <a href="#/Authentication">
360
+ <h3 class="section-name">Authentication</h3>
361
+ </a>
362
+
363
+ </div>
364
+ <ul class="task-group-list">
353
365
  <li class="item symbol">
354
366
  <div class="task-group-term">
355
367
  <code>
@@ -468,6 +480,18 @@
468
480
  </section>
469
481
  </div>
470
482
  </li>
483
+ </ul>
484
+ </div>
485
+ <div class="task-group">
486
+ <div class="task-name-container">
487
+
488
+ <a name="/Progress"></a>
489
+ <a href="#/Progress">
490
+ <h3 class="section-name">Progress</h3>
491
+ </a>
492
+
493
+ </div>
494
+ <ul class="task-group-list">
471
495
  <li class="item symbol">
472
496
  <div class="task-group-term">
473
497
  <code>
@@ -521,6 +545,18 @@
521
545
  </section>
522
546
  </div>
523
547
  </li>
548
+ </ul>
549
+ </div>
550
+ <div class="task-group">
551
+ <div class="task-name-container">
552
+
553
+ <a name="/Response"></a>
554
+ <a href="#/Response">
555
+ <h3 class="section-name">Response</h3>
556
+ </a>
557
+
558
+ </div>
559
+ <ul class="task-group-list">
524
560
  <li class="item symbol">
525
561
  <div class="task-group-term">
526
562
  <code>