danger-jazzy 0.1.1 → 1.0.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/.gitignore +1 -0
- data/.rubocop.yml +20 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -1
- data/README.md +40 -8
- data/danger-jazzy.gemspec +5 -2
- data/lib/jazzy/gem_version.rb +1 -1
- data/lib/jazzy/plugin.rb +82 -20
- data/spec/jazzy_spec.rb +33 -4
- data/spec/spec_helper.rb +3 -0
- metadata +20 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8bb53cde4ba129560e1f27e05941d12307f34ac
|
|
4
|
+
data.tar.gz: d73cfb80d5771789f127f82a92a461c2e55f487a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5471744bf514104875f84a8f6a60755b8cb6e3ee126331930031111bb4e75208d15becd15c3fcb5be878a9683e7b5cb29278090c79bf3d457bd95223537ede85
|
|
7
|
+
data.tar.gz: cc5e4e7196b8ffe0bfc3bc1502ea5aee9c2d23677e965ac4a4bbb4fa12177b9824058911bfb9e80cf03972529d722778dbba11f1e35c64f9e9ba3cae160e9a03
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
|
2
|
+
|
|
3
|
+
AllCops:
|
|
4
|
+
TargetRubyVersion: 2.0
|
|
5
|
+
Exclude:
|
|
6
|
+
- 'spec/fixtures/**/*'
|
|
7
|
+
- 'lib/danger/plugin_support/plugin_parser.rb'
|
|
8
|
+
|
|
9
|
+
Metrics/LineLength:
|
|
10
|
+
Exclude:
|
|
11
|
+
- 'spec/*'
|
|
12
|
+
- 'danger-jazzy.gemspec'
|
|
13
|
+
|
|
14
|
+
Style/IfUnlessModifier:
|
|
15
|
+
Exclude:
|
|
16
|
+
- 'Gemfile'
|
|
17
|
+
|
|
18
|
+
Style/SpecialGlobalVars:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'danger-jazzy.gemspec'
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,26 +1,58 @@
|
|
|
1
1
|
### jazzy
|
|
2
2
|
This is a danger plugin to check for undocumented symbols via Jazzy.
|
|
3
3
|
|
|
4
|
-
<blockquote>
|
|
4
|
+
<blockquote>Fail on undocumented symbols in modified files.
|
|
5
5
|
<pre>
|
|
6
|
-
jazzy.
|
|
6
|
+
jazzy.check</pre>
|
|
7
7
|
</blockquote>
|
|
8
8
|
|
|
9
|
-
<blockquote>
|
|
9
|
+
<blockquote>Fail on undocumented symbols in all files.
|
|
10
10
|
<pre>
|
|
11
|
-
jazzy.
|
|
12
|
-
|
|
11
|
+
jazzy.check fail: :all</pre>
|
|
12
|
+
</blockquote>
|
|
13
|
+
|
|
14
|
+
<blockquote>Warn about undocumented symbols in modified files.
|
|
15
|
+
<pre>
|
|
16
|
+
jazzy.check warn: :modified</pre>
|
|
17
|
+
</blockquote>
|
|
18
|
+
|
|
19
|
+
<blockquote>Write a custom message for undocumented symbols in modified files.
|
|
20
|
+
<pre>
|
|
21
|
+
jazzy.undocumented.each do |item|
|
|
22
|
+
message "You forgot to document this", file:item.file, line:item.line
|
|
23
|
+
end</pre>
|
|
24
|
+
</blockquote>
|
|
25
|
+
|
|
26
|
+
<blockquote>Write a custom message for undocumented symbols in all files.
|
|
27
|
+
<pre>
|
|
28
|
+
jazzy.undocumented(:all).each do |item|
|
|
29
|
+
message "You forgot to document this", file:item.file, line:item.line
|
|
13
30
|
end</pre>
|
|
14
31
|
</blockquote>
|
|
15
32
|
|
|
16
33
|
|
|
17
34
|
#### Attributes
|
|
18
35
|
|
|
19
|
-
`
|
|
36
|
+
`path` - Path to the docs folder, defaults to 'docs/'.
|
|
20
37
|
|
|
21
38
|
|
|
22
39
|
#### Methods
|
|
23
40
|
|
|
24
|
-
`
|
|
41
|
+
`check` - Checks files for modified symbols.
|
|
42
|
+
|
|
43
|
+
Takes a hash with the following keys:
|
|
44
|
+
|
|
45
|
+
* `fail`
|
|
46
|
+
* `warn`
|
|
47
|
+
|
|
48
|
+
Available scopes:
|
|
49
|
+
|
|
50
|
+
* `modified`
|
|
51
|
+
* `all`
|
|
52
|
+
|
|
53
|
+
`undocumented` - Returns a list of undocumented symbols in the current diff.
|
|
54
|
+
|
|
55
|
+
Available scopes:
|
|
25
56
|
|
|
26
|
-
`
|
|
57
|
+
* `modified`
|
|
58
|
+
* `all`
|
data/danger-jazzy.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = Jazzy::VERSION
|
|
9
9
|
spec.authors = ['Frederik Wallner']
|
|
10
10
|
spec.email = ['frederik.wallner@gmail.com']
|
|
11
|
-
spec.description =
|
|
12
|
-
spec.summary =
|
|
11
|
+
spec.description = 'A danger plugin for validating documentation generated with jazzy'
|
|
12
|
+
spec.summary = 'A danger plugin for validating documentation generated with jazzy'
|
|
13
13
|
spec.homepage = 'https://github.com/fwal/danger-jazzy'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
+
spec.required_ruby_version = '>= 2.0.0'
|
|
22
|
+
|
|
21
23
|
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
|
22
24
|
spec.add_runtime_dependency 'json', '~> 1.8'
|
|
23
25
|
|
|
@@ -31,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
31
33
|
# Linting code and docs
|
|
32
34
|
spec.add_development_dependency 'rubocop', '~> 0.41'
|
|
33
35
|
spec.add_development_dependency 'yard', '~> 0.8'
|
|
36
|
+
spec.add_development_dependency 'coveralls', '~> 0.8.15'
|
|
34
37
|
|
|
35
38
|
# Makes testing easy via `bundle exec guard`
|
|
36
39
|
spec.add_development_dependency 'guard', '~> 2.14'
|
data/lib/jazzy/gem_version.rb
CHANGED
data/lib/jazzy/plugin.rb
CHANGED
|
@@ -1,46 +1,82 @@
|
|
|
1
1
|
module Danger
|
|
2
|
+
# rubocop:disable Metrics/LineLength
|
|
2
3
|
# This is a danger plugin to check for undocumented symbols via Jazzy.
|
|
3
4
|
#
|
|
4
|
-
# @example
|
|
5
|
+
# @example Fail on undocumented symbols in modified files.
|
|
5
6
|
#
|
|
6
|
-
# jazzy.
|
|
7
|
+
# jazzy.check
|
|
7
8
|
#
|
|
8
|
-
# @example
|
|
9
|
+
# @example Fail on undocumented symbols in all files.
|
|
9
10
|
#
|
|
10
|
-
# jazzy.
|
|
11
|
-
#
|
|
11
|
+
# jazzy.check fail: :all
|
|
12
|
+
#
|
|
13
|
+
# @example Warn about undocumented symbols in modified files.
|
|
14
|
+
#
|
|
15
|
+
# jazzy.check warn: :modified
|
|
16
|
+
#
|
|
17
|
+
# @example Write a custom message for undocumented symbols in modified files.
|
|
18
|
+
#
|
|
19
|
+
# jazzy.undocumented.each do |item|
|
|
20
|
+
# message "You forgot to document this", file:item.file, line:item.line
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# @example Write a custom message for undocumented symbols in all files.
|
|
24
|
+
#
|
|
25
|
+
# jazzy.undocumented(:all).each do |item|
|
|
26
|
+
# message "You forgot to document this", file:item.file, line:item.line
|
|
12
27
|
# end
|
|
13
28
|
#
|
|
14
29
|
# @see fwal/danger-jazzy
|
|
15
30
|
# @tags jazzy, docs, documentation
|
|
16
31
|
#
|
|
32
|
+
# rubocop:enable Metrics/LineLength
|
|
17
33
|
class DangerJazzy < Plugin
|
|
18
34
|
DEFAULT_MESSAGE = 'Undocumented symbol.'.freeze
|
|
19
35
|
|
|
20
36
|
# Path to the docs folder, defaults to 'docs/'.
|
|
21
37
|
# @return [String]
|
|
22
|
-
attr_accessor :
|
|
38
|
+
attr_accessor :path
|
|
23
39
|
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
# Checks files for modified symbols.
|
|
41
|
+
#
|
|
42
|
+
# Takes a hash with the following keys:
|
|
43
|
+
#
|
|
44
|
+
# * `fail`
|
|
45
|
+
# * `warn`
|
|
46
|
+
#
|
|
47
|
+
# Available scopes:
|
|
48
|
+
#
|
|
49
|
+
# * `modified`
|
|
50
|
+
# * `all`
|
|
51
|
+
#
|
|
52
|
+
# @param [Hash] config
|
|
53
|
+
# @return [void]
|
|
54
|
+
def check(config = {})
|
|
55
|
+
@config = config
|
|
56
|
+
fail_check
|
|
57
|
+
warn_check
|
|
30
58
|
end
|
|
31
59
|
|
|
32
60
|
# Returns a list of undocumented symbols in the current diff.
|
|
61
|
+
#
|
|
62
|
+
# Available scopes:
|
|
63
|
+
#
|
|
64
|
+
# * `modified`
|
|
65
|
+
# * `all`
|
|
66
|
+
#
|
|
67
|
+
# @param [Key] scope
|
|
33
68
|
# @return [Array of symbol]
|
|
34
|
-
def undocumented
|
|
35
|
-
return unless File.exist?
|
|
36
|
-
|
|
37
|
-
@undocumented
|
|
69
|
+
def undocumented(scope = :modified)
|
|
70
|
+
return [] unless scope != :ignore && File.exist?(undocumented_path)
|
|
71
|
+
@undocumented = { modified: [], all: [] } if @undocumented.nil?
|
|
72
|
+
load_undocumented(scope) if @undocumented[scope].empty?
|
|
73
|
+
@undocumented[scope]
|
|
38
74
|
end
|
|
39
75
|
|
|
40
76
|
private
|
|
41
77
|
|
|
42
78
|
def docs_path
|
|
43
|
-
@
|
|
79
|
+
@path || 'docs/'
|
|
44
80
|
end
|
|
45
81
|
|
|
46
82
|
def undocumented_path
|
|
@@ -51,10 +87,36 @@ module Danger
|
|
|
51
87
|
git.modified_files + git.added_files
|
|
52
88
|
end
|
|
53
89
|
|
|
54
|
-
def load_undocumented
|
|
90
|
+
def load_undocumented(scope)
|
|
55
91
|
reader = UndocumentedReader.new(undocumented_path)
|
|
56
|
-
@undocumented = reader.undocumented_symbols.select do |item|
|
|
57
|
-
|
|
92
|
+
@undocumented[scope] = reader.undocumented_symbols.select do |item|
|
|
93
|
+
if scope == :modified
|
|
94
|
+
files_of_interest.include?(item.file)
|
|
95
|
+
else
|
|
96
|
+
true
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def fail_scope
|
|
102
|
+
@config[:fail] || :modified
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def warn_scope
|
|
106
|
+
@config[:warn] || :ignore
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def fail_check
|
|
110
|
+
undocumented(fail_scope).each do |item|
|
|
111
|
+
# rubocop:disable Style/SignalException
|
|
112
|
+
fail DEFAULT_MESSAGE, file: item.file, line: item.line
|
|
113
|
+
# rubocop:enable Style/SignalException
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def warn_check
|
|
118
|
+
undocumented(warn_scope).each do |item|
|
|
119
|
+
warn DEFAULT_MESSAGE, file: item.file, line: item.line
|
|
58
120
|
end
|
|
59
121
|
end
|
|
60
122
|
end
|
data/spec/jazzy_spec.rb
CHANGED
|
@@ -14,6 +14,7 @@ module Danger
|
|
|
14
14
|
@dangerfile = testing_dangerfile
|
|
15
15
|
@my_plugin = @dangerfile.jazzy
|
|
16
16
|
@default_message = 'Undocumented symbol.'
|
|
17
|
+
@my_plugin.path = 'spec/fixtures'
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
context 'changed files contains undocumented symbols' do
|
|
@@ -42,10 +43,38 @@ module Danger
|
|
|
42
43
|
.and_return(['MyFile.swift'])
|
|
43
44
|
end
|
|
44
45
|
|
|
45
|
-
it '
|
|
46
|
-
@my_plugin.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
it 'finds undocumented symbols only in modified files by default' do
|
|
47
|
+
expect(@my_plugin.undocumented.length).to eq(1)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'can find undocumented symbols in all files' do
|
|
51
|
+
expect(@my_plugin.undocumented(:all).length).to eq(2)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'fails on undocumented symbols only in modified files by default' do
|
|
55
|
+
@my_plugin.check
|
|
56
|
+
expect(@dangerfile.status_report[:errors]).to eq([@default_message])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'does not warn on undocumented symbols by default' do
|
|
60
|
+
@my_plugin.check
|
|
61
|
+
expect(@dangerfile.status_report[:warnings]).to eq([])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'can fail on undocumented symbols in all files' do
|
|
65
|
+
@my_plugin.check fail: :all
|
|
66
|
+
expect(@dangerfile.status_report[:errors]).to eq([@default_message, @default_message])
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'can warn on undocumented symbols in all files' do
|
|
70
|
+
@my_plugin.check warn: :all
|
|
71
|
+
expect(@dangerfile.status_report[:warnings]).to eq([@default_message, @default_message])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'does not fail if there is no undocumented json' do
|
|
75
|
+
@my_plugin.path = 'spec/empty'
|
|
76
|
+
@my_plugin.check
|
|
77
|
+
expect(@dangerfile.status_report[:errors]).to eq([])
|
|
49
78
|
end
|
|
50
79
|
end
|
|
51
80
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: danger-jazzy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Frederik Wallner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-11-
|
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: danger-plugin-api
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0.8'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: coveralls
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.8.15
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.8.15
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: guard
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -164,7 +178,7 @@ dependencies:
|
|
|
164
178
|
- - ">="
|
|
165
179
|
- !ruby/object:Gem::Version
|
|
166
180
|
version: '0'
|
|
167
|
-
description: A
|
|
181
|
+
description: A danger plugin for validating documentation generated with jazzy
|
|
168
182
|
email:
|
|
169
183
|
- frederik.wallner@gmail.com
|
|
170
184
|
executables: []
|
|
@@ -172,6 +186,7 @@ extensions: []
|
|
|
172
186
|
extra_rdoc_files: []
|
|
173
187
|
files:
|
|
174
188
|
- ".gitignore"
|
|
189
|
+
- ".rubocop.yml"
|
|
175
190
|
- ".travis.yml"
|
|
176
191
|
- CHANGELOG.md
|
|
177
192
|
- Gemfile
|
|
@@ -201,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
201
216
|
requirements:
|
|
202
217
|
- - ">="
|
|
203
218
|
- !ruby/object:Gem::Version
|
|
204
|
-
version:
|
|
219
|
+
version: 2.0.0
|
|
205
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
221
|
requirements:
|
|
207
222
|
- - ">="
|
|
@@ -212,7 +227,7 @@ rubyforge_project:
|
|
|
212
227
|
rubygems_version: 2.5.1
|
|
213
228
|
signing_key:
|
|
214
229
|
specification_version: 4
|
|
215
|
-
summary: A
|
|
230
|
+
summary: A danger plugin for validating documentation generated with jazzy
|
|
216
231
|
test_files:
|
|
217
232
|
- spec/fixtures/undocumented.json
|
|
218
233
|
- spec/jazzy_spec.rb
|