jazzy 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f8bf2a0d123cd83a7fd7c6d8928c07735f1c4da
4
- data.tar.gz: c8dcc98da703c0184eab711e25dfe7a22efa2e55
3
+ metadata.gz: f2baa2074d45fd8acf5c3a9afcaf52f9f4614608
4
+ data.tar.gz: 57e138cb29858db55c158aa6006114f9f09a2fa2
5
5
  SHA512:
6
- metadata.gz: 9f5c0e859e43e9416f70a5225affc7ee6967ff59925405826453320da6a7b92b3515c510983b6b50c13e94d995c84198b0bc1c7f5c950e3fbe456a6d734066db
7
- data.tar.gz: d5617da8fd853e0c5c8277109f6ca017937e3f792104343790a7eb628a6ff746a184e361bb27ce3d2342af4952b6e377bc97561a72fc388be0c24ff4d96a9744
6
+ metadata.gz: d14e639dda30299184b75472b051bba215675390e7f99b302de680987bf7dbfc2a8f324148f38ad1b22fd272e17cdc447bcdcc5d39c4ff5d8b804a051103139c
7
+ data.tar.gz: 7540ba48abfb300b5787b96afc56350c0a79e7434cb194cc47a9aeb2694143b06640db746d2c208c835f528bd833da115fc8ce5b04590ae68ea826785d831166
data/CHANGELOG.md CHANGED
@@ -1,6 +1,4 @@
1
- ## Master
2
-
3
- [sourcekitten](https://github.com/jpsim/sourcekitten/compare/0.3.1...master)
1
+ ## 0.1.3
4
2
 
5
3
  ##### Breaking
6
4
 
@@ -8,11 +6,34 @@
8
6
 
9
7
  ##### Enhancements
10
8
 
11
- * None.
9
+ * Improve the styling of `dl` elements (parsed key-value pairs).
10
+ [segiddins](https://github.com/segiddins)
11
+
12
+ * Raise exceptions if Xcode requirements aren't met.
13
+ [JP Simard](https://github.com/jpsim)
12
14
 
13
15
  ##### Bug Fixes
14
16
 
15
- * None.
17
+ * No longer count initializers with parameters as undocumented.
18
+ [JP Simard](https://github.com/jpsim)
19
+ [#183](https://github.com/realm/jazzy/issues/183)
20
+
21
+ * No longer crash when a token is missing a USR.
22
+ [JP Simard](https://github.com/jpsim)
23
+ [#171](https://github.com/realm/jazzy/issues/171)
24
+
25
+ * Fixed encoding issues in some environments.
26
+ [James Barrow](https://github.com/Baza207)
27
+ [#152](https://github.com/realm/jazzy/issues/152)
28
+
29
+ * No longer count undocumented externally declared tokens as undocumented.
30
+ [JP Simard](https://github.com/jpsim)
31
+ [#188](https://github.com/realm/jazzy/issues/188)
32
+
33
+ * Fixed `--source-directory` CLI option.
34
+ [JP Simard](https://github.com/jpsim)
35
+ [#177](https://github.com/realm/jazzy/issues/177)
36
+
16
37
 
17
38
  ## 0.1.2
18
39
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jazzy (0.1.2)
4
+ jazzy (0.1.3)
5
5
  activesupport (~> 4.1)
6
6
  cocoapods (~> 0.36.0.rc.1)
7
7
  mustache (~> 0.99)
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: http://rubygems.org/
16
16
  specs:
17
- activesupport (4.2.0)
17
+ activesupport (4.2.1)
18
18
  i18n (~> 0.7)
19
19
  json (~> 1.7, >= 1.7.7)
20
20
  minitest (~> 5.1)
@@ -29,28 +29,28 @@ GEM
29
29
  clintegracon (0.5.3)
30
30
  colored (~> 1.2)
31
31
  diffy
32
- cocoapods (0.36.0.rc.1)
32
+ cocoapods (0.36.0)
33
33
  activesupport (>= 3.2.15)
34
34
  claide (~> 0.8.1)
35
- cocoapods-core (= 0.36.0.rc.1)
35
+ cocoapods-core (= 0.36.0)
36
36
  cocoapods-downloader (~> 0.8.1)
37
37
  cocoapods-plugins (~> 0.4.1)
38
- cocoapods-trunk (~> 0.5.1)
38
+ cocoapods-trunk (~> 0.6.0)
39
39
  cocoapods-try (~> 0.4.3)
40
40
  colored (~> 1.2)
41
41
  escape (~> 0.0.4)
42
42
  molinillo (~> 0.2.1)
43
43
  nap (~> 0.8)
44
44
  open4 (~> 1.3)
45
- xcodeproj (~> 0.22.0)
46
- cocoapods-core (0.36.0.rc.1)
45
+ xcodeproj (~> 0.23.0)
46
+ cocoapods-core (0.36.0)
47
47
  activesupport (>= 3.2.15)
48
48
  fuzzy_match (~> 2.0.4)
49
49
  nap (~> 0.8.0)
50
50
  cocoapods-downloader (0.8.1)
51
51
  cocoapods-plugins (0.4.1)
52
52
  nap
53
- cocoapods-trunk (0.5.1)
53
+ cocoapods-trunk (0.6.0)
54
54
  nap (>= 0.8)
55
55
  netrc (= 0.7.8)
56
56
  cocoapods-try (0.4.3)
@@ -94,16 +94,16 @@ GEM
94
94
  ruby-progressbar (~> 1.4)
95
95
  ruby-progressbar (1.6.0)
96
96
  safe_yaml (1.0.4)
97
- sass (3.4.11)
97
+ sass (3.4.13)
98
98
  slop (3.6.0)
99
99
  sqlite3 (1.3.10)
100
- thread_safe (0.3.4)
100
+ thread_safe (0.3.5)
101
101
  tzinfo (1.2.2)
102
102
  thread_safe (~> 0.1)
103
103
  webmock (1.20.0)
104
104
  addressable (>= 2.3.6)
105
105
  crack (>= 0.3.2)
106
- xcodeproj (0.22.0)
106
+ xcodeproj (0.23.0)
107
107
  activesupport (>= 3)
108
108
  colored (~> 1.2)
109
109
 
data/Rakefile CHANGED
@@ -28,8 +28,10 @@ begin
28
28
  desc 'Run specs'
29
29
  task :spec do
30
30
  title 'Running Unit Tests'
31
- files = FileList['spec/**/*_spec.rb'].shuffle.join(' ')
31
+ files = FileList['spec/**/*_spec.rb']
32
+ .exclude('spec/integration_spec.rb').shuffle.join(' ')
32
33
  sh "bundle exec bacon #{files}"
34
+ sh 'bundle exec bacon spec/integration_spec.rb'
33
35
 
34
36
  Rake::Task['rubocop'].invoke
35
37
  end
@@ -92,7 +94,7 @@ begin
92
94
  File.open("#{destination}/Rakefile", 'w') { |f| f.write rakefile }
93
95
  end
94
96
 
95
- rescue LoadError, NameError
97
+ rescue LoadError, NameError => e
96
98
  $stderr.puts "\033[0;31m" \
97
99
  '[!] Some Rake tasks haven been disabled because the environment' \
98
100
  ' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \
data/lib/jazzy.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  require 'jazzy/config'
2
2
  require 'jazzy/doc_builder'
3
+
4
+ Encoding.default_external = Encoding::UTF_8
@@ -1,6 +1,7 @@
1
1
  $doc_coverage_color: #999;
2
2
  $content_wrapper_width: 980px;
3
3
  $code-font: 12px Menlo, monospace;
4
+ $graybox-border: 1px solid rgba(233, 233, 233, 1);
4
5
 
5
6
  html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td {
6
7
  background: transparent;
@@ -102,6 +103,26 @@ html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr
102
103
  display: inline-block;
103
104
  }
104
105
  }
106
+ dl {
107
+ border: $graybox-border;
108
+ @extend .para;
109
+ dt {
110
+ float: left;
111
+ width: 50px;
112
+ @extend em.term;
113
+ font-style: italic;
114
+ text-align: right;
115
+ padding: 7px;
116
+ vertical-align: top;
117
+ }
118
+ dd {
119
+ word-break: break-word;
120
+ margin-left: 64px;
121
+ padding: 7px;
122
+ min-width: 70px;
123
+ border-left: $graybox-border;
124
+ }
125
+ }
105
126
  .pointy-thing-container {
106
127
  background: #fff;
107
128
  border-bottom: 1px solid rgba(233, 233, 233, 1);
@@ -508,7 +529,7 @@ div.Swift {
508
529
  }
509
530
 
510
531
  .graybox {
511
- border: 1px solid rgba(233, 233, 233, 1);
532
+ border: $graybox-border;
512
533
  border-collapse: collapse;
513
534
  border-spacing: 0;
514
535
  empty-cells: hide;
@@ -890,9 +911,9 @@ html.dash {
890
911
  }
891
912
  .chapter {
892
913
  border: none;
893
- width: auto;
894
- position: static;
895
- padding-bottom: 50px;
914
+ width: auto;
915
+ position: static;
916
+ padding-bottom: 50px;
896
917
  box-shadow: none;
897
918
  }
898
919
  #reference .chapter {
@@ -52,9 +52,10 @@ module Jazzy
52
52
  if podspec = options.podspec
53
53
  stdout = PodspecDocumenter.new(podspec).sourcekitten_output
54
54
  else
55
- stdout = SourceKitten.run_sourcekitten(
56
- ['doc'] + options.xcodebuild_arguments,
57
- )
55
+ stdout = Dir.chdir(Config.instance.source_directory) do
56
+ arguments = ['doc'] + options.xcodebuild_arguments
57
+ SourceKitten.run_sourcekitten(arguments)
58
+ end
58
59
  end
59
60
  unless $?.success?
60
61
  warn 'Please pass in xcodebuild arguments using -x'
@@ -276,9 +277,7 @@ module Jazzy
276
277
  doc[:name] = doc_model.name
277
278
  doc[:kind] = doc_model.type.name
278
279
  doc[:dash_type] = doc_model.type.dash_type
279
- doc[:overview] = Jazzy.markdown.render(
280
- (doc_model.abstract || '') + (doc_model.discussion || ''),
281
- )
280
+ doc[:overview] = Jazzy.markdown.render(doc_model.overview)
282
281
  doc[:structure] = source_module.doc_structure
283
282
  doc[:tasks] = render_tasks(source_module, doc_model.children)
284
283
  doc[:module_name] = source_module.name
@@ -1,3 +1,3 @@
1
1
  module Jazzy
2
- VERSION = '0.1.2' unless defined? Jazzy::VERSION
2
+ VERSION = '0.1.3' unless defined? Jazzy::VERSION
3
3
  end
@@ -18,5 +18,9 @@ module Jazzy
18
18
  attr_accessor :url
19
19
  attr_accessor :mark
20
20
  attr_accessor :access_control_level
21
+
22
+ def overview
23
+ "#{abstract}\n\n#{discussion}".strip
24
+ end
21
25
  end
22
26
  end
@@ -31,10 +31,21 @@ module Jazzy
31
31
  kind == 'source.lang.swift.syntaxtype.comment.mark'
32
32
  end
33
33
 
34
+ def should_document?
35
+ declaration? && !param?
36
+ end
37
+
34
38
  def declaration?
35
39
  kind =~ /^source\.lang\.swift\.decl\..*/
36
40
  end
37
41
 
42
+ def param?
43
+ # SourceKit strangely categorizes initializer parameters as local
44
+ # variables, so both kinds represent a parameter in jazzy.
45
+ kind == 'source.lang.swift.decl.var.parameter' ||
46
+ kind == 'source.lang.swift.decl.var.local'
47
+ end
48
+
38
49
  def self.overview
39
50
  Type.new('Overview')
40
51
  end
@@ -38,13 +38,47 @@ module Jazzy
38
38
  else
39
39
  # Don't create HTML page for this doc if it doesn't have children
40
40
  # Instead, make its link a hash-link on its parent's page
41
- doc.url = parents.join('/') + '.html#/' + doc.usr
41
+ id = doc.usr
42
+ unless id
43
+ id = doc.name || 'unknown'
44
+ warn "`#{id}` has no USR. First make sure all modules used in " \
45
+ 'your project have been imported. If all used modules are ' \
46
+ 'imported, please report this by filing an issue at ' \
47
+ 'https://github.com/realm/jazzy/issues along with your Xcode ' \
48
+ 'project.'
49
+ end
50
+ doc.url = parents.join('/') + '.html#/' + id
42
51
  end
43
52
  end
44
53
  end
45
54
 
55
+ def self.assert_xcode_location
56
+ expected_xcode_select_path =
57
+ Pathname('/Applications/Xcode.app/Contents/Developer')
58
+ return if xcode_developer_directory == expected_xcode_select_path
59
+ raise 'Please install Xcode 6.1 or 6.2 in ' \
60
+ "#{expected_xcode_select_path} and set as active developer " \
61
+ 'directory by running `sudo xcode-select -s ' \
62
+ "#{expected_xcode_select_path}`"
63
+ end
64
+
65
+ def self.xcode_developer_directory
66
+ dir = Pathname(`xcode-select -p`.chomp)
67
+ dir.directory? ? dir.realpath : nil
68
+ end
69
+
70
+ def self.assert_swift_version
71
+ swift_version = `xcrun swift --version` =~ /Swift version ([\d\.]+)/ &&
72
+ Regexp.last_match[1]
73
+ expected_swift_version = '1.1'
74
+ return if swift_version == expected_swift_version
75
+ raise "Jazzy only works with Swift #{expected_swift_version}."
76
+ end
77
+
46
78
  # Run sourcekitten with given arguments and return STDOUT
47
79
  def self.run_sourcekitten(arguments)
80
+ assert_xcode_location
81
+ assert_swift_version
48
82
  bin_path = Pathname(__FILE__).parent + 'sourcekitten/sourcekitten'
49
83
  command = "#{bin_path} #{(arguments).join(' ')}"
50
84
  output = `#{command}`
@@ -78,7 +112,11 @@ module Jazzy
78
112
  end
79
113
 
80
114
  def self.process_undocumented_token(doc, declaration)
81
- @undocumented_tokens << doc
115
+ source_directory = Config.instance.source_directory.to_s
116
+ filepath = doc['key.filepath']
117
+ if !filepath || filepath.start_with?(source_directory)
118
+ @undocumented_tokens << doc
119
+ end
82
120
  return nil if !documented_child?(doc) && @skip_undocumented
83
121
  make_default_doc_info(declaration)
84
122
  end
@@ -98,7 +136,6 @@ module Jazzy
98
136
  return nil unless should_document?(doc)
99
137
  xml_key = 'key.doc.full_as_xml'
100
138
  return process_undocumented_token(doc, declaration) unless doc[xml_key]
101
- @documented_count += 1
102
139
 
103
140
  xml = Nokogiri::XML(doc[xml_key]).root
104
141
  declaration.line = XMLHelper.attribute(xml, 'line').to_i
@@ -111,7 +148,12 @@ module Jazzy
111
148
  declaration.discussion = XMLHelper.xpath(xml, 'Discussion')
112
149
  declaration.return = XMLHelper.xpath(xml, 'ResultDiscussion')
113
150
 
151
+ nodoc = ->(string) { string.to_s.include? '<dt>nodoc</dt>' }
152
+ return if nodoc[declaration.abstract] || nodoc[declaration.discussion]
153
+
114
154
  declaration.parameters = parameters_from_xml(xml)
155
+
156
+ @documented_count += 1
115
157
  end
116
158
 
117
159
  def self.make_substructure(doc, declaration)
@@ -139,12 +181,12 @@ module Jazzy
139
181
  if declaration.type.mark? && doc['key.name'].start_with?('MARK: ')
140
182
  current_mark = SourceMark.new(doc['key.name'])
141
183
  end
142
- next unless declaration.type.declaration?
184
+ next unless declaration.type.should_document?
143
185
 
144
186
  unless declaration.type.name
145
- raise 'Please file an issue on ' \
146
- 'https://github.com/realm/jazzy/issues about adding support for ' \
147
- "`#{declaration.type.kind}`."
187
+ raise 'Please file an issue at ' \
188
+ 'https://github.com/realm/jazzy/issues about adding support ' \
189
+ "for `#{declaration.type.kind}`."
148
190
  end
149
191
 
150
192
  declaration.file = doc['key.filepath']
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Jazzy
4
+ describe SourceKitten do
5
+ it 'validates the xcode-select path' do
6
+ SourceKitten.stubs(:`)
7
+ .returns '/Applications/Xcode.app/Contents/Developer'
8
+ should.not.raise { SourceKitten.assert_xcode_location }
9
+
10
+ SourceKitten.stubs(:`)
11
+ .returns '/Applications/Xcode-Beta.app/Contents/Developer'
12
+ should.raise { SourceKitten.assert_xcode_location }.message.should
13
+ .match %r{Please install Xcode.*/Applications/Xcode.app}
14
+ end
15
+
16
+ it 'validates the current xcode version' do
17
+ SourceKitten.stubs(:`).returns <<-O
18
+ Swift version 1.1 (swift-600.0.57.4)
19
+ Target: x86_64-apple-darwin14.1.0
20
+ O
21
+ should.not.raise { SourceKitten.assert_swift_version }
22
+
23
+ SourceKitten.stubs(:`).returns <<-O
24
+ Apple Swift version 1.2 (swiftlang-602.0.47.4 clang-602.0.48)
25
+ Target: x86_64-apple-darwin14.1.0
26
+ O
27
+ should.raise { SourceKitten.assert_swift_version }.message.should
28
+ .match /Jazzy.*Swift 1\.1/
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bacon'
4
+ require 'mocha-on-bacon'
5
+ require 'pretty_bacon'
6
+ require 'pathname'
7
+
8
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
9
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
10
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
11
+
12
+ require 'jazzy'
13
+
14
+ require 'spec_helper/pre_flight'
15
+
16
+ Bacon.summary_at_exit
17
+
18
+ module Bacon
19
+ class Context
20
+ include Jazzy::Config::Mixin
21
+
22
+ def temporary_directory
23
+ SpecHelper.temporary_directory
24
+ end
25
+ end
26
+ end
27
+
28
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
29
+
30
+ module SpecHelper
31
+ def self.temporary_directory
32
+ ROOT + 'tmp'
33
+ end
34
+ end
@@ -0,0 +1,21 @@
1
+ # Restores the config to the default state before each requirement
2
+
3
+ module Bacon
4
+ class Context
5
+ old_run_requirement = instance_method(:run_requirement)
6
+
7
+ define_method(:run_requirement) do |description, spec|
8
+ temporary_directory = SpecHelper.temporary_directory
9
+
10
+ ::Jazzy::Config.instance = nil
11
+ ::Jazzy::Config.instance.tap do |c|
12
+ c.source_directory = temporary_directory
13
+ end
14
+
15
+ temporary_directory.rmtree if temporary_directory.exist?
16
+ temporary_directory.mkpath
17
+
18
+ old_run_requirement.bind(self).call(description, spec)
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jazzy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Simard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-28 00:00:00.000000000 Z
13
+ date: 2015-03-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mustache
@@ -243,6 +243,9 @@ files:
243
243
  - logo.sketch
244
244
  - screenshot.jpg
245
245
  - spec/integration_spec.rb
246
+ - spec/sourcekitten_spec.rb
247
+ - spec/spec_helper.rb
248
+ - spec/spec_helper/pre_flight.rb
246
249
  homepage: http://github.com/realm/jazzy
247
250
  licenses:
248
251
  - MIT
@@ -263,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
266
  version: '0'
264
267
  requirements: []
265
268
  rubyforge_project:
266
- rubygems_version: 2.4.6
269
+ rubygems_version: 2.2.2
267
270
  signing_key:
268
271
  specification_version: 4
269
272
  summary: Soulful docs for Swift & Objective-C.