appium_doc_lint 0.0.10 → 0.0.11

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
  SHA1:
3
- metadata.gz: 3637ec9c28dbc012b5bfbdef591c8f0187aedcb2
4
- data.tar.gz: 5865887056deb7ddf46cece65c03421ac9f7cc7d
3
+ metadata.gz: e93c52c6eae739adc62445e0ac87a1f5c680beca
4
+ data.tar.gz: 9a5771779fe0b00ac3d0ec7f25606dafd36e0db6
5
5
  SHA512:
6
- metadata.gz: e0ea155206d3033272a894b0df55bf50bcdcab7920afc42716db27e55555533f0759eb62b3bc48bde0253c20eabd094e3a5872a893b0cfb60f03829e26849c27
7
- data.tar.gz: c284e9b92a89a3ca9f6076bcb77e9a14a6a65a09c2c0ea37813c67d45a8396fa391b544b3d80f78a4b4789554f6bc539030197adcb6d3e0ded258dceecce605b
6
+ metadata.gz: 02f28b73ad0fdb69483a033182c9ca0126d4e76e3127bac10974c921b8f2f0ba7d950288f3e7f3adead5a6a8befb40a79f28d786a3e55c1460c23269bac3d45d
7
+ data.tar.gz: 3ccc0b18a9b4f7ae99e54cfd3111aa50e8424f8b0c15a22b4eb4b181ef1f4ea041b47166b045f1cbd9c822e63a4be8552c50384237805cc3e92539fbb03ac911
@@ -4,18 +4,17 @@ module Appium
4
4
  class Lint
5
5
  require_relative 'lint/base'
6
6
  require_relative 'lint/ext_missing'
7
- require_relative 'lint/h1_invalid'
8
- require_relative 'lint/h1_multiple'
9
- require_relative 'lint/h1_missing'
7
+ require_relative 'lint/h2_multiple'
8
+ require_relative 'lint/h2_missing'
10
9
  require_relative 'lint/h2_invalid'
11
- require_relative 'lint/h456_invalid'
10
+ require_relative 'lint/h156_invalid'
12
11
  require_relative 'lint/line_break_invalid'
13
12
 
14
13
  # OpenStruct.new data: '', lines: '', file: ''
15
14
  attr_reader :input
16
15
 
17
16
  def initialize
18
- @rules = [ExtMissing, H1Missing, H1Multiple, H1Invalid, H2Invalid, H456Invalid, LineBreakInvalid]
17
+ @rules = [ExtMissing, H2Missing, H2Multiple, H2Invalid, H156Invalid, LineBreakInvalid]
19
18
  end
20
19
 
21
20
  def self.init_data opts={}, input
@@ -95,4 +94,4 @@ module Appium
95
94
  result.empty? ? nil : result
96
95
  end
97
96
  end
98
- end
97
+ end
@@ -3,17 +3,23 @@ module Appium
3
3
  ###
4
4
  # h4, h5, and h6 should not be used.
5
5
  # Slate works best with h1, h2, or h3
6
- class H456Invalid < Base
6
+ class H156Invalid < Base
7
7
  def call
8
+ in_code_block = false
8
9
  input.lines.each_with_index do |line, index|
