jazzy 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -9
  3. data/CHANGELOG.md +31 -0
  4. data/Gemfile.lock +7 -7
  5. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/SourceKittenFramework +0 -0
  6. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Commandant.framework/Commandant +0 -0
  7. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Commandant.framework/Versions/A/Commandant +0 -0
  8. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Commandant.framework/Versions/A/Resources/Info.plist +10 -6
  9. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Result.framework/Result +0 -0
  10. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/{LlamaKit.framework → Result.framework}/Versions/A/Resources/Info.plist +15 -16
  11. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Result.framework/Versions/A/Result +0 -0
  12. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SWXMLHash.framework/SWXMLHash +0 -0
  13. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SWXMLHash.framework/Versions/A/Resources/Info.plist +10 -6
  14. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SWXMLHash.framework/Versions/A/SWXMLHash +0 -0
  15. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/SwiftXPC +0 -0
  16. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/Resources/Info.plist +10 -6
  17. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SwiftXPC.framework/Versions/A/SwiftXPC +0 -0
  18. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftCore.dylib +0 -0
  19. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftCoreGraphics.dylib +0 -0
  20. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftDarwin.dylib +0 -0
  21. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftDispatch.dylib +0 -0
  22. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftFoundation.dylib +0 -0
  23. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftObjectiveC.dylib +0 -0
  24. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Resources/Info.plist +11 -7
  25. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/SourceKittenFramework +0 -0
  26. data/lib/jazzy/SourceKitten/bin/sourcekitten +0 -0
  27. data/lib/jazzy/config.rb +16 -1
  28. data/lib/jazzy/doc.rb +19 -0
  29. data/lib/jazzy/doc_builder.rb +20 -12
  30. data/lib/jazzy/gem_version.rb +1 -1
  31. data/lib/jazzy/jazzy_markdown.rb +53 -0
  32. data/lib/jazzy/source_declaration.rb +1 -0
  33. data/lib/jazzy/source_declaration/type.rb +28 -0
  34. data/lib/jazzy/sourcekitten.rb +90 -41
  35. data/spec/integration_spec.rb +57 -10
  36. metadata +5 -6
  37. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/LlamaKit.framework/LlamaKit +0 -0
  38. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/LlamaKit.framework/Versions/A/LlamaKit +0 -0
  39. data/lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftSecurity.dylib +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfdc8ff94daa57717cca49f094c0844e887966c7
4
- data.tar.gz: 4476ebbceab1a7f423718385181b5d7c8ec6c9e3
3
+ metadata.gz: 371a8d34a746d3593ff47191c1ae36f57c93310f
4
+ data.tar.gz: 419ab9cf9fb43c6434504ccad2aaf6c4a0a46aa4
5
5
  SHA512:
6
- metadata.gz: 07c5389be619f4e5739cb9afc114b423fa9dbad9217d47e91a5538aaa54c89eb0fd6d27b286812ace6ee82ca4873f01bc6c770cadf3e1231461741f112047be2
7
- data.tar.gz: ed8b0bd4d88757e4eeda790f50debc4ff74356ff4812312991b78148462738b4692a469d2ad896adf35a8e8589faad95ddd831962ff5f59d715557d65a6e5ec5
6
+ metadata.gz: bbee289354b3e4ea2e2874af3bf97040605658839ad9a28be5821f23f4ea9369492eff7f6b00de5106a4945924142643670ead0723d2b163b071e04c8d83365b
7
+ data.tar.gz: 5c9c31bafd32bf396285c74a0bbbea2984f274a45cbe3dab761a349db56e2c04b4bea7a1deff133b8cb409f2ab3becc7d2cde176e3cc99dc3b8f36b6e1f5a7f3
@@ -1,16 +1,17 @@
1
1
  language: objective-c
2
- osx_image: xcode6.4
3
- cache: bundler
4
2
  branches:
5
3
  only:
6
4
  - master
7
- rvm:
8
- - system
9
- before_install:
10
- - sudo gem install bundler
11
- - git submodule update --init --recursive
12
- script:
13
- - bundle exec rake spec
5
+ git:
6
+ submodules: false
7
+ before_install: git submodule update --init --recursive
8
+ script: bundle exec rake spec
14
9
  notifications:
15
10
  email: false
16
11
  slack: realmio:vPdpsG9NLDo2DNlbqtcMAQuE
