jazzy 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -3
  3. data/CHANGELOG.md +53 -0
  4. data/Gemfile.lock +11 -15
  5. data/jazzy.gemspec +3 -4
  6. data/lib/jazzy/SourceKitten/Commandant.framework/Commandant +1 -0
  7. data/lib/jazzy/SourceKitten/Commandant.framework/Modules +1 -0
  8. data/lib/jazzy/SourceKitten/Commandant.framework/Resources +1 -0
  9. data/lib/jazzy/SourceKitten/Commandant.framework/Versions/A/Commandant +0 -0
  10. data/lib/jazzy/{sourcekitten → SourceKitten}/Commandant.framework/Versions/A/Modules/Commandant.swiftmodule/x86_64.swiftdoc +0 -0
  11. data/lib/jazzy/{sourcekitten → SourceKitten}/Commandant.framework/Versions/A/Modules/Commandant.swiftmodule/x86_64.swiftmodule +0 -0
  12. data/lib/jazzy/{sourcekitten → SourceKitten}/Commandant.framework/Versions/A/Modules/module.modulemap +0 -0
  13. data/lib/jazzy/{sourcekitten → SourceKitten}/Commandant.framework/Versions/A/Resources/Info.plist +5 -5
  14. data/lib/jazzy/SourceKitten/Commandant.framework/Versions/Current +1 -0
  15. data/lib/jazzy/SourceKitten/LlamaKit.framework/LlamaKit +1 -0
  16. data/lib/jazzy/SourceKitten/LlamaKit.framework/Modules +1 -0
  17. data/lib/jazzy/SourceKitten/LlamaKit.framework/Resources +1 -0
  18. data/lib/jazzy/{sourcekitten/LlamaKit.framework → SourceKitten/LlamaKit.framework/Versions/A}/LlamaKit +0 -0
  19. data/lib/jazzy/{sourcekitten → SourceKitten}/LlamaKit.framework/Versions/A/Modules/LlamaKit.swiftmodule/x86_64.swiftdoc +0 -0
  20. data/lib/jazzy/{sourcekitten → SourceKitten}/LlamaKit.framework/Versions/A/Modules/LlamaKit.swiftmodule/x86_64.swiftmodule +0 -0
  21. data/lib/jazzy/{sourcekitten → SourceKitten}/LlamaKit.framework/Versions/A/Modules/module.modulemap +0 -0
  22. data/lib/jazzy/{sourcekitten → SourceKitten}/LlamaKit.framework/Versions/A/Resources/Info.plist +5 -5
  23. data/lib/jazzy/SourceKitten/LlamaKit.framework/Versions/Current +1 -0
  24. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Modules +1 -0
  25. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Resources +1 -0
  26. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/SourceKittenFramework +1 -0
  27. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Modules +1 -0
  28. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Resources +1 -0
  29. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/SwiftXPC +1 -0
  30. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/Modules/SwiftXPC.swiftmodule/x86_64.swiftdoc +0 -0
  31. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/Modules/SwiftXPC.swiftmodule/x86_64.swiftmodule +0 -0
  32. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/Modules/module.modulemap +0 -0
  33. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/Resources/Info.plist +5 -5
  34. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/SwiftXPC +0 -0
  35. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/Current +1 -0
  36. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftCore.dylib +0 -0
  37. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftCoreGraphics.dylib +0 -0
  38. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftDarwin.dylib +0 -0
  39. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftDispatch.dylib +0 -0
  40. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftFoundation.dylib +0 -0
  41. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftObjectiveC.dylib +0 -0
  42. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftSecurity.dylib +0 -0
  43. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Modules/SourceKittenFramework.swiftmodule/x86_64.swiftdoc +0 -0
  44. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/Modules/SourceKittenFramework.swiftmodule/x86_64.swiftmodule +0 -0
  45. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Modules/module.modulemap +0 -0
  46. data/lib/jazzy/{sourcekitten → SourceKitten}/SourceKittenFramework.framework/Versions/A/Resources/Info.plist +5 -5
  47. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/A/SourceKittenFramework +0 -0
  48. data/lib/jazzy/SourceKitten/SourceKittenFramework.framework/Versions/Current +1 -0
  49. data/lib/jazzy/SourceKitten/sourcekitten +0 -0
  50. data/lib/jazzy/assets/css/jazzy.css.scss +319 -810
  51. data/lib/jazzy/assets/js/jazzy.js +12 -2
  52. data/lib/jazzy/config.rb +6 -1
  53. data/lib/jazzy/doc.mustache +10 -36
  54. data/lib/jazzy/doc_builder.rb +13 -8
  55. data/lib/jazzy/docset_builder.rb +1 -1
  56. data/lib/jazzy/executable.rb +44 -0
  57. data/lib/jazzy/gem_version.rb +1 -1
  58. data/lib/jazzy/jazzy_markdown.rb +0 -4
  59. data/lib/jazzy/partials/footer.mustache +2 -2
  60. data/lib/jazzy/partials/header.mustache +11 -0
  61. data/lib/jazzy/partials/nav.mustache +5 -5
  62. data/lib/jazzy/partials/parameter.mustache +3 -3
  63. data/lib/jazzy/partials/task.mustache +22 -25
  64. data/lib/jazzy/readme_generator.rb +1 -2
  65. data/lib/jazzy/source_declaration.rb +2 -0
  66. data/lib/jazzy/sourcekitten.rb +52 -32
  67. data/spec/integration_spec.rb +3 -2
  68. data/spec/sourcekitten_spec.rb +1 -1
  69. metadata +69 -71
  70. data/lib/jazzy/sourcekitten/Commandant.framework/Commandant +0 -0
  71. data/lib/jazzy/sourcekitten/Commandant.framework/Versions/A/Commandant +0 -0
  72. data/lib/jazzy/sourcekitten/LlamaKit.framework/Versions/A/LlamaKit +0 -0
  73. data/lib/jazzy/sourcekitten/Rakefile +0 -19
  74. data/lib/jazzy/sourcekitten/SourceKittenFramework.framework/SourceKittenFramework +0 -0
  75. data/lib/jazzy/sourcekitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/SwiftXPC +0 -0
  76. data/lib/jazzy/sourcekitten/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/SwiftXPC +0 -0
  77. data/lib/jazzy/sourcekitten/SourceKittenFramework.framework/Versions/A/Modules/SourceKittenFramework.swiftmodule/x86_64.swiftdoc +0 -0
  78. data/lib/jazzy/sourcekitten/SourceKittenFramework.framework/Versions/A/Modules/SourceKittenFramework.swiftmodule/x86_64.swiftmodule +0 -0
  79. data/lib/jazzy/sourcekitten/SourceKittenFramework.framework/Versions/A/SourceKittenFramework +0 -0
  80. data/lib/jazzy/sourcekitten/sourcekitten +0 -0
  81. data/lib/jazzy/xml_helper.rb +0 -16
