jazzy 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc3616cb1da2da7c201cea6c6bc81659ee5a816da770bc8cc5c087b75e227a19
4
- data.tar.gz: 9a459463afd8a9b12881175acb5c638d1c27d4f86f6a78898d4d04fd77a2912f
3
+ metadata.gz: 6439cb8dc035d69bb0243f06e3b7140b079dd6892840b49e015be636efa7ff64
4
+ data.tar.gz: fc97247251923d0f385637721405435e2a3211110c14369876767e2572a25175
5
5
  SHA512:
6
- metadata.gz: d7e283f41d40a59988031091c64b1be2fc8a78334a3e544d4e00cfe2cb08beebffd2c2148e2e82cd8db63125c88a7ea8d1262e16c8fca1440ee8ef5f64cfbc89
7
- data.tar.gz: fa1111eda7b0f9f4d06ee49ddd1f114d0625970f77f3ef6515ddac933ce4551eed8852db56e89b95fa80f82e28b75508ecaf90e303df994659a169ae732cf9c7
6
+ metadata.gz: 4049263b20f10ed92f23f23971df8d2fd57a58d95f0312fd34c5c36f1be170b6889ea82a31f3a972505025d69e4ce3f0b55343b17794ccff06bde3a46d87db3c
7
+ data.tar.gz: 10ac755d262c1a19c451b8dce5969924bd95f1f5601ae5f76c2fb748ac6f74d92b3bc6240334a185da3a6a8987a29ea3cc27c138b666d6e95ed0ed9ea930d833
data/CHANGELOG.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## 0.11.0
2
+
3
+ ##### Breaking
4
+
5
+ * None.
6
+
7
+ ##### Enhancements
8
+
9
+ * Sass support now provided by `libsass` via `sassc` instead of the
10
+ deprecated Ruby Sass gem.
11
+ [John Fairhurst](https://github.com/johnfairh)
12
+
13
+ * Update bundled jQuery to 3.4.1 (all themes).
14
+ [Paul Idstein](https://github.com/idstein)
15
+
16
+ * Support Xcode 11 Swift projects that pass a response file to the Swift
17
+ compiler.
18
+ [John Fairhurst](https://github.com/johnfairh)
19
+ [#1087](https://github.com/realm/jazzy/issues/1087)
20
+
21
+ * Generate Swift docs from a Swift Package Manager package without
22
+ requiring an Xcode project file. Add `--swift-build-tool` to choose
23
+ the build method if both `.xcodeproj` and `Package.swift` files are
24
+ present. Add `--build-tool-flags` as a preferred alias for
25
+ `--xcodebuild-flags`.
26
+ [John Fairhurst](https://github.com/johnfairh)
27
+ [#487](https://github.com/realm/jazzy/issues/487)
28
+
29
+ ##### Bug Fixes
30
+
31
+ * Preserve non-latin characters in guide filenames and heading IDs.
32
+ [John Fairhurst](https://github.com/johnfairh)
33
+ [#1091](https://github.com/realm/jazzy/issues/1091)
34
+
35
+ * Generate correct html for custom categories containing special
36
+ characters.
37
+ [John Fairhurst](https://github.com/johnfairh)
38
+ [#945](https://github.com/realm/jazzy/issues/945)
39
+
40
+ * Fix crash on files with misplaced documentation comments.
41
+ [John Fairhurst](https://github.com/johnfairh)
42
+ [#1083](https://github.com/realm/jazzy/issues/1083)
43
+
1
44
  ## 0.10.0
2
45
 
3
46
  ##### Breaking
data/Gemfile.lock CHANGED
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jazzy (0.10.0)
4
+ jazzy (0.11.0)
5
5
  cocoapods (~> 1.5)
6
6
  mustache (~> 1.1)
7
7
  open4
8
8
  redcarpet (~> 3.4)
9
9
  rouge (>= 2.0.6, < 4.0)
10
- sass (~> 3.6)
10
+ sassc (~> 2.1)
11
11
  sqlite3 (~> 1.3)
12
12
  xcinvoke (~> 0.3.0)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- CFPropertyList (3.0.0)
17
+ CFPropertyList (3.0.1)
18
18
  activesupport (4.2.11.1)
19
19
  i18n (~> 0.7)
20
20
  minitest (~> 5.1)
@@ -33,10 +33,10 @@ GEM
33
33
  clintegracon (0.7.0)
34
34
  colored (~> 1.2)
35
35
  diffy
36
- cocoapods (1.7.2)
36
+ cocoapods (1.7.5)
37
37
  activesupport (>= 4.0.2, < 5)
38
38
  claide (>= 1.0.2, < 2.0)
39
- cocoapods-core (= 1.7.2)
39
+ cocoapods-core (= 1.7.5)
40
40
  cocoapods-deintegrate (>= 1.0.3, < 2.0)
41
41
  cocoapods-downloader (>= 1.2.2, < 2.0)
42
42
  cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -52,7 +52,7 @@ GEM
52
52
  nap (~> 1.0)
53
53
  ruby-macho (~> 1.4)
54
54
  xcodeproj (>= 1.10.0, < 2.0)
55
- cocoapods-core (1.7.2)
55
+ cocoapods-core (1.7.5)
56
56
  activesupport (>= 4.0.2, < 6)
57
57
  fuzzy_match (~> 2.0.4)
58
58
  nap (~> 1.0)
@@ -62,7 +62,7 @@ GEM
62
62
  nap
63
63
  cocoapods-search (1.0.0)
64
64
  cocoapods-stats (1.1.0)
65
- cocoapods-trunk (1.3.1)
65
+ cocoapods-trunk (1.4.0)
66
66
  nap (>= 0.8, < 2.0)
67
67
  netrc (~> 0.11)
68
68
  cocoapods-try (1.1.0)
@@ -130,11 +130,8 @@ GEM
130
130
  rainbow (2.2.2)
131
131
  rake
132
132
  rake (10.5.0)
133
- rb-fsevent (0.10.3)
134
- rb-inotify (0.10.0)
135
- ffi (~> 1.0)
136
- redcarpet (3.4.0)
137
- rouge (3.4.1)
133
+ redcarpet (3.5.0)
134
+ rouge (3.10.0)
138
135
  rubocop (0.49.0)
139
136
  parallel (~> 1.10)
140
137
  parser (>= 2.3.3.1, < 3.0)
@@ -145,11 +142,8 @@ GEM
145
142
  ruby-macho (1.4.0)
146
143
  ruby-progressbar (1.10.1)
147
144
  safe_yaml (1.0.5)
148
- sass (3.7.4)
149
- sass-listen (~> 4.0.0)
150
- sass-listen (4.0.0)
151
- rb-fsevent (~> 0.9, >= 0.9.4)
152
- rb-inotify (~> 0.9, >= 0.9.7)
145
+ sassc (2.2.0)
146
+ ffi (~> 1.9)
153
147
  sawyer (0.8.2)
154
148
  addressable (>= 2.3.5)
155
149
  faraday (> 0.8, < 2.0)
@@ -166,7 +160,7 @@ GEM
166
160
  hashdiff (>= 0.4.0, < 2.0.0)
167
161
  xcinvoke (0.3.0)
168
162
  liferaft (~> 0.0.6)
169
- xcodeproj (1.10.0)
163
+ xcodeproj (1.12.0)
170
164
  CFPropertyList (>= 2.3.3, < 4.0)
171
165
  atomos (~> 0.1.3)
172
166
  claide (>= 1.0.2, < 2.0)
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  Both Swift and Objective-C projects are supported.
10
10
 
11
- *Objective-C support was recently added, so please report any issues you find.*
11
+ *SwiftPM support was recently added, so please report any issues you find.*
12
12
 
13
13
  Instead of parsing your source files, `jazzy` hooks into [Clang][clang] and
14
14
  [SourceKit][sourcekit] to use the [AST][ast] representation of your code and
@@ -23,9 +23,8 @@ unacceptable behavior to [info@realm.io](mailto:info@realm.io).
23
23
 
24
24
  ## Requirements
25
25
 
26
- * A version of [Xcode][xcode] capable of building the project you wish to
27
- document. It must be installed in a location indexed by Spotlight for the
28
- `--swift-version` configuration option to succeed.
26
+ * Development tools that can build the project you wish to document. Jazzy supports
27
+ both [Xcode][xcode] and [Swift Package Manager][spm] projects.
29
28
 
30
29
  ## Installation
31
30
 
@@ -41,8 +40,9 @@ common problems.
41
40
  Run `jazzy` from your command line. Run `jazzy -h` for a list of additional options.
42
41
 
43
42
  If your Swift module is the first thing to build, and it builds fine when running
44
- `xcodebuild` without any arguments from the root of your project, then just running
45
- `jazzy` (without any arguments) from the root of your project should succeed too!
43
+ `xcodebuild` or `swift build` without any arguments from the root of your project, then
44
+ just running `jazzy` (without any arguments) from the root of your project should
45
+ succeed too!
46
46
 
47
47
  You can set options for your project’s documentation in a configuration file,
48
48
  `.jazzy.yaml` by default. For a detailed explanation and an exhaustive list of
@@ -83,13 +83,22 @@ jazzy \
83
83
  --github_url https://github.com/realm/realm-cocoa \
84
84
  --github-file-prefix https://github.com/realm/realm-cocoa/tree/v0.96.2 \
85
85
  --module-version 0.96.2 \
86
- --xcodebuild-arguments -scheme,RealmSwift \
86
+ --build-tool-arguments -scheme,RealmSwift \
87
87
  --module RealmSwift \
88
88
  --root-url https://realm.io/docs/swift/0.96.2/api/ \
89
89
  --output docs/swift_output \
90
90
  --theme docs/themes
91
91
  ```
92
92
 
93
+ This is how docs are generated for a project that uses the Swift Package Manager:
94
+
95
+ ```shell
96
+ jazzy \
97
+ --module DeckOfPlayingCards \
98
+ --swift-build-tool spm \
99
+ --build-tool-arguments -Xswiftc,-swift-version,-Xswiftc,5
100
+ ```
101
+
93
102
  ### Objective-C
94
103
 
95
104
  To generate documentation for Objective-C headers, you must pass the following
@@ -116,7 +125,7 @@ jazzy \
116
125
  --github_url https://github.com/realm/realm-cocoa \
117
126
  --github-file-prefix https://github.com/realm/realm-cocoa/tree/v2.2.0 \
118
127
  --module-version 2.2.0 \
119
- --xcodebuild-arguments --objc,Realm/Realm.h,--,-x,objective-c,-isysroot,$(xcrun --show-sdk-path),-I,$(pwd) \
128
+ --build-tool-arguments --objc,Realm/Realm.h,--,-x,objective-c,-isysroot,$(xcrun --show-sdk-path),-I,$(pwd) \
120
129
  --module Realm \
121
130
  --root-url https://realm.io/docs/objc/2.2.0/api/ \
122
131
  --output docs/objc_output \
@@ -326,3 +335,4 @@ read [our blog](https://realm.io/news) or say hi on twitter
326
335
  [SourceKitten]: https://github.com/jpsim/SourceKitten "SourceKitten"
327
336
  [bundler]: https://rubygems.org/gems/bundler
328
337
  [mustache]: https://mustache.github.io "Mustache"
338
+ [spm]: https://swift.org/package-manager/ "Swift Package Manager"
data/bin/sourcekitten CHANGED
Binary file
data/jazzy.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency 'open4'
23
23
  spec.add_runtime_dependency 'redcarpet', '~> 3.4'
24
24
  spec.add_runtime_dependency 'rouge', ['>= 2.0.6', '< 4.0']
25
- spec.add_runtime_dependency 'sass', '~> 3.6'
25
+ spec.add_runtime_dependency 'sassc', '~> 2.1'
26
26
  spec.add_runtime_dependency 'sqlite3', '~> 1.3'
27
27
  spec.add_runtime_dependency 'xcinvoke', '~> 0.3.0'
28
28
 
data/lib/jazzy/config.rb CHANGED
@@ -79,6 +79,14 @@ module Jazzy
79
79
  @all_config_attrs << Attribute.new(name, **opts)
80
80
  end
81
81
 
82
+ def self.alias_config_attr(name, forward, **opts)
83
+ alias_method name.to_s, forward.to_s
84
+ alias_method "#{name}=", "#{forward}="
85
+ alias_method "#{name}_configured", "#{forward}_configured"
86
+ alias_method "#{name}_configured=", "#{forward}_configured="
87
+ @all_config_attrs << Attribute.new(name, **opts)
88
+ end
89
+
82
90
  class << self
83
91
  attr_reader :all_config_attrs
84
92
  end
@@ -146,11 +154,16 @@ module Jazzy
146
154
  'Default: .jazzy.yaml in source directory or ancestor'],
147
155
  parse: ->(cf) { expand_path(cf) }
148
156
 
149
- config_attr :xcodebuild_arguments,
150
- command_line: ['-x', '--xcodebuild-arguments arg1,arg2,…argN', Array],
151
- description: 'Arguments to forward to xcodebuild',
157
+ config_attr :build_tool_arguments,
158
+ command_line: ['-b', '--build-tool-arguments arg1,arg2,…argN', Array],
159
+ description: 'Arguments to forward to xcodebuild, swift build, or ' \
160
+ 'sourcekitten.',
152
161
  default: []
153
162
 
163
+ alias_config_attr :xcodebuild_arguments, :build_tool_arguments,
164
+ command_line: ['-x', '--xcodebuild-arguments arg1,arg2,…argN', Array],
165
+ description: 'Back-compatibility alias for build_tool_arguments.'
166
+
154
167
  config_attr :sourcekitten_sourcefile,
155
168
  command_line: ['-s', '--sourcekitten-sourcefile FILEPATH'],
156
169
  description: 'File generated from sourcekitten output to parse',
@@ -192,6 +205,20 @@ module Jazzy
192
205
  end
193
206
  end
194
207
 
208
+ SWIFT_BUILD_TOOLS = %w[spm xcodebuild].freeze
209
+
210
+ config_attr :swift_build_tool,
211
+ command_line: "--swift-build-tool #{SWIFT_BUILD_TOOLS.join(' | ')}",
212
+ description: 'Control whether Jazzy uses Swift Package Manager or '\
213
+ 'xcodebuild to build the module to be documented. By '\
214
+ 'default it uses xcodebuild if there is a .xcodeproj '\
215
+ 'file in the source directory.',
216
+ parse: ->(tool) do
217
+ return tool.to_sym if SWIFT_BUILD_TOOLS.include?(tool)
218
+ raise "Unsupported swift_build_tool #{tool}, "\
219
+ "supported values: #{SWIFT_BUILD_TOOLS.join(', ')}"
220
+ end
221
+
195
222
  # ──────── Metadata ────────
196
223
 
197
224
  config_attr :author_name,
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'mustache'
3
3
  require 'pathname'
4
- require 'sass'
4
+ require 'sassc'
5
5
 
6
6
  require 'jazzy/config'
7
7
  require 'jazzy/doc'
@@ -55,21 +55,13 @@ module Jazzy
55
55
  def self.build(options)
56
56
  if options.sourcekitten_sourcefile
57
57
  stdout = options.sourcekitten_sourcefile.read
58
+ elsif options.podspec_configured
59
+ pod_documenter = PodspecDocumenter.new(options.podspec)
60
+ stdout = pod_documenter.sourcekitten_output(options)
58
61
  else
59
- if options.podspec_configured
60
- pod_documenter = PodspecDocumenter.new(options.podspec)
61
- stdout = pod_documenter.sourcekitten_output(options)
62
- else
63
- stdout = Dir.chdir(options.source_directory) do
64
- arguments = SourceKitten.arguments_from_options(options)
65
- SourceKitten.run_sourcekitten(arguments)
66
- end
67
- end
68
- unless $?.success?
69
- warn 'Please pass in xcodebuild arguments using -x'
70
- warn 'If build arguments are correct, please file an issue on ' \
71
- 'https://github.com/realm/jazzy/issues'
72
- exit $?.exitstatus || 1
62
+ stdout = Dir.chdir(options.source_directory) do
63
+ arguments = SourceKitten.arguments_from_options(options)
64
+ SourceKitten.run_sourcekitten(arguments)
73
65
  end
74
66
  end
75
67
 
@@ -95,10 +87,9 @@ module Jazzy
95
87
  def self.each_doc(output_dir, docs, &block)
96
88
  docs.each do |doc|
97
89
  next unless doc.render_as_page?
98
- # Assuming URL is relative to documentation root:
99
- path = output_dir + (doc.url || "#{doc.name}.html")
90
+ # Filepath is relative to documentation root:
91
+ path = output_dir + doc.filepath
100
92
  block.call(doc, path)
101
- next if doc.name == 'index'
102
93
  each_doc(
103
94
  output_dir,
104
95
  doc.children,
@@ -198,8 +189,7 @@ module Jazzy
198
189
  assets_directory = Config.instance.theme_directory + 'assets'
199
190
  FileUtils.cp_r(assets_directory.children, destination)
200
191
  Pathname.glob(destination + 'css/**/*.scss').each do |scss|
201
- contents = scss.read
202
- css = Sass::Engine.new(contents, syntax: :scss).render
192
+ css = SassC::Engine.new(scss.read).render
203
193
  css_filename = scss.sub(/\.scss$/, '')
204
194
  css_filename.open('w') { |f| f.write(css) }
205
195
  FileUtils.rm scss
@@ -78,7 +78,7 @@ module Jazzy
78
78
  'searchIndex (name, type, path);')
79
79
  source_module.all_declarations.select(&:type).each do |doc|
80
80
  db.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) ' \
81
- 'VALUES (?, ?, ?);', [doc.name, doc.type.dash_type, doc.url])
81
+ 'VALUES (?, ?, ?);', [doc.name, doc.type.dash_type, doc.filepath])
82
82
  end
83
83
  end
84
84
  end
@@ -1,3 +1,3 @@
1
1
  module Jazzy
2
- VERSION = '0.10.0'.freeze unless defined? Jazzy::VERSION
2
+ VERSION = '0.11.0'.freeze unless defined? Jazzy::VERSION
3
3
  end
@@ -11,7 +11,7 @@ module Jazzy
11
11
  attr_accessor :default_language
12
12
 
13
13
  def header(text, header_level)
14
- text_slug = text.gsub(/[^\w]+/, '-')
14
+ text_slug = text.gsub(/[^[[:word:]]]+/, '-')
15
15
  .downcase
16
16
  .sub(/^-/, '')
17
17
  .sub(/-$/, '')
@@ -111,6 +111,10 @@ module Jazzy
111
111
  unavailable || deprecated
112
112
  end
113
113
 
114
+ def filepath
115
+ CGI.unescape(url)
116
+ end
117
+
114
118
  def alternative_abstract
115
119
  if file = alternative_abstract_file
116
120
  Pathname(file).read
@@ -20,6 +20,7 @@ module Jazzy
20
20
  def self.make_index(readme_path)
21
21
  SourceDocument.new.tap do |sd|
22
22
  sd.name = 'index'
23
+ sd.url = sd.name + '.html'
23
24
  sd.readme_path = readme_path
24
25
  end
25
26
  end
@@ -36,8 +37,8 @@ module Jazzy
36
37
  Config.instance
37
38
  end
38
39
 
39
- def url
40
- name.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '') + '.html'
40
+ def url_name
41
+ name.downcase.strip.tr(' ', '-').gsub(/[^[[:word:]]-]/, '')
41
42
  end
42
43
 
43
44
  def content(source_module)
@@ -126,12 +126,11 @@ module Jazzy
126
126
  # @return [Hash] input docs with URLs
127
127
  def self.make_doc_urls(docs)
128
128
  docs.each do |doc|
129
- if !doc.parent_in_docs || doc.children.count > 0
130
- # Create HTML page for this doc if it has children or is root-level
129
+ if doc.render_as_page?
131
130
  doc.url = (
132
131
  subdir_for_doc(doc) +
133
132
  [sanitize_filename(doc) + '.html']
134
- ).join('/')
133
+ ).map { |path| ERB::Util.url_encode(path) }.join('/')
135
134
  doc.children = make_doc_urls(doc.children)
136
135
  else
137
136
  # Don't create HTML page for this doc if it doesn't have children
@@ -140,8 +139,8 @@ module Jazzy
140
139
  warn 'A compile error prevented ' + doc.fully_qualified_name +
141
140
  ' from receiving a unique USR. Documentation may be ' \
142
141
  'incomplete. Please check for compile errors by running ' \
143
- '`xcodebuild ' \
144
- "#{Config.instance.xcodebuild_arguments.shelljoin}`."
142
+ '`xcodebuild` or `swift build` with arguments ' \
143
+ "`#{Config.instance.build_tool_arguments.shelljoin}`."
145
144
  end
146
145
  id = doc.usr
147
146
  unless id
@@ -159,17 +158,17 @@ module Jazzy
159
158
  end
160
159
  # rubocop:enable Metrics/MethodLength
161
160
 
162
- # Determine the subdirectory in which a doc should be placed
161
+ # Determine the subdirectory in which a doc should be placed.
162
+ # Guides in the root for back-compatibility.
163
+ # Declarations under outer namespace type (Structures, Classes, etc.)
163
164
  def self.subdir_for_doc(doc)
164
- # We always want to create top-level subdirs according to type (Struct,
165
- # Class, etc).
165
+ return [] if doc.type.markdown?
166
166
  top_level_decl = doc.namespace_path.first
167
- if top_level_decl && top_level_decl.type && top_level_decl.type.name
168
- # File program elements under top ancestor’s type (Struct, Class, etc.)
167
+ if top_level_decl.type.name
169
168
  [top_level_decl.type.plural_url_name] +
170
169
  doc.namespace_ancestors.map(&:name)
171
170
  else
172
- # Categories live in their own directory
171
+ # Category - in the root
173
172
  []
174
173
  end
175
174
  end
@@ -183,22 +182,31 @@ module Jazzy
183
182
  end.select { |x| x }.flatten(1)
184
183
  end
185
184
 
185
+ def self.use_spm?(options)
186
+ options.swift_build_tool == :spm ||
187
+ (!options.swift_build_tool_configured &&
188
+ Dir['*.xcodeproj'].empty?)
189
+ end
190
+
186
191
  # Builds SourceKitten arguments based on Jazzy options
187
192
  def self.arguments_from_options(options)
188
193
  arguments = ['doc']
189
- arguments += if options.objc_mode
190
- objc_arguments_from_options(options)
191
- elsif !options.module_name.empty?
192
- ['--module-name', options.module_name, '--']
193
- else
194
- ['--']
195
- end
196
- arguments + options.xcodebuild_arguments
194
+ if options.objc_mode
195
+ arguments += objc_arguments_from_options(options)
196
+ else
197
+ arguments += ['--spm'] if use_spm?(options)
198
+ if options.module_name_configured
199
+ arguments += ['--module-name', options.module_name]
200
+ end
201
+ arguments += ['--']
202
+ end
203
+
204
+ arguments + options.build_tool_arguments
197
205
  end
198
206
 
199
207
  def self.objc_arguments_from_options(options)
200
208
  arguments = []
201
- if options.xcodebuild_arguments.empty?
209
+ if options.build_tool_arguments.empty?
202
210
  arguments += ['--objc', options.umbrella_header.to_s, '--', '-x',
203
211
  'objective-c', '-isysroot',
204
212
  `xcrun --show-sdk-path --sdk #{options.sdk}`.chomp,