12
+ matrix:
13
+ include:
14
+ - osx_image: xcode6.4
15
+ env: TRAVIS_SWIFT_VERSION=1.2
16
+ - osx_image: xcode7
17
+ env: TRAVIS_SWIFT_VERSION=2.0
@@ -1,3 +1,34 @@
1
+ ## 0.3.0
2
+
3
+ ##### Breaking
4
+
5
+ * `--swift-version` now defaults to 2.0 instead of 1.2.
6
+ [JP Simard](https://github.com/jpsim)
7
+
8
+ ##### Enhancements
9
+
10
+ * Now supports Swift 2.0 (previous Swift versions are still supported).
11
+ [JP Simard](https://github.com/jpsim)
12
+ [Samuel Giddins](https://github.com/segiddins)
13
+
14
+ * Declarations can now be grouped by custom categories defined in a JSON or YAML
15
+ file passed to `--categories`.
16
+ [pcantrell](https://github.com/pcantrell)
17
+
18
+ ##### Bug Fixes
19
+
20
+ * "View on GitHub" is now only generated if a GitHub URL is specified.
21
+ [mbogh](https://github.com/mbogh)
22
+ [#244](https://github.com/realm/jazzy/issues/244)
23
+
24
+ * Empty extensions are no longer documented.
25
+ [pcantrell](https://github.com/pcantrell)
26
+
27
+ * Undocumented enum cases are now supported.
28
+ [JP Simard](https://github.com/jpsim)
29
+ [#74](https://github.com/realm/jazzy/issues/74)
30
+
31
+
1
32
  ## 0.2.4
2
33
 
3
34
  ##### Breaking
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jazzy (0.2.4)
4
+ jazzy (0.3.0)
5
5
  cocoapods (~> 0.38)
6
6
  mustache (~> 0.99)
7
7
  open4
@@ -14,7 +14,7 @@ PATH
14
14
  GEM
15
15
  remote: http://rubygems.org/
16
16
  specs:
17
- activesupport (4.2.3)
17
+ activesupport (4.2.4)
18
18
  i18n (~> 0.7)
19
19
  json (~> 1.7, >= 1.7.7)
20
20
  minitest (~> 5.1)
@@ -47,13 +47,13 @@ GEM
47
47
  activesupport (>= 3.2.15)
48
48
  fuzzy_match (~> 2.0.4)
49
49
  nap (~> 0.8.0)
50
- cocoapods-downloader (0.9.1)
50
+ cocoapods-downloader (0.9.3)
51
51
  cocoapods-plugins (0.4.2)
52
52
  nap
53
53
  cocoapods-stats (0.5.3)
54
54
  nap (~> 0.8)
55
- cocoapods-trunk (0.6.1)
56
- nap (>= 0.8)
55
+ cocoapods-trunk (0.6.4)
56
+ nap (>= 0.8, < 2.0)
57
57
  netrc (= 0.7.8)
58
58
  cocoapods-try (0.4.5)
59
59
  colored (1.2)
@@ -66,7 +66,7 @@ GEM
66
66
  json (1.8.3)
67
67
  liferaft (0.0.4)
68
68
  metaclass (0.0.4)
69
- minitest (5.7.0)
69
+ minitest (5.8.0)
70
70
  mocha (1.1.0)
71
71
  metaclass (~> 0.0.1)
72
72
  mocha-on-bacon (0.2.2)
@@ -94,7 +94,7 @@ 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.16)
97
+ sass (3.4.18)
98
98
  slop (3.6.0)
99
99
  sqlite3 (1.3.10)
100
100
  thread_safe (0.3.5)
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>BuildMachineOSBuild</key>
6
- <string>15A235d</string>
6
+ <string>15A279b</string>
7
7
  <key>CFBundleDevelopmentRegion</key>
8
8
  <string>en</string>
9
9
  <key>CFBundleExecutable</key>
@@ -20,22 +20,26 @@
20
20
  <string>1.0</string>
21
21
  <key>CFBundleSignature</key>
22
22
  <string>????</string>
23
+ <key>CFBundleSupportedPlatforms</key>
24
+ <array>
25
+ <string>MacOSX</string>
26
+ </array>
23
27
  <key>CFBundleVersion</key>
24
28
  <string>1</string>
25
29
  <key>DTCompiler</key>
26
30
  <string>com.apple.compilers.llvm.clang.1_0</string>
27
31
  <key>DTPlatformBuild</key>
28
- <string>6E35b</string>
32
+ <string>7A192o</string>
29
33
  <key>DTPlatformVersion</key>
30
34
  <string>GM</string>
31
35
  <key>DTSDKBuild</key>
32
- <string>14D125</string>
36
+ <string>15A244e</string>
33
37
  <key>DTSDKName</key>
34
- <string>macosx10.10</string>
38
+ <string>macosx10.11</string>
35
39
  <key>DTXcode</key>
36
- <string>0640</string>
40
+ <string>0700</string>
37
41
  <key>DTXcodeBuild</key>
38
- <string>6E35b</string>
42
+ <string>7A192o</string>
39
43
  <key>NSHumanReadableCopyright</key>
40
44
  <string>Copyright © 2014 Carthage. All rights reserved.</string>
41
45
  </dict>
@@ -3,45 +3,44 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>BuildMachineOSBuild</key>
6
- <string>15A235d</string>
6
+ <string>15A279b</string>
7
7
  <key>CFBundleDevelopmentRegion</key>
8
8
  <string>en</string>
9
9
  <key>CFBundleExecutable</key>
10
- <string>LlamaKit</string>
10
+ <string>Result</string>
11
11
  <key>CFBundleIdentifier</key>
12
- <string>net.robnapier.LlamaKit</string>
12
+ <string>com.antitypical.Result</string>
13
13
  <key>CFBundleInfoDictionaryVersion</key>
14
14
  <string>6.0</string>
15
15
  <key>CFBundleName</key>
16
- <string>LlamaKit</string>
16
+ <string>Result</string>
17
17
  <key>CFBundlePackageType</key>
18
18
  <string>FMWK</string>
19
19
  <key>CFBundleShortVersionString</key>
20
- <string>1.0</string>
20
+ <string>0.0.1</string>
21
21
  <key>CFBundleSignature</key>
22
22
  <string>????</string>
23
+ <key>CFBundleSupportedPlatforms</key>
24
+ <array>
25
+ <string>MacOSX</string>
26
+ </array>
23
27
  <key>CFBundleVersion</key>
24
28
  <string>1</string>
25
29
  <key>DTCompiler</key>
26
30
  <string>com.apple.compilers.llvm.clang.1_0</string>
27
31
  <key>DTPlatformBuild</key>
28
- <string>6E35b</string>
32
+ <string>7A192o</string>
29
33
  <key>DTPlatformVersion</key>
30
34
  <string>GM</string>
31
35
  <key>DTSDKBuild</key>
32
- <string>14D125</string>
36
+ <string>15A244e</string>
33
37
  <key>DTSDKName</key>
34
- <string>macosx10.10</string>
38
+ <string>macosx10.11</string>
35
39
  <key>DTXcode</key>
36
- <string>0640</string>
40
+ <string>0700</string>
37
41
  <key>DTXcodeBuild</key>
38
- <string>6E35b</string>
42
+ <string>7A192o</string>
39
43
  <key>NSHumanReadableCopyright</key>
40
- <string>Copyright © 2014 Rob Napier. All rights reserved.</string>
41
- <key>UIDeviceFamily</key>
42
- <array>
43
- <integer>1</integer>
44
- <integer>2</integer>
45
- </array>
44
+ <string>Copyright © 2015 Rob Rix. All rights reserved.</string>
46
45
  </dict>
47
46
  </plist>
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>BuildMachineOSBuild</key>
6
- <string>15A235d</string>
6
+ <string>15A279b</string>
7
7
  <key>CFBundleDevelopmentRegion</key>
8
8
  <string>en</string>
9
9
  <key>CFBundleExecutable</key>
@@ -20,22 +20,26 @@
20
20
  <string>1.0</string>
21
21
  <key>CFBundleSignature</key>
22
22
  <string>????</string>
23
+ <key>CFBundleSupportedPlatforms</key>
24
+ <array>
25
+ <string>MacOSX</string>
26
+ </array>
23
27
  <key>CFBundleVersion</key>
24
28
  <string>1</string>
25
29
  <key>DTCompiler</key>
26
30
  <string>com.apple.compilers.llvm.clang.1_0</string>
27
31
  <key>DTPlatformBuild</key>
28
- <string>6E35b</string>
32
+ <string>7A192o</string>
29
33
  <key>DTPlatformVersion</key>
30
34
  <string>GM</string>
31
35
  <key>DTSDKBuild</key>
32
- <string>14D125</string>
36
+ <string>15A244e</string>
33
37
  <key>DTSDKName</key>
34
- <string>macosx10.10</string>
38
+ <string>macosx10.11</string>
35
39
  <key>DTXcode</key>
36
- <string>0640</string>
40
+ <string>0700</string>
37
41
  <key>DTXcodeBuild</key>
38
- <string>6E35b</string>
42
+ <string>7A192o</string>
39
43
  <key>UIDeviceFamily</key>
40
44
  <array>
41
45
  <integer>1</integer>
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>BuildMachineOSBuild</key>
6
- <string>15A235d</string>
6
+ <string>15A279b</string>
7
7
  <key>CFBundleDevelopmentRegion</key>
8
8
  <string>en</string>
9
9
  <key>CFBundleExecutable</key>
@@ -20,22 +20,26 @@
20
20
  <string>1.0.0</string>
21
21
  <key>CFBundleSignature</key>
22
22
  <string>????</string>
23
+ <key>CFBundleSupportedPlatforms</key>
24
+ <array>
25
+ <string>MacOSX</string>
26
+ </array>
23
27
  <key>CFBundleVersion</key>
24
28
  <string>1</string>
25
29
  <key>DTCompiler</key>
26
30
  <string>com.apple.compilers.llvm.clang.1_0</string>
27
31
  <key>DTPlatformBuild</key>
28
- <string>6E35b</string>
32
+ <string>7A192o</string>
29
33
  <key>DTPlatformVersion</key>
30
34
  <string>GM</string>
31
35
  <key>DTSDKBuild</key>
32
- <string>14D125</string>
36
+ <string>15A244e</string>
33
37
  <key>DTSDKName</key>
34
- <string>macosx10.10</string>
38
+ <string>macosx10.11</string>
35
39
  <key>DTXcode</key>
36
- <string>0640</string>
40
+ <string>0700</string>
37
41
  <key>DTXcodeBuild</key>
38
- <string>6E35b</string>
42
+ <string>7A192o</string>
39
43
  <key>NSHumanReadableCopyright</key>
40
44
  <string>Copyright © 2014 JP Simard. All rights reserved.</string>
41
45
  </dict>
@@ -3,7 +3,7 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>BuildMachineOSBuild</key>
6
- <string>15A235d</string>
6
+ <string>15A279b</string>
7
7
  <key>CFBundleDevelopmentRegion</key>
8
8
  <string>en</string>
9
9
  <key>CFBundleExecutable</key>
@@ -17,25 +17,29 @@
17
17
  <key>CFBundlePackageType</key>
18
18
  <string>FMWK</string>
19
19
  <key>CFBundleShortVersionString</key>
20
- <string>0.4.4</string>
20
+ <string>0.5.0</string>
21
21
  <key>CFBundleSignature</key>
22
22
  <string>????</string>
23
+ <key>CFBundleSupportedPlatforms</key>
24
+ <array>
25
+ <string>MacOSX</string>
26
+ </array>
23
27
  <key>CFBundleVersion</key>
24
28
  <string>1</string>
25
29
  <key>DTCompiler</key>
26
30
  <string>com.apple.compilers.llvm.clang.1_0</string>
27
31
  <key>DTPlatformBuild</key>
28
- <string>6E35b</string>
32
+ <string>7A192o</string>
29
33
  <key>DTPlatformVersion</key>
30
34
  <string>GM</string>
31
35
  <key>DTSDKBuild</key>
32
- <string>14D125</string>
36
+ <string>15A244e</string>
33
37
  <key>DTSDKName</key>
34
- <string>macosx10.10</string>
38
+ <string>macosx10.11</string>
35
39
  <key>DTXcode</key>
36
- <string>0640</string>
40
+ <string>0700</string>
37
41
  <key>DTXcodeBuild</key>
38
- <string>6E35b</string>
42
+ <string>7A192o</string>
39
43
  <key>NSHumanReadableCopyright</key>
40
44
  <string>Copyright © 2015 SourceKitten. All rights reserved.</string>
41
45
  </dict>
@@ -30,6 +30,7 @@ module Jazzy
30
30
  attr_accessor :docset_path
31
31
  attr_accessor :source_directory
32
32
  attr_accessor :excluded_files
33
+ attr_accessor :custom_categories
33
34
  attr_accessor :template_directory
34
35
  attr_accessor :swift_version
35
36
  attr_accessor :assets_directory
@@ -49,8 +50,9 @@ module Jazzy
49
50
  self.skip_undocumented = false
50
51
  self.source_directory = Pathname.pwd
51
52
  self.excluded_files = []
53
+ self.custom_categories = {}
52
54
  self.template_directory = Pathname(__FILE__).parent + 'templates'
53
- self.swift_version = '1.2'
55
+ self.swift_version = '2.0'
54
56
  self.assets_directory = Pathname(__FILE__).parent + 'assets'
55
57
  end
56
58
 
@@ -198,6 +200,11 @@ module Jazzy
198
200
  config.excluded_files = files.map { |f| File.expand_path(f) }
199
201
  end
200
202
 
203
+ opt.on('--categories file',
204
+ 'JSON or YAML file with custom groupings') do |file|
205
+ config.custom_categories = parse_config_file(file)
206
+ end
207
+
201
208
  opt.on('-v', '--version', 'Print version number') do
202
209
  puts 'jazzy version: ' + Jazzy::VERSION
203
210
  exit
@@ -217,6 +224,14 @@ module Jazzy
217
224
  config
218
225
  end
219
226
 
227
+ def self.parse_config_file(file)
228
+ case File.extname(file)
229
+ when '.json' then JSON.parse(File.read(file))
230
+ when '.yaml', '.yml' then YAML.load(File.read(file))
231
+ else raise "Config file must be .yaml or .json, but got #{file.inspect}"
232
+ end
233
+ end
234
+
220
235
  #-------------------------------------------------------------------------#
221
236
 
222
237
  # @!group Singleton
@@ -10,6 +10,25 @@ module Jazzy
10
10
  class Doc < Mustache
11
11
  self.template_name = 'doc'
12
12
 
13
+ ############################################################################
14
+ # TODO: Remove shortly (kept for backwards compatibility)
15
+ #
16
+ def date
17
+ # Fake date is used to keep integration tests consistent
18
+ ENV['JAZZY_FAKE_DATE'] || DateTime.now.strftime('%Y-%m-%d')
19
+ end
20
+
21
+ def year
22
+ # Fake date is used to keep integration tests consistent
23
+ if ENV['JAZZY_FAKE_DATE']
24
+ ENV['JAZZY_FAKE_DATE'][0..3]
25
+ else
26
+ DateTime.now.strftime('%Y')
27
+ end
28
+ end
29
+ #
30
+ ############################################################################
31
+
13
32
  def copyright
14
33
  config = Config.instance
15
34
  copyright = config.copyright || (
@@ -31,9 +31,12 @@ module Jazzy
31
31
  docs.map do |doc|
32
32
  {
33
33
  section: doc.name,
34
- children: doc.children.sort_by(&:name).map do |child|
35
- { name: child.name, url: child.url }
36
- end,
34
+ children: doc.children
35
+ .sort_by(&:name)
36
+ .sort_by(&:nav_order)
37
+ .map do |child|
38
+ { name: child.name, url: child.url }
39
+ end,
37
40
  }
38
41
  end
39
42
  end
@@ -70,25 +73,26 @@ module Jazzy
70
73
  # @param [Config] options Build options
71
74
  # @param [Array] doc_structure @see #doc_structure_for_docs
72
75
  def self.build_docs(output_dir, docs, source_module)
73
- each_doc(output_dir, docs) do |doc, path, depth|
76
+ each_doc(output_dir, docs) do |doc, path|
74
77
  prepare_output_dir(path.parent, false)
75
- path_to_root = ['../'].cycle(depth).to_a.join('')
78
+ depth = path.relative_path_from(output_dir).each_filename.count - 1
79
+ path_to_root = '../' * depth
76
80
  path.open('w') do |file|
77
81
  file.write(document(source_module, doc, path_to_root))
78
82
  end
79
83
  end
80
84
  end
81
85
 
82
- def self.each_doc(output_dir, docs, depth = 0, &block)
86
+ def self.each_doc(output_dir, docs, &block)
83
87
  docs.each do |doc|
84
88
  next if doc.name != 'index' && doc.children.count == 0
85
- path = output_dir + "#{doc.name}.html"
86
- block.call(doc, path, depth)
89
+ # Assuming URL is relative to documentation root:
90
+ path = output_dir + (doc.url || "#{doc.name}.html")
91
+ block.call(doc, path)
87
92
  next if doc.name == 'index'
88
93
  each_doc(
89
- output_dir + doc.name,
94
+ output_dir,
90
95
  doc.children,
91
- depth + 1,
92
96
  &block
93
97
  )
94
98
  end
@@ -183,7 +187,9 @@ module Jazzy
183
187
  doc[:structure] = source_module.doc_structure
184
188
  doc[:module_name] = source_module.name
185
189
  doc[:author_name] = source_module.author_name
186
- doc[:github_url] = source_module.github_url.to_s
190
+ # TODO: Remove shortly (kept for backwards compatibility)
191
+ doc[:author_website] = source_module.author_url
192
+ doc[:github_url] = source_module.github_url
187
193
  doc[:dash_url] = source_module.dash_url
188
194
  doc[:path_to_root] = path_to_root
189
195
  doc[:hide_name] = true
@@ -287,7 +293,9 @@ module Jazzy
287
293
  doc[:tasks] = render_tasks(source_module, doc_model.children)
288
294
  doc[:module_name] = source_module.name
289
295
  doc[:author_name] = source_module.author_name
290
- doc[:github_url] = source_module.github_url.to_s
296
+ # TODO: Remove shortly (kept for backwards compatibility)
297
+ doc[:author_website] = source_module.author_url.to_s
298
+ doc[:github_url] = source_module.github_url
291
299
  doc[:dash_url] = source_module.dash_url
292
300
  doc[:path_to_root] = path_to_root
293
301
  doc.render
@@ -1,3 +1,3 @@
1
1
  module Jazzy
2
- VERSION = '0.2.4' unless defined? Jazzy::VERSION
2
+ VERSION = '0.3.0' unless defined? Jazzy::VERSION
3
3
  end
@@ -19,6 +19,59 @@ module Jazzy
19
19
  "<h#{header_level} id='#{text_slug}'>#{text}</h#{header_level}>\n"
20
20
  end
21
21
 
22
+ SPECIAL_LIST_TYPES = %w(Attention
23
+ Author
24
+ Authors
25
+ Bug
26
+ Complexity
27
+ Copyright
28
+ Date
29
+ Experiment
30
+ Important
31
+ Invariant
32
+ Note
33
+ Parameter
34
+ Postcondition
35
+ Precondition
36
+ Remark
37
+ Requires
38
+ Returns
39
+ See
40
+ SeeAlso
41
+ Since
42
+ TODO
43
+ Throws
44
+ Version
45
+ Warning).freeze
46
+
47
+ # rubocop:disable RegexpLiteral
48
+ SPECIAL_LIST_TYPE_REGEX = %r{
49
+ \A\s* # optional leading spaces
50
+ (<p>\s*)? # optional opening p tag
51
+ # any one of our special list types
52
+ (#{SPECIAL_LIST_TYPES.map(&Regexp.method(:escape)).join('|')})
53
+ [\s:] # followed by either a space or a colon
54
+ }ix
55
+ # rubocop:enable RegexpLiteral
56
+
57
+ ELIDED_LI_TOKEN = '7wNVzLB0OYPL2eGlPKu8q4vITltqh0Y6DPZf659TPMAeYh49o'.freeze
58
+
59
+ def list_item(text, _list_type)
60
+ return ELIDED_LI_TOKEN if text =~ SPECIAL_LIST_TYPE_REGEX
61
+ str = '<li>'
62
+ str << text.strip
63
+ str << "</li>\n"
64
+ end
65
+
66
+ def list(text, list_type)
67
+ elided = text.gsub!(ELIDED_LI_TOKEN, '')
68
+ return if text =~ /\A\s*\Z/ && elided
69
+ str = "\n"
70
+ str << (list_type == :ordered ? "<ol>\n" : "<ul>\n")
71
+ str << text
72
+ str << (list_type == :ordered ? "</ol>\n" : "</ul>\n")
73
+ end
74
+
22
75
  OPTIONS = {
23
76
  autolink: true,
24
77
  fenced_code_blocks: true,
@@ -23,6 +23,7 @@ module Jazzy
23
23
  attr_accessor :access_control_level
24
24
  attr_accessor :start_line
25
25
  attr_accessor :end_line
26
+ attr_accessor :nav_order
26
27
 
27
28
  def overview
28
29
  "#{abstract}\n\n#{discussion}".strip
@@ -31,6 +31,14 @@ module Jazzy
31
31
  kind == 'source.lang.swift.syntaxtype.comment.mark'
32
32
  end
33
33
 
34
+ def enum_case?
35
+ kind == 'source.lang.swift.decl.enumcase'
36
+ end
37
+
38
+ def enum_element?
39
+ kind == 'source.lang.swift.decl.enumelement'
40
+ end
41
+
34
42
  def should_document?
35
43
  declaration? && !param?
36
44
  end
@@ -39,6 +47,10 @@ module Jazzy
39
47
  kind =~ /^source\.lang\.swift\.decl\..*/
40
48
  end
41
49
 
50
+ def extension?
51
+ kind =~ /^source\.lang\.swift\.decl\.extension.*/
52
+ end
53
+
42
54
  def param?
43
55
  # SourceKit strangely categorizes initializer parameters as local
44
56
  # variables, so both kinds represent a parameter in jazzy.
@@ -84,6 +96,10 @@ module Jazzy
84
96
  jazzy: 'Global Variable',
85
97
  dash: 'Global',
86
98
  }.freeze,
99
+ 'source.lang.swift.decl.enumcase' => {
100
+ jazzy: 'Enum Case',
101
+ dash: 'Case',
102
+ }.freeze,
87
103
  'source.lang.swift.decl.enumelement' => {
88
104
  jazzy: 'Enum Element',
89
105
  dash: 'Element',
@@ -96,6 +112,18 @@ module Jazzy
96
112
  jazzy: 'Extension',
97
113
  dash: 'Extension',
98
114
  }.freeze,
115
+ 'source.lang.swift.decl.extension.class' => {
116
+ jazzy: 'Class Extension',
117
+ dash: 'Extension',
118
+ }.freeze,
119
+ 'source.lang.swift.decl.extension.enum' => {
120
+ jazzy: 'Enum Extension',
121
+ dash: 'Extension',
122
+ }.freeze,
123
+ 'source.lang.swift.decl.extension.protocol' => {
124
+ jazzy: 'Protocol Extension',
125
+ dash: 'Extension',
126
+ }.freeze,
99
127
  'source.lang.swift.decl.function.free' => {
100
128
  jazzy: 'Function',
101
129
  dash: 'Function',
@@ -15,17 +15,49 @@ module Jazzy
15
15
  @documented_count = 0
16
16
  @undocumented_tokens = []
17
17
 
18
- # Group root-level docs by type and add as children to a group doc element
19
- def self.group_docs(docs, type)
20
- group, docs = docs.partition { |doc| doc.type == type }
21
- docs << SourceDeclaration.new.tap do |sd|
18
+ # Group root-level docs by custom categories (if any) and type
19
+ def self.group_docs(docs)
20
+ custom_categories, docs = group_custom_categories(docs)
21
+ type_categories, uncategorized = group_type_categories(
22
+ docs, custom_categories.any? ? 'Other ' : '')
23
+ custom_categories + type_categories + uncategorized
24
+ end
25
+
26
+ def self.group_custom_categories(docs)
27
+ group = Config.instance.custom_categories.map do |category|
28
+ children = category['children'].flat_map do |name|
29
+ docs_with_name, docs = docs.partition { |doc| doc.name == name }
30
+ if docs_with_name.empty?
31
+ STDERR.puts 'WARNING: No documented top-level declarations match ' \
32
+ "name \"#{name}\" specified in categories file"
33
+ end
34
+ docs_with_name
35
+ end
36
+ # Category config overrides alphabetization
37
+ children.each.with_index { |child, i| child.nav_order = i }
38
+ make_group(children, category['name'], '')
39
+ end
40
+ [group.compact, docs]
41
+ end
42
+
43
+ def self.group_type_categories(docs, type_category_prefix)
44
+ group = SourceDeclaration::Type.all.map do |type|
45
+ children, docs = docs.partition { |doc| doc.type == type }
46
+ make_group(
47
+ children,
48
+ type_category_prefix + type.plural_name,
49
+ "The following #{type.plural_name.downcase} are available globally.")
50
+ end
51
+ [group.compact, docs]
52
+ end
53
+
54
+ def self.make_group(group, name, abstract)
55
+ SourceDeclaration.new.tap do |sd|
22
56
  sd.type = SourceDeclaration::Type.overview
23
- sd.name = type.plural_name
24
- sd.abstract = "The following #{type.plural_name.downcase} are " \
25
- 'available globally.'
57
+ sd.name = name
58
+ sd.abstract = abstract
26
59
  sd.children = group
27
- end if group.count > 0
28
- docs
60
+ end unless group.empty?
29
61
  end
30
62
 
31
63
  # rubocop:disable Metrics/MethodLength
@@ -33,20 +65,22 @@ module Jazzy
33
65
  # @return [Hash] input docs with URLs
34
66
  def self.make_doc_urls(docs, parents)
35
67
  docs.each do |doc|
36
- if doc.children.count > 0
37
- # Create HTML page for this doc if it has children
38
- parents_slash = parents.count > 0 ? '/' : ''
39
- doc.url = parents.join('/') + parents_slash + doc.name + '.html'
40
- doc.children = make_doc_urls(doc.children, parents + [doc.name])
68
+ if parents.empty? || doc.children.count > 0
69
+ # Create HTML page for this doc if it has children or is root-level
70
+ doc.url = (
71
+ subdir_for_doc(doc, parents) +
72
+ [doc.name + '.html']
73
+ ).join('/')
74
+ doc.children = make_doc_urls(doc.children, parents + [doc])
41
75
  else
42
76
  # Don't create HTML page for this doc if it doesn't have children
43
77
  # Instead, make its link a hash-link on its parent's page
44
78
  if doc.typename == '<<error type>>'
45
79
  warn 'A compile error prevented ' +
46
- (parents[1..-1] + [doc.name]).join('.') + ' from receiving a ' \
47
- 'unique USR. Documentation may be incomplete. Please check for ' \
48
- 'compile errors by running `xcodebuild ' \
49
- "#{Config.instance.xcodebuild_arguments.shelljoin}`."
80
+ (parents[1..-1] + [doc]).map(&:name).join('.') +
81
+ ' from receiving a unique USR. Documentation may be ' \
82
+ 'incomplete. Please check for compile errors by running ' \
83
+ "`xcodebuild #{Config.instance.xcodebuild_arguments.shelljoin}`."
50
84
  end
51
85
  id = doc.usr
52
86
  unless id
@@ -58,12 +92,22 @@ module Jazzy
58
92
  'project. If this token is declared in an `#if` block, please ' \
59
93
  'ignore this message.'
60
94
  end
61
- doc.url = parents.join('/') + '.html#/' + id
95
+ doc.url = parents.last.url + '#/' + id
62
96
  end
63
97
  end
64
98
  end
65
99
  # rubocop:enable Metrics/MethodLength
66
100
 
101
+ # Determine the subdirectory in which a doc should be placed
102
+ def self.subdir_for_doc(doc, parents)
103
+ parents.map(&:name).tap do |names|
104
+ # We always want to create top-level subdirs according to type (Struct,
105
+ # Class, etc), but parents[0] might be a custom category name.
106
+ top_level_decl = (parents + [doc])[1]
107
+ names[0] = top_level_decl.type.plural_name if top_level_decl
108
+ end
109
+ end
110
+
67
111
  # Run sourcekitten with given arguments and return STDOUT
68
112
  def self.run_sourcekitten(arguments)
69
113
  xcode = XCInvoke::Xcode.find_swift_version(Config.instance.swift_version)
@@ -88,19 +132,16 @@ module Jazzy
88
132
  end
89
133
 
90
134
  def self.should_document?(doc)
91
- unless doc['key.usr']
92
- warn "`#{doc['key.name']}` has no USR. First make sure all modules " \
93
- 'used in your project have been imported. If all used modules ' \
94
- 'are imported, please report this problem by filing an issue ' \
95
- 'at https://github.com/realm/jazzy/issues along with your ' \
96
- 'Xcode project. If this token is declared in an `#if` block, ' \
97
- 'please ignore this message.'
98
- return false
99
- end
100
135
  return false if doc['key.doc.comment'].to_s.include?(':nodoc:')
101
136
 
102
- # Always document extensions, since we can't tell what ACL they are
103
- return true if doc['key.kind'] == 'source.lang.swift.decl.extension'
137
+ # Document extensions & enum elements, since we can't tell their ACL.
138
+ type = SourceDeclaration::Type.new(doc['key.kind'])
139
+ return true if type.enum_element?
140
+ if type.extension?
141
+ return Array(doc['key.substructure']).any? do |subdoc|
142
+ should_document?(subdoc)
143
+ end
144
+ end
104
145
 
105
146
  SourceDeclaration::AccessControlLevel.from_doc(doc) >= @min_acl
106
147
  end
@@ -153,10 +194,7 @@ module Jazzy
153
194
  doc['key.parsed_declaration'] || doc['key.doc.declaration'],
154
195
  'swift',
155
196
  )
156
- stripped_comment = string_until_first_rest_definition(
157
- doc['key.doc.comment'],
158
- ) || ''
159
- declaration.abstract = Jazzy.markdown.render(stripped_comment)
197
+ declaration.abstract = comment_from_doc(doc)
160
198
  declaration.discussion = ''
161
199
  declaration.return = make_paragraphs(doc, 'key.doc.result_discussion')
162
200
 
@@ -165,10 +203,15 @@ module Jazzy
165
203
  @documented_count += 1
166
204
  end
167
205
 
168
- def self.string_until_first_rest_definition(string)
169
- matches = /^\s*:[^\s]+:/.match(string)
170
- return string unless matches
171
- string[0...matches.begin(0)]
206
+ def self.comment_from_doc(doc)
207
+ swift_version = Config.instance.swift_version.to_f
208
+ comment = doc['key.doc.comment'] || ''
209
+ if swift_version < 2
210
+ # comment until first ReST definition
211
+ matches = /^\s*:[^\s]+:/.match(comment)
212
+ comment = comment[0...matches.begin(0)] if matches
213
+ end
214
+ Jazzy.markdown.render(comment)
172
215
  end
173
216
 
174
217
  def self.make_substructure(doc, declaration)
@@ -198,6 +241,11 @@ module Jazzy
198
241
  if declaration.type.mark? && doc['key.name'].start_with?('MARK: ')
199
242
  current_mark = SourceMark.new(doc['key.name'])
200
243
  end
244
+ if declaration.type.enum_case?
245
+ # Enum "cases" are thin wrappers around enum "elements".
246
+ declarations += make_source_declarations(doc['key.substructure'])
247
+ next
248
+ end
201
249
  next unless declaration.type.should_document?
202
250
 
203
251
  unless declaration.type.name
@@ -256,9 +304,10 @@ module Jazzy
256
304
  sourcekitten_json = filter_excluded_files(JSON.parse(sourcekitten_output))
257
305
  docs = make_source_declarations(sourcekitten_json)
258
306
  docs = deduplicate_declarations(docs)
259
- SourceDeclaration::Type.all.each do |type|
260
- docs = group_docs(docs, type)
261
- end
307
+ docs = group_docs(docs)
308
+ # Remove top-level enum cases because it means they have an ACL lower
309
+ # than min_acl
310
+ docs = docs.reject { |doc| doc.type.enum_element? }
262
311
  [make_doc_urls(docs, []), doc_coverage, @undocumented_tokens]
263
312
  end
264
313
  end
@@ -87,24 +87,32 @@ describe_cli 'jazzy' do
87
87
  s.replace_path ROOT.to_s, 'ROOT'
88
88
  end
89
89
 
90
- describe 'jazzy' do
90
+ travis_swift = ENV['TRAVIS_SWIFT_VERSION']
91
+
92
+ describe 'jazzy swift 1.2' do
91
93
  describe 'Creates docs with a module name, author name, project URL, ' \
92
94
  'xcodebuild options, and github info' do
93
- behaves_like cli_spec 'document_alamofire',
95
+ behaves_like cli_spec 'document_alamofire1.2',
94
96
  '-m Alamofire -a Alamofire ' \
95
97
  '-u https://nshipster.com/alamofire ' \
96
98
  '-x -project,Alamofire.xcodeproj,-dry-run ' \
97
99
  '-g https://github.com/Alamofire/Alamofire ' \
98
100
  '--github-file-prefix https://github.com/' \
99
- 'Alamofire/Alamofire/blob/1.1.0 ' \
100
- '--module-version 1.1.0 ' \
101
+ 'Alamofire/Alamofire/blob/1.3.1 ' \
102
+ '--module-version 1.3.1 ' \
101
103
  '-r http://static.realm.io/jazzy_demo/Alamofire/ ' \
102
- '--skip-undocumented'
104
+ '--skip-undocumented ' \
105
+ '--swift-version=1.2'
103
106
  end
104
107
 
105
108
  describe 'Creates Realm Swift docs' do
106
- realm_version = '0.93.2'
107
- behaves_like cli_spec 'document_realm_swift',
109
+ realm_version = ''
110
+ dir = ROOT + 'spec/integration_specs/document_realm_swift1.2/before'
111
+ Dir.chdir(dir) do
112
+ realm_version = `./build.sh get-version`.chomp
113
+ `REALM_SWIFT_VERSION=1.2 ./build.sh set-swift-version`
114
+ end
115
+ behaves_like cli_spec 'document_realm_swift1.2',
108
116
  '--author Realm ' \
109
117
  '--author_url "https://realm.io" ' \
110
118
  '--github_url ' \
@@ -116,12 +124,51 @@ describe_cli 'jazzy' do
116
124
  '--root-url https://realm.io/docs/swift/' \
117
125
  "#{realm_version}/api/ " \
118
126
  '--xcodebuild-arguments ' \
119
- '-project,RealmSwift.xcodeproj,-dry-run'
127
+ '-project,RealmSwift.xcodeproj,-dry-run ' \
128
+ '--swift-version=1.2'
120
129
  end
121
130
 
122
131
  describe 'Creates docs for a podspec with dependencies and subspecs' do
123
132
  behaves_like cli_spec 'document_moya_podspec',
124
- '--podspec=Moya.podspec'
133
+ '--podspec=Moya.podspec --swift-version=1.2'
134
+ end
135
+ end if !travis_swift || travis_swift == '1.2'
136
+
137
+ describe 'jazzy swift 2.0' do
138
+ describe 'Creates docs with a module name, author name, project URL, ' \
139
+ 'xcodebuild options, and github info' do
140
+ behaves_like cli_spec 'document_alamofire',
141
+ '-m Alamofire -a Alamofire ' \
142
+ '-u https://nshipster.com/alamofire ' \
143
+ '-x -project,Alamofire.xcodeproj,-dry-run ' \
144
+ '-g https://github.com/Alamofire/Alamofire ' \
145
+ '--github-file-prefix https://github.com/' \
146
+ 'Alamofire/Alamofire/blob/swift-2.0 ' \
147
+ '--module-version swift-2.0 ' \
148
+ '-r http://static.realm.io/jazzy_demo/Alamofire/ ' \
149
+ '--skip-undocumented'
150
+ end
151
+
152
+ describe 'Creates Realm Swift docs' do
153
+ realm_version = ''
154
+ Dir.chdir(ROOT + 'spec/integration_specs/document_realm_swift/before') do
155
+ realm_version = `./build.sh get-version`.chomp
156
+ `REALM_SWIFT_VERSION=2.0 ./build.sh set-swift-version`
157
+ end
158
+ behaves_like cli_spec 'document_realm_swift',
159
+ '--author Realm ' \
160
+ '--author_url "https://realm.io" ' \
161
+ '--github_url ' \
162
+ 'https://github.com/realm/realm-cocoa ' \
163
+ '--github-file-prefix https://github.com/realm/' \
164
+ "realm-cocoa/tree/v#{realm_version} " \
165
+ '--module RealmSwift ' \
166
+ "--module-version #{realm_version} " \
167
+ '--root-url https://realm.io/docs/swift/' \
168
+ "#{realm_version}/api/ " \
169
+ '--xcodebuild-arguments ' \
170
+ '-project,RealmSwift.xcodeproj,-dry-run ' \
171
+ '--template-directory "docs/templates/swift" '
125
172
  end
126
173
 
127
174
  describe 'Creates docs for Swift project with a variety of contents' do
@@ -132,5 +179,5 @@ describe_cli 'jazzy' do
132
179
  '-x -dry-run ' \
133
180
  '--min-acl private'
134
181
  end
135
- end
182
+ end if !travis_swift || travis_swift == '2.0'
136
183
  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.2.4
4
+ version: 0.3.0
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-08-27 00:00:00.000000000 Z
13
+ date: 2015-09-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cocoapods
@@ -179,9 +179,9 @@ files:
179
179
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Commandant.framework/Commandant
180
180
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Commandant.framework/Versions/A/Commandant
181
181
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Commandant.framework/Versions/A/Resources/Info.plist
182
- - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/LlamaKit.framework/LlamaKit
183
- - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/LlamaKit.framework/Versions/A/LlamaKit
184
- - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/LlamaKit.framework/Versions/A/Resources/Info.plist
182
+ - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Result.framework/Result
183
+ - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Result.framework/Versions/A/Resources/Info.plist
184
+ - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/Result.framework/Versions/A/Result
185
185
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SWXMLHash.framework/SWXMLHash
186
186
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SWXMLHash.framework/Versions/A/Resources/Info.plist
187
187
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/SWXMLHash.framework/Versions/A/SWXMLHash
@@ -194,7 +194,6 @@ files:
194
194
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftDispatch.dylib
195
195
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftFoundation.dylib
196
196
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftObjectiveC.dylib
197
- - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Frameworks/libswiftSecurity.dylib
198
197
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/Resources/Info.plist
199
198
  - lib/jazzy/SourceKitten/Frameworks/SourceKittenFramework.framework/Versions/A/SourceKittenFramework
200
199
  - lib/jazzy/SourceKitten/Rakefile