@@ -1,3 +1,13 @@
1
+ window.jazzy = {'docset': false}
2
+ if (typeof window.dash != 'undefined') {
3
+ document.documentElement.className += ' dash'
4
+ window.jazzy.docset = true
5
+ }
6
+ if (navigator.userAgent.match(/xcode/i)) {
7
+ document.documentElement.className += ' xcode'
8
+ window.jazzy.docset = true
9
+ }
10
+
1
11
  // On doc load, toggle the URL hash discussion if present
2
12
  $(document).ready(function() {
3
13
  if (!window.jazzy.docset) {
@@ -6,8 +16,8 @@ $(document).ready(function() {
6
16
  }
7
17
  });
8
18
 
9
- // On x-instance-method click, toggle its discussion and animate token.marginLeft
10
- $(".x-instance-method").click(function() {
19
+ // On token click, toggle its discussion and animate token.marginLeft
20
+ $(".token").click(function() {
11
21
  if (window.jazzy.docset) {
12
22
  return;
13
23
  }
data/lib/jazzy/config.rb CHANGED
@@ -107,7 +107,7 @@ module Jazzy
107
107
  end
108
108
 
109
109
  opt.on('-s', '--sourcekitten-sourcefile FILEPATH',
110
- 'XML doc file generated from sourcekitten to parse') do |s|
110
+ 'File generated from sourcekitten output to parse') do |s|
111
111
  config.sourcekitten_sourcefile = Pathname(s)
112
112
  end
113
113
 
@@ -159,6 +159,11 @@ module Jazzy
159
159
  config.source_directory = Pathname(source_directory)
160
160
  end
161
161
 
162
+ opt.on('--readme FILEPATH',
163
+ 'The path to a markdown README file') do |readme|
164
+ config.readme_path = Pathname(readme)
165
+ end
166
+
162
167
  opt.on('-v', '--version', 'Print version number') do
163
168
  puts 'jazzy version: ' + Jazzy::VERSION
164
169
  exit
@@ -5,54 +5,28 @@
5
5
  <link rel="stylesheet" type="text/css" href="{{path_to_root}}css/jazzy.css" />
6
6
  <link rel="stylesheet" type="text/css" href="{{path_to_root}}css/highlight.css" />
7
7
  <meta charset='utf-8'>
8
- <script type="text/javascript">
9
- window.jazzy = {'docset': false}
10
- if (typeof window.dash != 'undefined') {
11
- document.documentElement.className += ' dash'
12
- window.jazzy.docset = true
13
- }
14
- if (navigator.userAgent.match(/xcode/i)) {
15
- document.documentElement.className += ' xcode'
16
- window.jazzy.docset = true
17
- }
18
- </script>
19
8
  <script src="{{path_to_root}}js/jquery.min.js" defer></script>
20
9
  <script src="{{path_to_root}}js/jazzy.js" defer></script>
21
10
  </head>
22
- <body id="reference" class="Swift">
11
+ <body>
23
12
  {{#dash_type}}
24
13
  <a name="//apple_ref/swift/{{dash_type}}/{{name}}" class="dashAnchor"></a>
25
14
  {{/dash_type}}
26
15
  <a title="{{name}} {{kind}} Reference"></a>
27
- <header>
28
- <div class="content-wrapper">
29
- <p class="header-text"><a href="{{path_to_root}}index.html">{{module_name}} Docs</a> ({{doc_coverage}}% documented)</p>
30
- {{#github_url}}
31
- <p id="header-links"><a href="{{github_url}}"><img id="header-icon" src="{{path_to_root}}img/gh.png" height="16px" width="16px" />View on GitHub</a></p>
32
- {{/github_url}}
33
- {{#dash_url}}
34
- <p id="header-links"><a href="{{dash_url}}"><img id="header-icon" src="{{path_to_root}}img/dash.png" height="16px" width="16px" />Install in Dash</a></p>
35
- {{/dash_url}}
36
- </div>
37
- </header>
38
- <section id="valence">
39
- <div class="content-wrapper">
40
- <p id="hierarchial_navigation">
41
- <a href="{{path_to_root}}index.html" id="design_resources_link">{{module_name}} Reference</a>
42
- <img id="carat" src="{{path_to_root}}img/carat.png" height="10px" width="6px" />
16
+ {{> jazzy/partials/header}}
17
+ <div class="content-wrapper">
18
+ <p id="breadcrumbs">
19
+ <a href="{{path_to_root}}index.html">{{module_name}} Reference</a>
20
+ <img id="carat" src="{{path_to_root}}img/carat.png" />
43
21
  {{name}} {{kind}} Reference
44
- </p>
45
- </div>
46
- </section>
22
+ </p>
23
+ </div>
47
24
  <div class="content-wrapper">
48
25
  {{> jazzy/partials/nav}}
49
- <div class="pixel-line"></div>
50
- <div class="rubber-band-gap"></div>
51
- <article class="chapter">
52
- <a name="/{{usr}}"></a>
53
- <h1 class="chapter-name">{{name}}</h1>
26
+ <article class="main-content">
54
27
  <section>
55
28
  <section class="section">
29
+ {{^hide_name}}<h1>{{name}}</h1>{{/hide_name}}
56
30
  {{{overview}}}
57
31
  </section>
58
32
  {{> jazzy/partials/tasks}}
@@ -18,8 +18,6 @@ module Jazzy
18
18
  # This module handles HTML generation, file writing, asset copying,
19
19
  # and generally building docs given sourcekitten output
20
20
  module DocBuilder
21
- DEVELOPER_DIR = `xcode-select -p`.chomp
22
-
23
21
  # mkdir -p output directory and clean if option is set
24
22
  def self.prepare_output_dir(output_dir, clean)
25
23
  FileUtils.rm_r output_dir if clean && output_dir.directory?
@@ -30,16 +28,14 @@ module Jazzy
30
28
  # @return [Array] doc structure comprised of
31
29
  # section names & child names & URLs
32
30
  def self.doc_structure_for_docs(docs)
33
- structure = []
34
- docs.each do |doc|
35
- structure << {
31
+ docs.map do |doc|
32
+ {
36
33
  section: doc.name,
37
34
  children: doc.children.sort_by(&:name).map do |child|
38
35
  { name: child.name, url: child.url }
39
36
  end,
40
37
  }
41
38
  end
42
- structure
43
39
  end
44
40
 
45
41
  # Build documentation from the given options
@@ -192,11 +188,14 @@ module Jazzy
192
188
  doc[:github_url] = source_module.github_url.to_s
193
189
  doc[:dash_url] = source_module.dash_url
194
190
  doc[:path_to_root] = path_to_root
191
+ doc[:hide_name] = true
195
192
  doc.render
196
193
  end
197
194
 
198
195
  def self.should_link_to_github(file)
199
- !file.start_with?(DEVELOPER_DIR) if file
196
+ developer_directory = SourceKitten.xcode_developer_directory
197
+ return unless developer_directory && file
198
+ !file.start_with?(developer_directory.realpath.to_s)
200
199
  end
201
200
 
202
201
  # Construct Github token URL
@@ -205,7 +204,11 @@ module Jazzy
205
204
  def self.gh_token_url(item, source_module)
206
205
  if source_module.github_file_prefix && should_link_to_github(item.file)
207
206
  relative_file_path = item.file.gsub(`pwd`.strip, '')
208
- gh_line = "#L#{item.line}"
207
+ if item.start_line && (item.start_line != item.end_line)
208
+ gh_line = "#L#{item.start_line}-L#{item.end_line}"
209
+ else
210
+ gh_line = "#L#{item.line}"
211
+ end
209
212
  source_module.github_file_prefix + relative_file_path + gh_line
210
213
  end
211
214
  end
@@ -228,6 +231,8 @@ module Jazzy
228
231
  item_render[:return] = Jazzy.markdown.render(item.return) if item.return
229
232
  item_render[:parameters] = item.parameters if item.parameters.any?
230
233
  item_render[:url] = item.url if item.children.any?
234
+ item_render[:start_line] = item.start_line
235
+ item_render[:end_line] = item.end_line
231
236
  item_render.reject { |_, v| v.nil? }
232
237
  end
233
238
 
@@ -58,7 +58,7 @@ module Jazzy
58
58
  end
59
59
 
60
60
  def copy_docs
61
- files_to_copy = Pathname.glob(generated_docs_dir + '**/*') -
61
+ files_to_copy = Pathname.glob(generated_docs_dir + '*') -
62
62
  [docset_dir, output_dir]
63
63
 
64
64
  FileUtils.mkdir_p documents_dir
@@ -0,0 +1,44 @@
1
+ module Jazzy
2
+ module Executable
3
+ class IO < Array
4
+ def initialize(io = nil)
5
+ @io = io
6
+ end
7
+
8
+ def <<(value)
9
+ super
10
+ ensure
11
+ @io << value.to_s if @io
12
+ end
13
+
14
+ def to_s
15
+ join("\n")
16
+ end
17
+ end
18
+
19
+ class << self
20
+ def execute_command(executable, args, raise_on_failure)
21
+ require 'shellwords'
22
+ bin = `which #{executable.to_s.shellescape}`.strip
23
+ raise "Unable to locate the executable `#{executable}`" if bin.empty?
24
+
25
+ require 'open4'
26
+
27
+ stdout, stderr = IO.new, IO.new($stderr)
28
+
29
+ options = { stdout: stdout, stderr: stderr, status: true }
30
+ status = Open4.spawn(bin, *args, options)
31
+ unless status.success?
32
+ full_command = "#{bin.shellescape} #{args.map(&:shellescape)}"
33
+ output = stdout.to_s << stderr.to_S
34
+ if raise_on_failure
35
+ raise "#{full_command}\n\n#{output}"
36
+ else
37
+ warn("[!] Failed: #{full_command}")
38
+ end
39
+ end
40
+ [stdout.to_s, status]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Jazzy
2
- VERSION = '0.1.4' unless defined? Jazzy::VERSION
2
+ VERSION = '0.1.5' unless defined? Jazzy::VERSION
3
3
  end
@@ -7,10 +7,6 @@ module Jazzy
7
7
  include Redcarpet::Render::SmartyPants
8
8
  include Rouge::Plugins::Redcarpet
9
9
 
10
- def paragraph(text)
11
- "<p class=\"para\">#{text}</p>"
12
- end
13
-
14
10
  def header(text, header_level)
15
11
  text_slug = text.gsub(/[^a-zA-Z0-9]+/, '_')
16
12
  .downcase
@@ -1,4 +1,4 @@
1
1
  <section id="footer">
2
- <p class="copyright">&copy; {{year}} <a class="link" href="{{author_website}}" target="_blank" rel="external">{{author_name}}</a>. All rights reserved. (Last updated: {{date}})</p>
3
- <p class="copyright">Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v{{jazzy_version}}</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
2
+ <p>&copy; {{year}} <a class="link" href="{{author_website}}" target="_blank" rel="external">{{author_name}}</a>. All rights reserved. (Last updated: {{date}})</p>
3
+ <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v{{jazzy_version}}</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
4
4
  </section>
@@ -0,0 +1,11 @@
1
+ <header>
2
+ <div class="content-wrapper">
3
+ <p><a href="{{path_to_root}}index.html">{{module_name}} Docs</a> ({{doc_coverage}}% documented)</p>
4
+ {{#github_url}}
5
+ <p class="header-right"><a href="{{github_url}}"><img src="{{path_to_root}}img/gh.png"/>View on GitHub</a></p>
6
+ {{/github_url}}
7
+ {{#dash_url}}
8
+ <p class="header-right"><a href="{{dash_url}}"><img src="{{path_to_root}}img/dash.png"/>Install in Dash</a></p>
9
+ {{/dash_url}}
10
+ </div>
11
+ </header>
@@ -1,11 +1,11 @@
1
- <nav class="book-parts">
2
- <ul class="nav-parts">
1
+ <nav class="sidebar">
2
+ <ul class="nav-groups">
3
3
  {{#structure}}
4
- <li class="part-name tasks">
4
+ <li class="nav-group-name">
5
5
  <a href="{{path_to_root}}{{section}}.html">{{section}}</a>
6
- <ul class="nav-chapters">
6
+ <ul class="nav-group-tasks">
7
7
  {{#children}}
8
- <li class="nav-chapter">
8
+ <li class="nav-group-task">
9
9
  <a href="{{path_to_root}}{{url}}">{{name}}</a>
10
10
  </li>
11
11
  {{/children}}
@@ -1,11 +1,11 @@
1
1
  <tr>
2
- <td scope="row">
2
+ <td>
3
3
  <code>
4
- <em class="term">{{name}}</em>
4
+ <em>{{name}}</em>
5
5
  </code>
6
6
  </td>
7
7
  <td>
8
- <div class="definition">
8
+ <div>
9
9
  {{{discussion}}}
10
10
  </div>
11
11
  </td>
@@ -1,41 +1,38 @@
1
1
  <div class="task-group">
2
- <div class="task-name-container">
3
- {{#pre_separator}}<hr/>{{/pre_separator}}
4
- <a name="/{{uid}}"></a>
5
- {{#name}}
6
- <a name="//apple_ref/swift/Section/{{name}}" class="dashAnchor"></a>
7
- <a href="#/{{uid}}">
8
- <h3 class="section-name">{{name}}</h3>
9
- </a>
10
- {{/name}}
11
- {{#post_separator}}<hr/>{{/post_separator}}
12
- </div>
13
- <ul class="task-group-list">
2
+ {{#name}}
3
+ <div class="task-name-container">
4
+ <a name="/{{uid}}"></a>
5
+ <a name="//apple_ref/swift/Section/{{name}}" class="dashAnchor"></a>
6
+ <a href="#/{{uid}}">
7
+ <h3 class="section-name">{{name}}</h3>
8
+ </a>
9
+ </div>
10
+ {{/name}}
11
+ <ul>
14
12
  {{#items}}
15
- <li class="item symbol">
16
- <div class="task-group-term">
13
+ <li class="item">
14
+ <div>
17
15
  <code>
18
- <a name="/{{usr}}">
16
+ <a name="/{{usr}}"></a>
19
17
  <a name="//apple_ref/swift/{{dash_type}}/{{name}}" class="dashAnchor"></a>
20
- <a class="x-instance-method Swift" href="#/{{usr}}">{{name}}</a>
18
+ <a class="token" href="#/{{usr}}">{{name}}</a>
21
19
  </code>
22
20
  </div>
23
21
  <div class="height-container">
24
- <div class="pointy-thing-container"></div>
25
- <section class="section instance-method">
26
- <div class="pointy-thing"></div>
22
+ <div class="pointer-container"></div>
23
+ <section class="section">
24
+ <div class="pointer"></div>
27
25
  {{#abstract}}
28
26
  <div class="abstract">
29
27
  {{{abstract}}}
30
28
  {{#url}}
31
- <a href="{{{path_to_root}}}{{{url}}}" class="see-more">See more</a>
29
+ <a href="{{{path_to_root}}}{{{url}}}" class="slightly-smaller">See more</a>
32
30
  {{/url}}
33
31
  </div>
34
32
  {{/abstract}}
35
33
  {{#declaration}}
36
34
  <div class="declaration">
37
35
  <h4>Declaration</h4>
38
-
39
36
  <div class="Swift">
40
37
  <p class="aside-title">Swift</p>
41
38
  {{{declaration}}}
@@ -43,9 +40,9 @@
43
40
  </div>
44
41
  {{/declaration}}
45
42
  {{#parameters.count}}
46
- <div class="parameters">
43
+ <div>
47
44
  <h4>Parameters</h4>
48
- <table class="graybox" border="0" cellspacing="0" cellpadding="5">
45
+ <table class="graybox">
49
46
  <tbody>
50
47
  {{#parameters}}
51
48
  {{> jazzy/partials/parameter}}
@@ -55,13 +52,13 @@
55
52
  </div>
56
53
  {{/parameters.count}}
57
54
  {{#return}}
58
- <div class="result-description">
55
+ <div>
59
56
  <h4>Return Value</h4>
60
57
  {{{return}}}
61
58
  </div>
62
59
  {{/return}}
63
60
  {{#github_token_url}}
64
- <div class="result-description view-on-github">
61
+ <div class="slightly-smaller">
65
62
  <a href="{{{github_token_url}}}">Show on GitHub</a>
66
63
  </div>
67
64
  {{/github_token_url}}
@@ -13,8 +13,7 @@ module Jazzy
13
13
  readme = generated_readme(source_module)
14
14
  end
15
15
 
16
- rendered_readme = Jazzy.markdown.render(readme)
17
- "<div class='readme'>#{rendered_readme}</div>"
16
+ Jazzy.markdown.render(readme)
18
17
  end
19
18
 
20
19
  def self.readme_path
@@ -18,6 +18,8 @@ module Jazzy
18
18
  attr_accessor :url
19
19
  attr_accessor :mark
20
20
  attr_accessor :access_control_level
21
+ attr_accessor :start_line
22
+ attr_accessor :end_line
21
23
 
22
24
  def overview
23
25
  "#{abstract}\n\n#{discussion}".strip
@@ -2,10 +2,10 @@ require 'json'
2
2
  require 'pathname'
3
3
 
4
4
  require 'jazzy/config'
5
+ require 'jazzy/executable'
6
+ require 'jazzy/highlighter'
5
7
  require 'jazzy/source_declaration'
6
8
  require 'jazzy/source_mark'
7
- require 'jazzy/xml_helper'
8
- require 'jazzy/highlighter'
9
9
 
10
10
  module Jazzy
11
11
  # This module interacts with the sourcekitten command-line executable
@@ -56,7 +56,7 @@ module Jazzy
56
56
  expected_xcode_select_path =
57
57
  Pathname('/Applications/Xcode.app/Contents/Developer')
58
58
  return if xcode_developer_directory == expected_xcode_select_path
59
- raise 'Please install Xcode 6.1 or 6.2 in ' \
59
+ raise 'Please install or symlink Xcode 6.1 or 6.2 in ' \
60
60
  "#{expected_xcode_select_path} and set as active developer " \
61
61
  'directory by running `sudo xcode-select -s ' \
62
62
  "#{expected_xcode_select_path}`"
@@ -64,7 +64,7 @@ module Jazzy
64
64
 
65
65
  def self.xcode_developer_directory
66
66
  dir = Pathname(`xcode-select -p`.chomp)
67
- dir.directory? ? dir.realpath : nil
67
+ dir.directory? ? dir.expand_path : nil
68
68
  end
69
69
 
70
70
  def self.assert_swift_version
@@ -79,10 +79,8 @@ module Jazzy
79
79
  def self.run_sourcekitten(arguments)
80
80
  assert_xcode_location
81
81
  assert_swift_version
82
- bin_path = Pathname(__FILE__).parent + 'sourcekitten/sourcekitten'
83
- command = "#{bin_path} #{(arguments).join(' ')}"
84
- output = `#{command}`
85
- raise "Running `#{command}` failed: " + output unless $?.success?
82
+ bin_path = Pathname(__FILE__).parent + 'SourceKitten/sourcekitten'
83
+ output, _ = Executable.execute_command(bin_path, arguments, true)
86
84
  output
87
85
  end
88
86
 
@@ -97,13 +95,12 @@ module Jazzy
97
95
 
98
96
  def self.documented_child?(doc)
99
97
  return false unless doc['key.substructure']
100
- doc['key.substructure'].each do |child|
101
- return true if documented_child?(child)
102
- end
103
- false
98
+ doc['key.substructure'].any? { |child| documented_child?(child) }
104
99
  end
105
100
 
106
101
  def self.should_document?(doc)
102
+ return false if doc['key.doc.comment'].to_s.include?(':nodoc:')
103
+
107
104
  # Always document extensions, since we can't tell what ACL they are
108
105
  return true if doc['key.kind'] == 'source.lang.swift.decl.extension'
109
106
 
@@ -121,41 +118,62 @@ module Jazzy
121
118
  make_default_doc_info(declaration)
122
119
  end
123
120
 
124
- def self.parameters_from_xml(xml)
125
- xml.xpath('Parameters/Parameter').map do |parameter_el|
121
+ def self.make_paragraphs(doc, key)
122
+ return nil unless doc[key]
123
+ doc[key].map do |p|
124
+ if para = p['Para']
125
+ Jazzy.markdown.render(para)
126
+ elsif verbatim = p['Verbatim']
127
+ Jazzy.markdown.render("```\n#{verbatim}```\n")
128
+ else
129
+ warn "Jazzy could not recognize the `#{p.keys.first}` tag. " \
130
+ 'Please report this by filing an issue at ' \
131
+ 'https://github.com/realm/jazzy/issues along with the comment ' \
132
+ 'including this tag.'
133
+ Jazzy.markdown.render(p.values.first)
134
+ end
135
+ end.join
136
+ end
137
+
138
+ def self.parameters(doc)
139
+ (doc['key.doc.parameters'] || []).map do |p|
126
140
  {
127
- name: XMLHelper.xpath(parameter_el, 'Name'),
128
- discussion: Jazzy.markdown.render(
129
- XMLHelper.xpath(parameter_el, 'Discussion') || '',
130
- ),
141
+ name: p['name'],
142
+ discussion: make_paragraphs(p, 'discussion'),
131
143
  }
132
144
  end
133
145
  end
134
146
 
135
147
  def self.make_doc_info(doc, declaration)
136
- return nil unless should_document?(doc)
137
- xml_key = 'key.doc.full_as_xml'
138
- return process_undocumented_token(doc, declaration) unless doc[xml_key]
148
+ return unless should_document?(doc)
149
+ unless doc['key.doc.full_as_xml']
150
+ return process_undocumented_token(doc, declaration)
151
+ end
139
152
 
140
- xml = Nokogiri::XML(doc[xml_key]).root
141
- declaration.line = XMLHelper.attribute(xml, 'line').to_i
142
- declaration.column = XMLHelper.attribute(xml, 'column').to_i
153
+ declaration.line = doc['key.doc.line']
154
+ declaration.column = doc['key.doc.column']
143
155
  declaration.declaration = Highlighter.highlight(
144
- doc['key.parsed_declaration'] || XMLHelper.xpath(xml, 'Declaration'),
156
+ doc['key.parsed_declaration'] || doc['key.doc.declaration'],
145
157
  'swift',
146
158
  )
147
- declaration.abstract = XMLHelper.xpath(xml, 'Abstract')
148
- declaration.discussion = XMLHelper.xpath(xml, 'Discussion')
149
- declaration.return = XMLHelper.xpath(xml, 'ResultDiscussion')
159
+ stripped_comment = string_until_first_rest_definition(
160
+ doc['key.doc.comment'],
161
+ ) || ''
162
+ declaration.abstract = Jazzy.markdown.render(stripped_comment)
163
+ declaration.discussion = ''
164
+ declaration.return = make_paragraphs(doc, 'key.doc.result_discussion')
150
165
 
151
- nodoc = ->(string) { string.to_s.include? '<dt>nodoc</dt>' }
152
- return if nodoc[declaration.abstract] || nodoc[declaration.discussion]
153
-
154
- declaration.parameters = parameters_from_xml(xml)
166
+ declaration.parameters = parameters(doc)
155
167
 
156
168
  @documented_count += 1
157
169
  end
158
170
 
171
+ def self.string_until_first_rest_definition(string)
172
+ matches = /^\s*:[^\s]+:/.match(string)
173
+ return string unless matches
174
+ string[0...matches.begin(0)]
175
+ end
176
+
159
177
  def self.make_substructure(doc, declaration)
160
178
  if doc['key.substructure']
161
179
  declaration.children = make_source_declarations(
@@ -197,6 +215,8 @@ module Jazzy
197
215
  doc['key.annotated_decl'],
198
216
  )
199
217
  declaration.access_control_level = acl
218
+ declaration.start_line = doc['key.parsed_scope.start']
219
+ declaration.end_line = doc['key.parsed_scope.end']
200
220
 
201
221
  next unless make_doc_info(doc, declaration)
202
222
  make_substructure(doc, declaration)
@@ -46,7 +46,7 @@ require 'rubygems'
46
46
  require 'bundler/setup'
47
47
  require 'pretty_bacon'
48
48
  require 'colored'
49
- require 'clintegracon'
49
+ require 'CLIntegracon'
50
50
 
51
51
  CLIntegracon.configure do |c|
52
52
  c.spec_path = ROOT + 'spec/integration_specs'
@@ -88,7 +88,7 @@ describe_cli 'jazzy' do
88
88
  behaves_like cli_spec 'document_alamofire',
89
89
  '-m Alamofire -a Alamofire ' \
90
90
  '-u https://nshipster.com/alamofire ' \
91
- '-x -project,Alamofire.xcodeproj ' \
91
+ '-x -project,Alamofire.xcodeproj,-dry-run ' \
92
92
  '-g https://github.com/Alamofire/Alamofire ' \
93
93
  '--github-file-prefix https://github.com/' \
94
94
  'Alamofire/Alamofire/blob/1.1.0 ' \
@@ -107,6 +107,7 @@ describe_cli 'jazzy' do
107
107
  '-m MiscJazzyFeatures -a Realm ' \
108
108
  '-u https://github.com/realm/jazzy ' \
109
109
  '-g https://github.com/realm/jazzy ' \
110
+ '-x -dry-run ' \
110
111
  '--min-acl private'
111
112
  end
112
113
  end
@@ -10,7 +10,7 @@ module Jazzy
10
10
  SourceKitten.stubs(:`)
11
11
  .returns '/Applications/Xcode-Beta.app/Contents/Developer'
12
12
  should.raise { SourceKitten.assert_xcode_location }.message.should
13
- .match %r{Please install Xcode.*/Applications/Xcode.app}
13
+ .match %r{Please install or symlink Xcode.*/Applications/Xcode.app}
14
14
  end
15
15
 
16
16
  it 'validates the current xcode version' do