appium_doc_lint 0.0.2 → 0.0.3
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/bin/appium_doc_lint +5 -1
- data/lib/appium_doc_lint/lint/h1_multiple.rb +32 -0
- data/lib/appium_doc_lint/lint.rb +2 -1
- data/lib/appium_doc_lint/version.rb +1 -1
- data/release_notes.md +5 -0
- data/spec/data/sub/3.md +15 -1
- data/spec/helper.rb +1 -0
- data/spec/lint_spec.rb +38 -13
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e51c5890b05e13f9b3cb7a21120420df411822c
|
4
|
+
data.tar.gz: 7f3867ba30ad673c7b48524708b9272aa18ec25c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba53a6f63988c9a30fe82e5c4097bd6d1878bf37bbd17232a3b64308b80f222072342255eab763f16501e98406931c05c75bdcddf53b30cf6d02b6a197c26ed7
|
7
|
+
data.tar.gz: cb972b4a8371813897fe82395dac84435bc1d83fea905168e720ee2a5b90e3b5c8db3a7e045347ba8e7eb3c65a08765525b226382a8532da0248728309611f45
|
data/bin/appium_doc_lint
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Appium
|
2
|
+
class Lint
|
3
|
+
###
|
4
|
+
# Each doc must have exactly 1 h1
|
5
|
+
class H1Multiple < Base
|
6
|
+
def call
|
7
|
+
h1_count = 0
|
8
|
+
in_code_block = false
|
9
|
+
input.lines.each_with_index do |line, index|
|
10
|
+
code_block = !! line.match(/^```/)
|
11
|
+
in_code_block = ! in_code_block if code_block
|
12
|
+
|
13
|
+
next if in_code_block
|
14
|
+
|
15
|
+
h1_detected = !! line.match(/^#[^#]/)
|
16
|
+
if h1_detected # only warn if h1 detected
|
17
|
+
h1_count += 1
|
18
|
+
warn index if h1_count > 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
warnings
|
23
|
+
end
|
24
|
+
|
25
|
+
FAIL = 'each doc must contain exactly one h1'
|
26
|
+
|
27
|
+
def fail
|
28
|
+
FAIL
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/appium_doc_lint/lint.rb
CHANGED
@@ -4,6 +4,7 @@ module Appium
|
|
4
4
|
class Lint
|
5
5
|
require_relative 'lint/base'
|
6
6
|
require_relative 'lint/h1_invalid'
|
7
|
+
require_relative 'lint/h1_multiple'
|
7
8
|
require_relative 'lint/h1_missing'
|
8
9
|
require_relative 'lint/h2_invalid'
|
9
10
|
require_relative 'lint/h456_invalid'
|
@@ -13,7 +14,7 @@ module Appium
|
|
13
14
|
attr_reader :input
|
14
15
|
|
15
16
|
def initialize
|
16
|
-
@rules = [
|
17
|
+
@rules = [H1Missing, H1Multiple, H1Invalid, H2Invalid, H456Invalid, LineBreakInvalid]
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.init_data opts={}, input
|
data/release_notes.md
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
####
|
2
|
+
|
3
|
+
- [910d158](https://github.com/appium/appium_doc_lint/commit/910d1583b5286c9c13242f97722ce50c99023944) Release 0.0.2
|
4
|
+
- [4759871](https://github.com/appium/appium_doc_lint/commit/4759871312485a6574d468eb4baba703c44435e3) Guarantee glob order
|
5
|
+
- [bdf6993](https://github.com/appium/appium_doc_lint/commit/bdf69931b0579dc657ffe5bf76a8bf75f2bf565f) Add gem badge
|
data/spec/data/sub/3.md
CHANGED
data/spec/helper.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rspec'
|
|
3
3
|
require_relative '../lib/appium_doc_lint/lint'
|
4
4
|
require_relative '../lib/appium_doc_lint/lint/base'
|
5
5
|
require_relative '../lib/appium_doc_lint/lint/h1_missing'
|
6
|
+
require_relative '../lib/appium_doc_lint/lint/h1_multiple'
|
6
7
|
require_relative '../lib/appium_doc_lint/lint/h1_invalid'
|
7
8
|
require_relative '../lib/appium_doc_lint/lint/h2_invalid'
|
8
9
|
require_relative '../lib/appium_doc_lint/lint/h456_invalid'
|
data/spec/lint_spec.rb
CHANGED
@@ -2,22 +2,25 @@ require_relative 'helper'
|
|
2
2
|
|
3
3
|
class Appium::Lint
|
4
4
|
describe 'Lint' do
|
5
|
-
it 'processes globbed files' do
|
6
|
-
lint
|
7
|
-
dir
|
5
|
+
it 'processes globbed files using all lint rules' do
|
6
|
+
lint = Appium::Lint.new
|
7
|
+
dir = File.join(Dir.pwd, 'spec', 'data', '**', '*.md')
|
8
8
|
|
9
|
-
actual
|
9
|
+
actual = lint.glob dir
|
10
10
|
|
11
11
|
# 1.md has no problems so it doesn't show up in expected failures
|
12
12
|
expected = { '0.md' => { 1 => [H1Missing::FAIL],
|
13
13
|
2 => [H1Invalid::FAIL],
|
14
14
|
5 => [H2Invalid::FAIL] },
|
15
|
-
'3.md' => { 3
|
16
|
-
7
|
15
|
+
'3.md' => { 3 => [LineBreakInvalid::FAIL],
|
16
|
+
7 => [LineBreakInvalid::FAIL],
|
17
|
+
9 => [H1Multiple::FAIL],
|
18
|
+
11 => [H456Invalid::FAIL],
|
19
|
+
21 => [H1Multiple::FAIL],} }
|
17
20
|
|
18
21
|
# convert path/to/0.md to 0.md
|
19
22
|
actual.keys.each do |key|
|
20
|
-
new_key
|
23
|
+
new_key = File.basename key
|
21
24
|
actual[new_key] = actual[key]
|
22
25
|
actual.delete key
|
23
26
|
end
|
@@ -25,11 +28,11 @@ class Appium::Lint
|
|
25
28
|
expect(actual).to eq(expected)
|
26
29
|
end
|
27
30
|
|
28
|
-
it 'reports globbed files' do
|
29
|
-
lint
|
30
|
-
dir
|
31
|
+
it 'reports globbed files using all lint rules' do
|
32
|
+
lint = Appium::Lint.new
|
33
|
+
dir = File.join(Dir.pwd, 'spec', 'data', '**', '*.md')
|
31
34
|
|
32
|
-
actual
|
35
|
+
actual = lint.report lint.glob dir
|
33
36
|
expected = (<<REPORT).strip
|
34
37
|
0.md
|
35
38
|
1: #{H1Missing::FAIL}
|
@@ -39,6 +42,9 @@ class Appium::Lint
|
|
39
42
|
3.md
|
40
43
|
3: #{LineBreakInvalid::FAIL}
|
41
44
|
7: #{LineBreakInvalid::FAIL}
|
45
|
+
9: #{H1Multiple::FAIL}
|
46
|
+
11: #{H456Invalid::FAIL}
|
47
|
+
21: #{H1Multiple::FAIL}
|
42
48
|
REPORT
|
43
49
|
|
44
50
|
expect(actual).to eq(expected)
|
@@ -46,7 +52,7 @@ REPORT
|
|
46
52
|
|
47
53
|
it 'empty report is falsey' do
|
48
54
|
lint = Appium::Lint.new
|
49
|
-
actual = !!
|
55
|
+
actual = !!lint.report({})
|
50
56
|
expect(actual).to eq(false)
|
51
57
|
end
|
52
58
|
|
@@ -92,6 +98,25 @@ MARKDOWN
|
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
101
|
+
describe H1Multiple do
|
102
|
+
it 'detects extra h1s' do
|
103
|
+
rule = H1Multiple.new data: "# hi\n# bye\n#test"
|
104
|
+
expected = { 2 => [rule.fail],
|
105
|
+
3 => [rule.fail] }
|
106
|
+
actual = rule.call
|
107
|
+
|
108
|
+
expect(actual).to eq(expected)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'does not error on one h1' do
|
112
|
+
rule = H1Multiple.new data: '# hi'
|
113
|
+
expected = {}
|
114
|
+
actual = rule.call
|
115
|
+
|
116
|
+
expect(actual).to eq(expected)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
95
120
|
describe H1Missing do
|
96
121
|
it 'detects missing h1' do
|
97
122
|
rule = H1Missing.new data: '## hi'
|
@@ -101,7 +126,7 @@ MARKDOWN
|
|
101
126
|
expect(actual).to eq(expected)
|
102
127
|
end
|
103
128
|
|
104
|
-
it '
|
129
|
+
it 'does not error on valid h1' do
|
105
130
|
rule = H1Missing.new data: '# hi'
|
106
131
|
expected = {}
|
107
132
|
actual = rule.call
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appium_doc_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- code@bootstraponline.com
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/appium_doc_lint/lint/base.rb
|
74
74
|
- lib/appium_doc_lint/lint/h1_invalid.rb
|
75
75
|
- lib/appium_doc_lint/lint/h1_missing.rb
|
76
|
+
- lib/appium_doc_lint/lint/h1_multiple.rb
|
76
77
|
- lib/appium_doc_lint/lint/h2_invalid.rb
|
77
78
|
- lib/appium_doc_lint/lint/h456_invalid.rb
|
78
79
|
- lib/appium_doc_lint/lint/line_break_invalid.rb
|