Skip to content

Commit 85c8e60

Browse files
authored
Merge pull request #43 from couchbaselabs/DOC-13478-vale-review-capella-API
DOC-13478 vale review capella api
2 parents 8b949d0 + ffef7ca commit 85c8e60

6 files changed

Lines changed: 72 additions & 2 deletions

File tree

ValeStyles/.vale.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ experimental = YES
2626

2727
attribute-missing = drop
2828

29+
Vale.Spelling = NO
30+
2931
[*.{adoc,md,txt}]
3032
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
3133

32-
Vale.Spelling = NO
34+
[test/fixtures/test.yml]
35+
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
36+
View = OpenAPIInclude
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
engine: dasel
2+
scopes:
3+
- expr: properties.all().property(description?)
4+
type: md
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
engine: dasel
2+
scopes:
3+
- expr: description
4+
type: md

ValeStyles/test/expected.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('run vale against test files', function () {
1414
'vale',
1515
[
1616
'--output', 'JSON',
17-
'test/fixtures/'
17+
'test/fixtures/*.adoc'
1818
]
1919
)
2020
}

ValeStyles/test/fixtures/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type: test
2+
content:
3+
foo: 1
4+
bar: 2
5+
description: |
6+
First sentence. Second sentence.
7+
Test couchbase.

ValeStyles/test/view-span.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const {range, zip, escape} = require('lodash');
2+
3+
// this test file is designed to be run with Mocha
4+
const assert = require('assert')
5+
const fs = require('fs')
6+
const ok = specify
7+
const { spawnSync } = require('node:child_process')
8+
9+
describe('check spans for Yaml', function () {
10+
testSpans('test/fixtures/test.yml')
11+
})
12+
13+
describe('check spans for Asciidoc', function () {
14+
testSpans('test/fixtures/basic.adoc')
15+
})
16+
17+
function testSpans(file) {
18+
const vale = runVale(file)
19+
20+
const text = fs.readFileSync(file).toString()
21+
const lines = text.match(/^.*?(\n|$)/gm)
22+
23+
for (const item of vale[file]) {
24+
const line = lines[item.Line - 1]
25+
const [from,to] = item.Span
26+
const span = line.substr(from - 1, to-from+1)
27+
28+
ok(`Match ${item.Match}`, function () {
29+
assert.equal(item.Match, span)
30+
console.log({line, span, match: item.Match})
31+
})
32+
}
33+
}
34+
35+
function runVale(file) {
36+
let vale
37+
try {
38+
vale = spawnSync(
39+
'vale',
40+
[
41+
'--output', 'JSON',
42+
file
43+
]
44+
)
45+
}
46+
catch (err) {
47+
console.log("Failed to run vale", err)
48+
}
49+
50+
return JSON.parse(vale.stdout)
51+
}

0 commit comments

Comments
 (0)