jazzy 0.11.2 → 0.12.0
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 +4 -4
- data/.circleci/config.yml +3 -20
- data/CHANGELOG.md +26 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +15 -15
- data/README.md +28 -1
- data/bin/sourcekitten +0 -0
- data/lib/jazzy/config.rb +15 -6
- data/lib/jazzy/doc.rb +0 -4
- data/lib/jazzy/doc_builder.rb +4 -2
- data/lib/jazzy/gem_version.rb +1 -1
- data/lib/jazzy/highlighter.rb +10 -8
- data/lib/jazzy/source_declaration.rb +30 -6
- data/lib/jazzy/source_declaration/type.rb +4 -0
- data/lib/jazzy/sourcekitten.rb +60 -31
- data/spec/integration_spec.rb +23 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b0a6f32e8d7182725eafedb4ec488e382de192af903fb42ee9d7cd3c7396c3
|
4
|
+
data.tar.gz: 1b2dbf01dae14692d0a04a1912f71d98cc44d2397fe81280df0d072089b3ad4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04ef74edf753cb424bfe2b9f8bdc7860b3d9072e91a5be60a7db38981d705cc595286a33d805482129746b4ee6626ef5852cbbf13e428d0e0f7fcd99310adf14
|
7
|
+
data.tar.gz: 8b038aaabd0516983b87d80841e1dc490b35e6493cae241193d07b09c946f8f47dd0b7b84bd20300fd382d522ad6ca3104fb2478c9eb6ab764afb5a6840014b4
|
data/.circleci/config.yml
CHANGED
@@ -12,25 +12,16 @@ aliases:
|
|
12
12
|
BUNDLE_RETRY: 3
|
13
13
|
BUNDLE_PATH: vendor/bundle
|
14
14
|
|
15
|
-
- &shell
|
16
|
-
/bin/bash --login -eo pipefail
|
17
|
-
|
18
|
-
- &set-ruby-version
|
19
|
-
echo "ruby-2.4" > ~/.ruby-version
|
20
|
-
|
21
15
|
version: 2
|
22
16
|
jobs:
|
23
17
|
|
24
18
|
swift:
|
25
19
|
macos:
|
26
|
-
xcode: "
|
20
|
+
xcode: "11.2.0"
|
27
21
|
environment: *bundler-environment
|
28
|
-
# Used to invoke chruby
|
29
|
-
shell: *shell
|
30
22
|
steps:
|
31
23
|
- checkout
|
32
24
|
- restore_cache: *restore-mac-bundler-cache
|
33
|
-
- run: *set-ruby-version
|
34
25
|
- run: bundle install
|
35
26
|
- run: git submodule update --init --recursive
|
36
27
|
- run: bundle exec rake swift_spec
|
@@ -38,14 +29,11 @@ jobs:
|
|
38
29
|
|
39
30
|
objc:
|
40
31
|
macos:
|
41
|
-
xcode: "
|
32
|
+
xcode: "11.2.0"
|
42
33
|
environment: *bundler-environment
|
43
|
-
# Used to invoke chruby
|
44
|
-
shell: *shell
|
45
34
|
steps:
|
46
35
|
- checkout
|
47
36
|
- restore_cache: *restore-mac-bundler-cache
|
48
|
-
- run: *set-ruby-version
|
49
37
|
- run: bundle install
|
50
38
|
- run: git submodule update --init --recursive
|
51
39
|
- run: bundle exec rake objc_spec
|
@@ -53,16 +41,13 @@ jobs:
|
|
53
41
|
|
54
42
|
cocoapods:
|
55
43
|
macos:
|
56
|
-
xcode: "
|
44
|
+
xcode: "11.2.0"
|
57
45
|
environment: *bundler-environment
|
58
|
-
# Used to invoke chruby
|
59
|
-
shell: *shell
|
60
46
|
steps:
|
61
47
|
- checkout
|
62
48
|
- restore_cache:
|
63
49
|
key: cocoapods
|
64
50
|
- restore_cache: *restore-mac-bundler-cache
|
65
|
-
- run: *set-ruby-version
|
66
51
|
- run: bundle install
|
67
52
|
- run: git submodule update --init --recursive
|
68
53
|
- run: bundle exec rake cocoapods_spec
|
@@ -76,8 +61,6 @@ jobs:
|
|
76
61
|
docker:
|
77
62
|
- image: circleci/ruby:2.4-node
|
78
63
|
environment: *bundler-environment
|
79
|
-
# Used to invoke chruby
|
80
|
-
shell: *shell
|
81
64
|
steps:
|
82
65
|
- checkout
|
83
66
|
- restore_cache:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
## 0.12.0
|
2
|
+
|
3
|
+
##### Breaking
|
4
|
+
|
5
|
+
* None.
|
6
|
+
|
7
|
+
##### Enhancements
|
8
|
+
|
9
|
+
* Support for mixed Swift-ObjC modules: generate two sets of SourceKitten
|
10
|
+
json and pass them on using `--sourcekitten-sourcefile`.
|
11
|
+
[Joe Susnick](https://github.com/joesus)
|
12
|
+
[John Fairhurst](https://github.com/johnfairh)
|
13
|
+
[#447](https://github.com/realm/jazzy/issues/447)
|
14
|
+
|
15
|
+
##### Bug Fixes
|
16
|
+
|
17
|
+
* Stop displaying type attributes on extension declarations.
|
18
|
+
[John Fairhurst](https://github.com/johnfairh)
|
19
|
+
|
20
|
+
* Show ObjC and Swift classes (etc.) in the same category.
|
21
|
+
[John Fairhurst](https://github.com/johnfairh)
|
22
|
+
|
23
|
+
* Merge Swift extensions into ObjC classes.
|
24
|
+
[John Fairhurst](https://github.com/johnfairh)
|
25
|
+
[Joe Susnick](https://github.com/joesus)
|
26
|
+
|
1
27
|
## 0.11.2
|
2
28
|
|
3
29
|
##### Breaking
|
data/CONTRIBUTING.md
CHANGED
@@ -49,7 +49,7 @@ git push
|
|
49
49
|
You'll need push access to the integration specs repo to do this. You can
|
50
50
|
request access from one of the maintainers when filing your PR.
|
51
51
|
|
52
|
-
You must have Xcode
|
52
|
+
You must have Xcode 11.2 installed to build the integration specs.
|
53
53
|
|
54
54
|
## Making changes to SourceKitten
|
55
55
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jazzy (0.
|
4
|
+
jazzy (0.12.0)
|
5
5
|
cocoapods (~> 1.5)
|
6
6
|
mustache (~> 1.1)
|
7
7
|
open4
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
tzinfo (~> 1.1)
|
23
23
|
addressable (2.7.0)
|
24
24
|
public_suffix (>= 2.0.2, < 5.0)
|
25
|
-
algoliasearch (1.27.
|
25
|
+
algoliasearch (1.27.1)
|
26
26
|
httpclient (~> 2.8, >= 2.8.3)
|
27
27
|
json (>= 1.5.1)
|
28
28
|
ast (2.4.0)
|
@@ -36,10 +36,10 @@ GEM
|
|
36
36
|
clintegracon (0.7.0)
|
37
37
|
colored (~> 1.2)
|
38
38
|
diffy
|
39
|
-
cocoapods (1.8.
|
39
|
+
cocoapods (1.8.4)
|
40
40
|
activesupport (>= 4.0.2, < 5)
|
41
41
|
claide (>= 1.0.2, < 2.0)
|
42
|
-
cocoapods-core (= 1.8.
|
42
|
+
cocoapods-core (= 1.8.4)
|
43
43
|
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
44
44
|
cocoapods-downloader (>= 1.2.2, < 2.0)
|
45
45
|
cocoapods-plugins (>= 1.0.0, < 2.0)
|
@@ -55,10 +55,10 @@ GEM
|
|
55
55
|
nap (~> 1.0)
|
56
56
|
ruby-macho (~> 1.4)
|
57
57
|
xcodeproj (>= 1.11.1, < 2.0)
|
58
|
-
cocoapods-core (1.8.
|
58
|
+
cocoapods-core (1.8.4)
|
59
59
|
activesupport (>= 4.0.2, < 6)
|
60
60
|
algoliasearch (~> 1.0)
|
61
|
-
concurrent-ruby (~> 1.
|
61
|
+
concurrent-ruby (~> 1.1)
|
62
62
|
fuzzy_match (~> 2.0.4)
|
63
63
|
nap (~> 1.0)
|
64
64
|
cocoapods-deintegrate (1.0.4)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
nap
|
68
68
|
cocoapods-search (1.0.0)
|
69
69
|
cocoapods-stats (1.1.0)
|
70
|
-
cocoapods-trunk (1.4.
|
70
|
+
cocoapods-trunk (1.4.1)
|
71
71
|
nap (>= 0.8, < 2.0)
|
72
72
|
netrc (~> 0.11)
|
73
73
|
cocoapods-try (1.1.0)
|
@@ -78,7 +78,7 @@ GEM
|
|
78
78
|
colored2 (~> 3.1)
|
79
79
|
crack (0.4.3)
|
80
80
|
safe_yaml (~> 1.0.0)
|
81
|
-
danger (6.0
|
81
|
+
danger (6.1.0)
|
82
82
|
claide (~> 1.0)
|
83
83
|
claide-plugins (>= 0.9.2)
|
84
84
|
colored2 (~> 3.1)
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
terminal-table (~> 1)
|
94
94
|
diffy (3.3.0)
|
95
95
|
escape (0.0.4)
|
96
|
-
faraday (0.
|
96
|
+
faraday (0.17.0)
|
97
97
|
multipart-post (>= 1.2, < 3)
|
98
98
|
faraday-http-cache (2.0.0)
|
99
99
|
faraday (~> 0.8)
|
@@ -112,7 +112,7 @@ GEM
|
|
112
112
|
kramdown (~> 2.0)
|
113
113
|
liferaft (0.0.6)
|
114
114
|
metaclass (0.0.4)
|
115
|
-
minitest (5.
|
115
|
+
minitest (5.13.0)
|
116
116
|
mocha (1.9.0)
|
117
117
|
metaclass (~> 0.0.1)
|
118
118
|
mocha-on-bacon (0.2.3)
|
@@ -127,8 +127,8 @@ GEM
|
|
127
127
|
octokit (4.14.0)
|
128
128
|
sawyer (~> 0.8.0, >= 0.5.3)
|
129
129
|
open4 (1.3.4)
|
130
|
-
parallel (1.
|
131
|
-
parser (2.6.
|
130
|
+
parallel (1.18.0)
|
131
|
+
parser (2.6.5.0)
|
132
132
|
ast (~> 2.4.0)
|
133
133
|
powerpack (0.1.2)
|
134
134
|
prettybacon (0.0.2)
|
@@ -138,7 +138,7 @@ GEM
|
|
138
138
|
rake
|
139
139
|
rake (10.5.0)
|
140
140
|
redcarpet (3.5.0)
|
141
|
-
rouge (3.
|
141
|
+
rouge (3.12.0)
|
142
142
|
rubocop (0.49.0)
|
143
143
|
parallel (~> 1.10)
|
144
144
|
parser (>= 2.3.3.1, < 3.0)
|
@@ -161,13 +161,13 @@ GEM
|
|
161
161
|
tzinfo (1.2.5)
|
162
162
|
thread_safe (~> 0.1)
|
163
163
|
unicode-display_width (1.6.0)
|
164
|
-
webmock (3.7.
|
164
|
+
webmock (3.7.6)
|
165
165
|
addressable (>= 2.3.6)
|
166
166
|
crack (>= 0.3.2)
|
167
167
|
hashdiff (>= 0.4.0, < 2.0.0)
|
168
168
|
xcinvoke (0.3.0)
|
169
169
|
liferaft (~> 0.0.6)
|
170
|
-
xcodeproj (1.
|
170
|
+
xcodeproj (1.13.0)
|
171
171
|
CFPropertyList (>= 2.3.3, < 4.0)
|
172
172
|
atomos (~> 0.1.3)
|
173
173
|
claide (>= 1.0.2, < 2.0)
|
data/README.md
CHANGED
@@ -150,6 +150,33 @@ jazzy \
|
|
150
150
|
--module AFNetworking
|
151
151
|
```
|
152
152
|
|
153
|
+
### Mixed Objective-C / Swift
|
154
|
+
|
155
|
+
*This feature is new and has some rough edges.*
|
156
|
+
|
157
|
+
To generate documentation for a mixed Swift and Objective-C project you must first
|
158
|
+
generate two [SourceKitten][sourcekitten] files: one for Swift and one for Objective-C.
|
159
|
+
|
160
|
+
Then pass these files to Jazzy together using `--sourcekitten-sourcefile`.
|
161
|
+
|
162
|
+
#### Example
|
163
|
+
|
164
|
+
This is how docs are generated from an Xcode project for a module containing both
|
165
|
+
Swift and Objective-C files:
|
166
|
+
|
167
|
+
```shell
|
168
|
+
# Generate Swift SourceKitten output
|
169
|
+
sourcekitten doc -- -workspace MyProject.xcworkspace -scheme MyScheme > swiftDoc.json
|
170
|
+
|
171
|
+
# Generate Objective-C SourceKitten output
|
172
|
+
sourcekitten doc --objc $(pwd)/MyProject/MyProject.h \
|
173
|
+
-- -x objective-c -isysroot $(xcrun --show-sdk-path --sdk iphonesimulator) \
|
174
|
+
-I $(pwd) -fmodules > objcDoc.json
|
175
|
+
|
176
|
+
# Feed both outputs to Jazzy as a comma-separated list
|
177
|
+
jazzy --sourcekitten-sourcefile swiftDoc.json,objcDoc.json
|
178
|
+
```
|
179
|
+
|
153
180
|
### Themes
|
154
181
|
|
155
182
|
Three themes are provided with jazzy: `apple` (default), `fullwidth` and `jony`.
|
@@ -331,7 +358,7 @@ Instructions to build SourceKitten from source can be found at
|
|
331
358
|
- Leverage modern HTML templating ([Mustache][mustache])
|
332
359
|
- Leverage the power and accuracy of the [Clang AST][ast] and [SourceKit][sourcekit]
|
333
360
|
- Support for Dash docsets
|
334
|
-
- Support Swift and Objective-C
|
361
|
+
- Support Swift and Objective-C
|
335
362
|
|
336
363
|
## License
|
337
364
|
|
data/bin/sourcekitten
CHANGED
Binary file
|
data/lib/jazzy/config.rb
CHANGED
@@ -102,6 +102,14 @@ module Jazzy
|
|
102
102
|
Pathname(Dir[abs_path][0] || abs_path) # Use existing filesystem spelling
|
103
103
|
end
|
104
104
|
|
105
|
+
def hide_swift?
|
106
|
+
hide_declarations == 'swift'
|
107
|
+
end
|
108
|
+
|
109
|
+
def hide_objc?
|
110
|
+
hide_declarations == 'objc'
|
111
|
+
end
|
112
|
+
|
105
113
|
# ──────── Build ────────
|
106
114
|
|
107
115
|
# rubocop:disable Layout/AlignParameters
|
@@ -143,9 +151,9 @@ module Jazzy
|
|
143
151
|
command_line: '--hide-declarations [objc|swift] ',
|
144
152
|
description: 'Hide declarations in the specified language. Given that ' \
|
145
153
|
'generating Swift docs only generates Swift declarations, ' \
|
146
|
-
'this is
|
147
|
-
'
|
148
|
-
'
|
154
|
+
'this is useful for hiding a specific interface for ' \
|
155
|
+
'either Objective-C or mixed Objective-C and Swift ' \
|
156
|
+
'projects.',
|
149
157
|
default: ''
|
150
158
|
|
151
159
|
config_attr :config_file,
|
@@ -165,9 +173,10 @@ module Jazzy
|
|
165
173
|
description: 'Back-compatibility alias for build_tool_arguments.'
|
166
174
|
|
167
175
|
config_attr :sourcekitten_sourcefile,
|
168
|
-
command_line: ['-s', '--sourcekitten-sourcefile
|
169
|
-
|
170
|
-
|
176
|
+
command_line: ['-s', '--sourcekitten-sourcefile filepath1,…filepathN',
|
177
|
+
Array],
|
178
|
+
description: 'File(s) generated from sourcekitten output to parse',
|
179
|
+
parse: ->(paths) { paths.map { |path| expand_path(path) } }
|
171
180
|
|
172
181
|
config_attr :source_directory,
|
173
182
|
command_line: '--source-directory DIRPATH',
|
data/lib/jazzy/doc.rb
CHANGED
data/lib/jazzy/doc_builder.rb
CHANGED
@@ -53,8 +53,9 @@ module Jazzy
|
|
53
53
|
# @param [Config] options
|
54
54
|
# @return [SourceModule] the documented source module
|
55
55
|
def self.build(options)
|
56
|
-
if options.
|
57
|
-
stdout = options.sourcekitten_sourcefile.read
|
56
|
+
if options.sourcekitten_sourcefile_configured
|
57
|
+
stdout = '[' + options.sourcekitten_sourcefile.map(&:read)
|
58
|
+
.join(',') + ']'
|
58
59
|
elsif options.podspec_configured
|
59
60
|
pod_documenter = PodspecDocumenter.new(options.podspec)
|
60
61
|
stdout = pod_documenter.sourcekitten_output(options)
|
@@ -329,6 +330,7 @@ module Jazzy
|
|
329
330
|
name: item.name,
|
330
331
|
abstract: abstract,
|
331
332
|
declaration: item.display_declaration,
|
333
|
+
language: item.display_language,
|
332
334
|
other_language_declaration: item.display_other_language_declaration,
|
333
335
|
usr: item.usr,
|
334
336
|
dash_type: item.type.dash_type,
|
data/lib/jazzy/gem_version.rb
CHANGED
data/lib/jazzy/highlighter.rb
CHANGED
@@ -3,6 +3,9 @@ require 'rouge'
|
|
3
3
|
module Jazzy
|
4
4
|
# This module helps highlight code
|
5
5
|
module Highlighter
|
6
|
+
SWIFT = 'swift'.freeze
|
7
|
+
OBJC = 'objective_c'.freeze
|
8
|
+
|
6
9
|
class Formatter < Rouge::Formatters::HTML
|
7
10
|
def initialize(language)
|
8
11
|
@language = language
|
@@ -16,16 +19,15 @@ module Jazzy
|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
22
|
+
def self.highlight_swift(source)
|
23
|
+
highlight(source, SWIFT)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.highlight_objc(source)
|
27
|
+
highlight(source, OBJC)
|
26
28
|
end
|
27
29
|
|
28
|
-
def self.highlight(source, language
|
30
|
+
def self.highlight(source, language)
|
29
31
|
source && Rouge.highlight(source, language, Formatter.new(language))
|
30
32
|
end
|
31
33
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'jazzy/source_declaration/access_control_level'
|
2
2
|
require 'jazzy/source_declaration/type'
|
3
3
|
|
4
|
+
# rubocop:disable Metrics/ClassLength
|
4
5
|
module Jazzy
|
5
6
|
class SourceDeclaration
|
6
7
|
# kind of declaration (e.g. class, variable, function)
|
@@ -13,6 +14,14 @@ module Jazzy
|
|
13
14
|
children.any?
|
14
15
|
end
|
15
16
|
|
17
|
+
def swift?
|
18
|
+
type.swift_type?
|
19
|
+
end
|
20
|
+
|
21
|
+
def highlight_language
|
22
|
+
swift? ? Highlighter::SWIFT : Highlighter::OBJC
|
23
|
+
end
|
24
|
+
|
16
25
|
# When referencing this item from its parent category,
|
17
26
|
# include the content or just link to it directly?
|
18
27
|
def omit_content_from_parent?
|
@@ -67,17 +76,32 @@ module Jazzy
|
|
67
76
|
name.split(/[\(\)]/) if type.objc_category?
|
68
77
|
end
|
69
78
|
|
79
|
+
def swift_objc_extension?
|
80
|
+
type.swift_extension? && usr && usr.start_with?('c:objc')
|
81
|
+
end
|
82
|
+
|
83
|
+
def swift_extension_objc_name
|
84
|
+
return unless type.swift_extension? && usr
|
85
|
+
|
86
|
+
usr.split('(cs)').last
|
87
|
+
end
|
88
|
+
|
89
|
+
# The language in the templates for display
|
90
|
+
def display_language
|
91
|
+
return 'Swift' if swift?
|
92
|
+
|
93
|
+
Config.instance.hide_objc? ? 'Swift' : 'Objective-C'
|
94
|
+
end
|
95
|
+
|
70
96
|
def display_declaration
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
declaration
|
75
|
-
end
|
97
|
+
return declaration if swift?
|
98
|
+
|
99
|
+
Config.instance.hide_objc? ? other_language_declaration : declaration
|
76
100
|
end
|
77
101
|
|
78
102
|
def display_other_language_declaration
|
79
103
|
other_language_declaration unless
|
80
|
-
|
104
|
+
Config.instance.hide_objc? || Config.instance.hide_swift?
|
81
105
|
end
|
82
106
|
|
83
107
|
attr_accessor :file
|
data/lib/jazzy/sourcekitten.rb
CHANGED
@@ -65,7 +65,7 @@ module Jazzy
|
|
65
65
|
type_categories, uncategorized = group_type_categories(
|
66
66
|
docs, custom_categories.any? ? 'Other ' : ''
|
67
67
|
)
|
68
|
-
custom_categories + type_categories + uncategorized
|
68
|
+
custom_categories + merge_categories(type_categories) + uncategorized
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.group_custom_categories(docs)
|
@@ -98,6 +98,19 @@ module Jazzy
|
|
98
98
|
[group.compact, docs]
|
99
99
|
end
|
100
100
|
|
101
|
+
# Join categories with the same name (eg. ObjC and Swift classes)
|
102
|
+
def self.merge_categories(categories)
|
103
|
+
merged = []
|
104
|
+
categories.each do |new_category|
|
105
|
+
if existing = merged.find { |c| c.name == new_category.name }
|
106
|
+
existing.children += new_category.children
|
107
|
+
else
|
108
|
+
merged.append(new_category)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
merged
|
112
|
+
end
|
113
|
+
|
101
114
|
def self.make_group(group, name, abstract, url_name = nil)
|
102
115
|
group.reject! { |doc| doc.name.empty? }
|
103
116
|
unless group.empty?
|
@@ -262,8 +275,13 @@ module Jazzy
|
|
262
275
|
def self.should_document?(doc)
|
263
276
|
return false if doc['key.doc.comment'].to_s.include?(':nodoc:')
|
264
277
|
|
278
|
+
type = SourceDeclaration::Type.new(doc['key.kind'])
|
279
|
+
|
265
280
|
# Always document Objective-C declarations.
|
266
|
-
return true
|
281
|
+
return true unless type.swift_type?
|
282
|
+
|
283
|
+
# Don't document Swift types if we are hiding Swift
|
284
|
+
return false if Config.instance.hide_swift?
|
267
285
|
|
268
286
|
# Don't document @available declarations with no USR, since it means
|
269
287
|
# they're unavailable.
|
@@ -272,7 +290,6 @@ module Jazzy
|
|
272
290
|
end
|
273
291
|
|
274
292
|
# Document extensions & enum elements, since we can't tell their ACL.
|
275
|
-
type = SourceDeclaration::Type.new(doc['key.kind'])
|
276
293
|
return true if type.swift_enum_element?
|
277
294
|
if type.swift_extension?
|
278
295
|
return Array(doc['key.substructure']).any? do |subdoc|
|
@@ -296,14 +313,14 @@ module Jazzy
|
|
296
313
|
make_default_doc_info(declaration)
|
297
314
|
|
298
315
|
filepath = doc['key.filepath']
|
299
|
-
|
300
|
-
if
|
316
|
+
|
317
|
+
if !declaration.swift? || should_mark_undocumented(filepath)
|
301
318
|
@stats.add_undocumented(declaration)
|
302
319
|
return nil if @skip_undocumented
|
303
320
|
declaration.abstract = undocumented_abstract
|
304
321
|
else
|
305
322
|
declaration.abstract = Markdown.render(doc['key.doc.comment'] || '',
|
306
|
-
|
323
|
+
declaration.highlight_language)
|
307
324
|
end
|
308
325
|
|
309
326
|
declaration
|
@@ -322,16 +339,7 @@ module Jazzy
|
|
322
339
|
def self.make_doc_info(doc, declaration)
|
323
340
|
return unless should_document?(doc)
|
324
341
|
|
325
|
-
|
326
|
-
declaration.declaration =
|
327
|
-
Highlighter.highlight(doc['key.parsed_declaration'])
|
328
|
-
declaration.other_language_declaration =
|
329
|
-
Highlighter.highlight(doc['key.swift_declaration'], 'swift')
|
330
|
-
else
|
331
|
-
declaration.declaration =
|
332
|
-
Highlighter.highlight(make_swift_declaration(doc, declaration))
|
333
|
-
end
|
334
|
-
|
342
|
+
highlight_declaration(doc, declaration)
|
335
343
|
make_deprecation_info(doc, declaration)
|
336
344
|
|
337
345
|
unless doc['key.doc.full_as_xml']
|
@@ -339,7 +347,7 @@ module Jazzy
|
|
339
347
|
end
|
340
348
|
|
341
349
|
declaration.abstract = Markdown.render(doc['key.doc.comment'] || '',
|
342
|
-
|
350
|
+
declaration.highlight_language)
|
343
351
|
declaration.discussion = ''
|
344
352
|
declaration.return = Markdown.rendered_returns
|
345
353
|
declaration.parameters = parameters(doc, Markdown.rendered_parameters)
|
@@ -347,6 +355,18 @@ module Jazzy
|
|
347
355
|
@stats.add_documented
|
348
356
|
end
|
349
357
|
|
358
|
+
def self.highlight_declaration(doc, declaration)
|
359
|
+
if declaration.swift?
|
360
|
+
declaration.declaration =
|
361
|
+
Highlighter.highlight_swift(make_swift_declaration(doc, declaration))
|
362
|
+
else
|
363
|
+
declaration.declaration =
|
364
|
+
Highlighter.highlight_objc(doc['key.parsed_declaration'])
|
365
|
+
declaration.other_language_declaration =
|
366
|
+
Highlighter.highlight_swift(doc['key.swift_declaration'])
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
350
370
|
def self.make_deprecation_info(doc, declaration)
|
351
371
|
if declaration.deprecated
|
352
372
|
declaration.deprecation_message =
|
@@ -401,8 +421,7 @@ module Jazzy
|
|
401
421
|
parsed &&
|
402
422
|
(annotated.include?(' = default') || # SR-2608
|
403
423
|
parsed.match('@autoclosure|@escaping') || # SR-6321
|
404
|
-
parsed.include?("\n")
|
405
|
-
parsed.include?('extension '))
|
424
|
+
parsed.include?("\n"))
|
406
425
|
end
|
407
426
|
|
408
427
|
# Replace the fully qualified name of a type with its base name
|
@@ -424,6 +443,9 @@ module Jazzy
|
|
424
443
|
# From source code
|
425
444
|
parsed_decl = doc['key.parsed_declaration']
|
426
445
|
|
446
|
+
# Don't present type attributes on extensions
|
447
|
+
return parsed_decl if declaration.type.extension?
|
448
|
+
|
427
449
|
decl =
|
428
450
|
if prefer_parsed_decl?(parsed_decl, annotated_decl_body)
|
429
451
|
# Strip any attrs captured by parsed version
|
@@ -473,8 +495,7 @@ module Jazzy
|
|
473
495
|
declaration.type = SourceDeclaration::Type.new(doc['key.kind'])
|
474
496
|
declaration.typename = doc['key.typename']
|
475
497
|
declaration.objc_name = doc['key.name']
|
476
|
-
documented_name = if Config.instance.
|
477
|
-
doc['key.swift_name']
|
498
|
+
documented_name = if Config.instance.hide_objc? && doc['key.swift_name']
|
478
499
|
doc['key.swift_name']
|
479
500
|
else
|
480
501
|
declaration.objc_name
|
@@ -528,6 +549,10 @@ module Jazzy
|
|
528
549
|
decls.map do |decl|
|
529
550
|
next decl unless decl.type.extension? && decl.name.include?('.')
|
530
551
|
|
552
|
+
# Don't expand the Swift namespace if we're in ObjC mode.
|
553
|
+
# ex: NS_SWIFT_NAME(Foo.Bar) should not create top-level Foo
|
554
|
+
next decl if decl.swift_objc_extension? && !Config.instance.hide_objc?
|
555
|
+
|
531
556
|
name_parts = decl.name.split('.')
|
532
557
|
decl.name = name_parts.pop
|
533
558
|
expand_extension(decl, name_parts, decls)
|
@@ -578,11 +603,18 @@ module Jazzy
|
|
578
603
|
|
579
604
|
# Two declarations get merged if they have the same deduplication key.
|
580
605
|
def self.deduplication_key(decl, root_decls)
|
581
|
-
|
606
|
+
# Swift extension of objc class
|
607
|
+
if decl.swift_objc_extension?
|
608
|
+
[decl.swift_extension_objc_name, :objc_class_and_categories]
|
609
|
+
# Swift type or Swift extension of Swift type
|
610
|
+
elsif decl.type.swift_extensible? || decl.type.swift_extension?
|
582
611
|
[decl.usr, decl.name]
|
612
|
+
# Objc categories and classes
|
583
613
|
elsif mergeable_objc?(decl, root_decls)
|
584
|
-
|
614
|
+
# Using the ObjC name to match swift_objc_extension.
|
615
|
+
name, _ = decl.objc_category_name || decl.objc_name
|
585
616
|
[name, :objc_class_and_categories]
|
617
|
+
# Non-mergable declarations (funcs, typedefs etc...)
|
586
618
|
else
|
587
619
|
[decl.usr, decl.name, decl.type.kind]
|
588
620
|
end
|
@@ -828,17 +860,14 @@ module Jazzy
|
|
828
860
|
@min_acl = min_acl
|
829
861
|
@skip_undocumented = skip_undocumented
|
830
862
|
@stats = Stats.new
|
831
|
-
sourcekitten_json = filter_files(JSON.parse(sourcekitten_output))
|
863
|
+
sourcekitten_json = filter_files(JSON.parse(sourcekitten_output).flatten)
|
832
864
|
docs = make_source_declarations(sourcekitten_json).concat inject_docs
|
833
865
|
docs = expand_extensions(docs)
|
834
866
|
docs = deduplicate_declarations(docs)
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
# than min_acl
|
840
|
-
docs = docs.reject { |doc| doc.type.swift_enum_element? }
|
841
|
-
end
|
867
|
+
docs = reject_objc_types(docs)
|
868
|
+
# Remove top-level enum cases because it means they have an ACL lower
|
869
|
+
# than min_acl
|
870
|
+
docs = docs.reject { |doc| doc.type.swift_enum_element? }
|
842
871
|
ungrouped_docs = docs
|
843
872
|
docs = group_docs(docs)
|
844
873
|
make_doc_urls(docs)
|
data/spec/integration_spec.rb
CHANGED
@@ -52,13 +52,9 @@ require 'cocoapods'
|
|
52
52
|
|
53
53
|
def configure_cocoapods
|
54
54
|
Pod::Config.instance.with_changes(silent: true) do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
Pod::Command::Repo::Update.invoke(%w[master])
|
59
|
-
else
|
60
|
-
Pod::Command::Setup.invoke
|
61
|
-
end
|
55
|
+
Pod::Command::Setup.invoke
|
56
|
+
Pod::Command::Repo::AddCDN.invoke(%w[trunk https://cdn.cocoapods.org/])
|
57
|
+
Pod::Command::Repo::Update.invoke(%w[trunk])
|
62
58
|
end
|
63
59
|
end
|
64
60
|
|
@@ -77,8 +73,11 @@ CLIntegracon.configure do |c|
|
|
77
73
|
File.write(
|
78
74
|
path,
|
79
75
|
File.read(path).gsub(
|
80
|
-
|
76
|
+
c.temp_path.to_s,
|
81
77
|
'<TMP>',
|
78
|
+
).gsub(
|
79
|
+
c.spec_path.to_s,
|
80
|
+
'<SPEC>',
|
82
81
|
),
|
83
82
|
)
|
84
83
|
end
|
@@ -164,9 +163,23 @@ describe_cli 'jazzy' do
|
|
164
163
|
"--head #{realm_head.shellescape}"
|
165
164
|
end
|
166
165
|
|
167
|
-
describe 'Creates docs for ObjC project with a variety of contents' do
|
166
|
+
describe 'Creates docs for ObjC-Swift project with a variety of contents' do
|
167
|
+
base = ROOT + 'spec/integration_specs/misc_jazzy_objc_features/before'
|
168
|
+
Dir.chdir(base) do
|
169
|
+
sourcekitten = ROOT + 'bin/sourcekitten'
|
170
|
+
sdk = `xcrun --show-sdk-path --sdk iphonesimulator`.chomp
|
171
|
+
objc_args = "#{base}/MiscJazzyObjCFeatures/MiscJazzyObjCFeatures.h " \
|
172
|
+
'-- -x objective-c ' \
|
173
|
+
"-isysroot #{sdk} " \
|
174
|
+
"-I #{base} " \
|
175
|
+
'-fmodules'
|
176
|
+
`#{sourcekitten} doc --objc #{objc_args} > objc.json`
|
177
|
+
`#{sourcekitten} doc > swift.json`
|
178
|
+
end
|
179
|
+
|
168
180
|
behaves_like cli_spec 'misc_jazzy_objc_features',
|
169
|
-
'--theme fullwidth'
|
181
|
+
'--theme fullwidth '\
|
182
|
+
'-s objc.json,swift.json'
|
170
183
|
end
|
171
184
|
end if !spec_subset || spec_subset == 'objc'
|
172
185
|
|
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.
|
4
|
+
version: 0.12.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: 2019-
|
13
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cocoapods
|