9
- h456_invalid = !!line.match(/^\#{4,6}[^#]/)
10
- warn index if h456_invalid
11
- end
10
+ code_block = !! line.match(/^```/)
11
+ in_code_block = ! in_code_block if code_block
12
+
13
+ next if in_code_block
12
14
 
15
+ h156_invalid = !!line.match(/^\#{5,6}[^#]|^#[^#]|^===+\s*$/)
16
+ warn index if h156_invalid
17
+
18
+ end
13
19
  warnings
14
20
  end
15
21
 
16
- FAIL = 'h4, h5, h6 should not be used. Use h1, h2 or h3.'
22
+ FAIL = 'h1, h5, h6 should not be used. Use h2, h3 or h4.'
17
23
 
18
24
  def fail
19
25
  FAIL
@@ -26,4 +32,4 @@ end
26
32
  => "<h5>ok</h5>\n"
27
33
  > md.render(" ##### ok")
28
34
  => "<p>##### ok</p>\n"
29
- =end
35
+ =end
@@ -0,0 +1,25 @@
1
+ module Appium
2
+ class Lint
3
+ ###
4
+ # Each file must have a h2
5
+ # This forms the title for the document and is used to anchor the
6
+ # #filename.md link.
7
+ #
8
+ # The file should start with the h2. This rule will fail if the document
9
+ # doesn't contain at least one h2
10
+ class H2Missing < Base
11
+ def call
12
+ # either the doc has a h2 or it doesn't
13
+ # attach warning to line 0
14
+ h2_missing = !input.data.match(/^##[^#]/m)
15
+ h2_missing ? warn(0) : warnings
16
+ end
17
+
18
+ FAIL = 'h2 is missing'
19
+
20
+ def fail
21
+ FAIL
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,7 +2,7 @@ module Appium
2
2
  class Lint
3
3
  ###
4
4
  # Each doc must have exactly 1 h1
5
- class H1Multiple < Base
5
+ class H2Multiple < Base
6
6
  def call
7
7
  h1_count = 0
8
8
  in_code_block = false
@@ -12,7 +12,7 @@ module Appium
12
12
 
13
13
  next if in_code_block
14
14
 
15
- h1_detected = !! line.match(/^#[^#]/)
15
+ h1_detected = !! line.match(/^##[^#]/)
16
16
  if h1_detected # only warn if h1 detected
17
17
  h1_count += 1
18
18
  warn index if h1_count > 1
@@ -22,11 +22,11 @@ module Appium
22
22
  warnings
23
23
  end
24
24
 
25
- FAIL = 'each doc must contain exactly one h1'
25
+ FAIL = 'each doc must contain exactly one h2'
26
26
 
27
27
  def fail
28
28
  FAIL
29
29
  end
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -1,6 +1,6 @@
1
1
  module Appium
2
2
  class Lint
3
- VERSION = '0.0.10' unless defined? ::Appium::Lint::VERSION
4
- DATE = '2014-07-01' unless defined? ::Appium::Lint::DATE
3
+ VERSION = '0.0.11' unless defined? ::Appium::Lint::VERSION
4
+ DATE = '2014-07-03' unless defined? ::Appium::Lint::DATE
5
5
  end
6
6
  end
@@ -1,3 +1,11 @@
1
+ #### v0.0.10 2014-07-01
2
+
3
+ - [d1288b7](https://github.com/appium/appium_doc_lint/commit/d1288b77382f91334535671949717074f0e2d086) Release 0.0.10
4
+ - [e055255](https://github.com/appium/appium_doc_lint/commit/e05525508a0b48cd5ffa32bc69d23b77a48be56d) Check that file isn't a directory
5
+ - [56e3127](https://github.com/appium/appium_doc_lint/commit/56e31274068ef80e0f61d999bae06be1730785b2) Add test for multiple code blocks
6
+ - [ee0ee4d](https://github.com/appium/appium_doc_lint/commit/ee0ee4d068c982152e22fd9a67d291d1a0ba463d) Add example one time scan
7
+
8
+
1
9
  #### v0.0.9 2014-04-27
2
10
 
3
11
  - [3c4661e](https://github.com/appium/appium_doc_lint/commit/3c4661ebe628ab2b320f77f53b53b537b8c1723e) Release 0.0.9
@@ -1,3 +1,3 @@
1
- # h1
1
+ ## h2
2
2
 
3
- ## h2
3
+ ### h3
@@ -1,4 +1,4 @@
1
- # h1
1
+ ## h2
2
2
 
3
3
  --
4
4
 
@@ -6,7 +6,7 @@ hi
6
6
 
7
7
  ---
8
8
 
9
- # h1 again
9
+ ## h2 again
10
10
 
11
11
  ##### h5
12
12
 
@@ -18,8 +18,8 @@ don't detect duplicate h1 in code blocks
18
18
  # testing
19
19
  ```
20
20
 
21
- # dupe
21
+ ## dupe
22
22
 
23
23
  [ok](ok#ok)
24
24
  [ok](ok.md)
25
- [ok](ok.md#ok)
25
+ [ok](ok.md#ok)
@@ -9,14 +9,14 @@ class Appium::Lint
9
9
  actual = lint.glob dir
10
10
 
11
11
  # 1.md has no problems so it doesn't show up in expected failures
12
- expected = { '0.md' => { 1 => [H1Missing::FAIL],
13
- 2 => [H1Invalid::FAIL],
12
+ expected = { '0.md' => { 1 => [H2Missing::FAIL],
13
+ 2 => [H156Invalid::FAIL],
14
14
  5 => [H2Invalid::FAIL] },
15
15
  '3.md' => { 3 => [LineBreakInvalid::FAIL],
16
16
  7 => [LineBreakInvalid::FAIL],
17
- 9 => [H1Multiple::FAIL],
18
- 11 => [H456Invalid::FAIL],
19
- 21 => [H1Multiple::FAIL],
17
+ 9 => [H2Multiple::FAIL],
18
+ 11 => [H156Invalid::FAIL],
19
+ 21 => [H2Multiple::FAIL],
20
20
  23 => [ExtMissing::FAIL + ' [ok](ok#ok)'] } }
21
21
 
22
22
  # convert path/to/0.md to 0.md
@@ -36,16 +36,16 @@ class Appium::Lint
36
36
  actual = lint.report lint.glob dir
37
37
  expected = (<<REPORT).strip
38
38
  ./spec/data/0.md
39
- 1: #{H1Missing::FAIL}
40
- 2: #{H1Invalid::FAIL}
39
+ 1: #{H2Missing::FAIL}
40
+ 2: #{H156Invalid::FAIL}
41
41
  5: #{H2Invalid::FAIL}
42
42
 
43
43
  ./spec/data/sub/3.md
44
44
  3: #{LineBreakInvalid::FAIL}
45
45
  7: #{LineBreakInvalid::FAIL}
46
- 9: #{H1Multiple::FAIL}
47
- 11: #{H456Invalid::FAIL}
48
- 21: #{H1Multiple::FAIL}
46
+ 9: #{H2Multiple::FAIL}
47
+ 11: #{H156Invalid::FAIL}
48
+ 21: #{H2Multiple::FAIL}
49
49
  23: #{ExtMissing::FAIL + ' [ok](ok#ok)'}
50
50
  REPORT
51
51
 
@@ -83,16 +83,15 @@ there 2
83
83
  ###### h6
84
84
  MARKDOWN
85
85
 
86
- expected = { 1 => [H1Missing::FAIL],
87
- 2 => [H1Invalid::FAIL],
88
- 5 => [H1Invalid::FAIL],
86
+ expected = { 1 => [H2Missing::FAIL],
87
+ 2 => [H156Invalid::FAIL],
88
+ 5 => [H156Invalid::FAIL],
89
89
  8 => [H2Invalid::FAIL],
90
90
  11 => [H2Invalid::FAIL],
91
91
  13 => [LineBreakInvalid::FAIL],
92
92
  15 => [LineBreakInvalid::FAIL],
93
- 17 => [H456Invalid::FAIL],
94
- 18 => [H456Invalid::FAIL],
95
- 19 => [H456Invalid::FAIL] }
93
+ 18 => [H156Invalid::FAIL],
94
+ 19 => [H156Invalid::FAIL] }
96
95
 
97
96
  actual = lint.call data: markdown
98
97
 
@@ -100,9 +99,9 @@ MARKDOWN
100
99
  end
101
100
  end
102
101
 
103
- describe H1Multiple do
104
- it 'detects extra h1s' do
105
- rule = H1Multiple.new data: "# hi\n# bye\n#test"
102
+ describe H2Multiple do
103
+ it 'detects extra h2s' do
104
+ rule = H2Multiple.new data: "## hi\n## bye\n##test"
106
105
  expected = { 2 => [rule.fail],
107
106
  3 => [rule.fail] }
108
107
  actual = rule.call
@@ -110,8 +109,8 @@ MARKDOWN
110
109
  expect(actual).to eq(expected)
111
110
  end
112
111
 
113
- it 'does not error on one h1' do
114
- rule = H1Multiple.new data: '# hi'
112
+ it 'does not error on one h2' do
113
+ rule = H2Multiple.new data: '## hi'
115
114
  expected = {}
116
115
  actual = rule.call
117
116
 
@@ -134,52 +133,24 @@ Here's a Ruby example:
134
133
  # Ruby example
135
134
  ```
136
135
  DATA
137
- rule = H1Multiple.new data: data
136
+ rule = H2Multiple.new data: data
138
137
  expected = {}
139
138
  actual = rule.call
140
139
  expect(actual).to eq(expected)
141
140
  end
142
141
  end
143
142
 
144
- describe H1Missing do
143
+ describe H2Missing do
145
144
  it 'detects missing h1' do
146
- rule = H1Missing.new data: '## hi'
145
+ rule = H2Missing.new data: '### hi'
147
146
  expected = { 1 => [rule.fail] }
148
147
  actual = rule.call
149
148
 
150
149
  expect(actual).to eq(expected)
151
150
  end
152
151
 
153
- it 'does not error on valid h1' do
154
- rule = H1Missing.new data: '# hi'
155
- expected = {}
156
- actual = rule.call
157
-
158
- expect(actual).to eq(expected)
159
- end
160
- end
161
-
162
- describe H1Invalid do
163
- it 'detects invalid h1' do
164
- rule = H1Invalid.new data: "hi\n==="
165
- expected = { 2 => [rule.fail] }
166
- actual = rule.call
167
-
168
- expect(actual).to eq(expected)
169
- end
170
-
171
- it 'detects multiple invalid h1' do
172
- rule = H1Invalid.new data: "hi\n===\nbye\n======\n\n===="
173
- expected = { 2 => [rule.fail],
174
- 4 => [rule.fail],
175
- 6 => [rule.fail] }
176
- actual = rule.call
177
-
178
- expect(actual).to eq(expected)
179
- end
180
-
181
- it 'detects valid h1' do
182
- rule = H1Invalid.new data: '# hi'
152
+ it 'does not error on valid h2' do
153
+ rule = H2Missing.new data: '## hi'
183
154
  expected = {}
184
155
  actual = rule.call
185
156
 
@@ -197,7 +168,7 @@ DATA
197
168
  end
198
169
 
199
170
  it 'detects multiple invalid h2' do
200
- rule = H2Invalid.new data: "hi\n---\nbye\n-------"
171
+ rule = H2Invalid.new data: "hi\n---\nbye\n-----\n\n-------"
201
172
  expected = { 2 => [rule.fail],
202
173
  4 => [rule.fail] }
203
174
  actual = rule.call
@@ -214,10 +185,10 @@ DATA
214
185
  end
215
186
  end
216
187
 
217
- describe H456Invalid do
218
- it 'detects invalid h4, h5, h6' do
219
- ['#### h4', '##### h5', '###### h6'].each do |data|
220
- rule = H456Invalid.new data: data
188
+ describe H156Invalid do
189
+ it 'detects invalid h1, h5, h6' do
190
+ ['# h1', '##### h5', '###### h6'].each do |data|
191
+ rule = H156Invalid.new data: data
221
192
  expected = { 1 => [rule.fail] }
222
193
  actual = rule.call
223
194
 
@@ -225,7 +196,7 @@ DATA
225
196
  end
226
197
  end
227
198
 
228
- it 'detects multiple invalid h4, h5, h6' do
199
+ it 'detects multiple invalid h1, h5, h6' do
229
200
  data = <<-MARKDOWN
230
201
  # h1
231
202
  ## h2
@@ -234,10 +205,11 @@ DATA
234
205
  ##### h5
235
206
  ###### h6
236
207
  #### not actually a h4 due to leading space
208
+
237
209
  MARKDOWN
238
210
 
239
- rule = H456Invalid.new data: data
240
- expected = { 4 => [rule.fail],
211
+ rule = H156Invalid.new data: data
212
+ expected = { 1 => [rule.fail],
241
213
  5 => [rule.fail],
242
214
  6 => [rule.fail] }
243
215
  actual = rule.call
@@ -245,13 +217,13 @@ DATA
245
217
  expect(actual).to eq(expected)
246
218
  end
247
219
 
248
- it 'does not error on h1, h2, h3' do
220
+ it 'does not error on h2, h3, h4' do
249
221
  data = <<-MARKDOWN
250
- # h1
251
- # h2
252
- # h3
222
+ ## h2
223
+ ### h3
224
+ #### h4
253
225
  MARKDOWN
254
- rule = H456Invalid.new data: data
226
+ rule = H156Invalid.new data: data
255
227
  expected = {}
256
228
  actual = rule.call
257
229
 
@@ -342,4 +314,4 @@ markdown--
342
314
  expect(actual).to eq(expected)
343
315
  end
344
316
  end
345
- end
317
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_doc_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -73,11 +73,10 @@ files:
73
73
  - lib/appium_doc_lint/lint.rb
74
74
  - lib/appium_doc_lint/lint/base.rb
75
75
  - lib/appium_doc_lint/lint/ext_missing.rb
76
- - lib/appium_doc_lint/lint/h1_invalid.rb
77
- - lib/appium_doc_lint/lint/h1_missing.rb
78
- - lib/appium_doc_lint/lint/h1_multiple.rb
76
+ - lib/appium_doc_lint/lint/h156_invalid.rb
79
77
  - lib/appium_doc_lint/lint/h2_invalid.rb
80
- - lib/appium_doc_lint/lint/h456_invalid.rb
78
+ - lib/appium_doc_lint/lint/h2_missing.rb
79
+ - lib/appium_doc_lint/lint/h2_multiple.rb
81
80
  - lib/appium_doc_lint/lint/line_break_invalid.rb
82
81
  - lib/appium_doc_lint/version.rb
83
82
  - release_notes.md
@@ -1,36 +0,0 @@
1
- module Appium
2
- class Lint
3
- ###
4
- # h1 must use the `#` syntax and not the `===` underline syntax.
5
- # check for three = to reduce false positives
6
- class H1Invalid < Base
7
- def call
8
- # === is always a h1 regardless of previous line
9
- input.lines.each_with_index do |line, index|
10
- h1_invalid = !!line.match(/^===+\s*$/)
11
- warn index if h1_invalid
12
- end
13
-
14
- warnings
15
- end
16
-
17
- FAIL = 'h1 must not use === underline syntax. Use # instead'
18
-
19
- def fail
20
- FAIL
21
- end
22
- end
23
- end
24
- end
25
-
26
- =begin
27
- md = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
28
- > md.render("hi\n=")
29
- => "<h1>hi</h1>\n"
30
- > md.render("hi\n =")
31
- => "<p>hi\n =</p>\n"
32
- > md.render("hi\n= ")
33
- => "<h1>hi</h1>\n"
34
- > md.render("\n\n======")
35
- => "<h1></h1>\n"
36
- =end
@@ -1,25 +0,0 @@
1
- module Appium
2
- class Lint
3
- ###
4
- # Each file must have a h1
5
- # This forms the title for the document and is used to anchor the
6
- # #filename.md link.
7
- #
8
- # The file should start with the h1. This rule will fail if the document
9
- # doesn't contain at least one h1
10
- class H1Missing < Base
11
- def call
12
- # either the doc has a h1 or it doesn't
13
- # attach warning to line 0
14
- h1_missing = !input.data.match(/^#[^#]/m)
15
- h1_missing ? warn(0) : warnings
16
- end
17
-
18
- FAIL = 'h1 is missing'
19
-
20
- def fail
21
- FAIL
22
- end
23
- end
24
- end
25
- end