-
Notifications
You must be signed in to change notification settings - Fork 30
DOC-13478 vale review capella api #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These Views are customized to either:
- `description` at top-level (Included)
- `properties.*.description`
This requires us to explicitly tell Vale which files are of which type in the .vale.ini
like this example:
```
[cmd/cp-open-api/specs/schemas/alertIntegration/{BasicAuth,*AlertIntegration*,Exclude,Reque
st*, Response*}.yaml]
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
View = OpenAPI
[cmd/cp-open-api/specs/schemas/alertIntegration/{Token}.yaml]
BasedOnStyles = Vale, write-good, proselint, Couchbase, Google
View = OpenAPIInclude
```
(This restriction may go away with dasel 3, once Vale integrates that)
It looks like the behaviour of Vale with dasel view of a Yaml file gives inconsistent results for Line and Span. EXPECT: ====== the .Line and .Span records should point to the location in the file that the .Match text comes from. ACTUAL: ====== * For .adoc, this expectation is true. * For rules like Couchbase.VentilatedProse (theory: with `scope: raw`), we instead get the .Line indexed from the position of the Yaml token selected. For example, on the first line of the `.description`, it is marked as Line: 1 * For rules like Vale.Terms, we do get the correct .Line, but the .Span is indexed based on *YAML*'s understanding of the parsed content, not the textual source of the .yaml file contents.
sarahlwelton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how intelligent most of my comments are after like 10 minutes of research but lemme know I guess 😅
|
|
||
| attribute-missing = drop | ||
|
|
||
| Vale.Spelling = NO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we don't want to run spellcheck?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question!
There were a lot of false positives, and it made testing very noisy.
I think the correct thing would be to add a vocabularies/CapellaOpenAPI.txt and update those such that there's a canonical list of words used. (Some of these might also go into our Couchbase.txt list, but I think it's worth keeping some hygiene between them.)
I'd like to do this as a subsequent step, rather than making it a blocker though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. Our current vocabularies aren't very fleshed out, so might be worth investing some time into those in general.
| BasedOnStyles = Vale, write-good, proselint, Couchbase, Google | ||
|
|
||
| Vale.Spelling = NO | ||
| [test/fixtures/test.yml] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is only going to limit to files called test.yml. Is that going to work for where you want to deploy this? Shouldn't we just specify the yml file extension generally, instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is just a sample test.yml file, for the purpose of testing the infrastructure.
(It's actually proving that Vale+Views+Dasel Yaml mangles the line numbers... I've submitted a bug-report)
The customized .vale.ini then lives in the content repo, currently a POC one https://github.com/couchbaselabs/docs-vale-openapi-test-poc/blob/master/cmd/cp-open-api/specs/.vale.ini
That's because there's some mangling for specific files needing a specific view (again, to work around a Vale+Views+dasel bug/misfeature) which I don't think needs to go in the central .vale.ini.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my, that .ini seems a little fragile - I hope that bug fix makes that easier to manage going forward.
| catch (err) { | ||
| console.log("Failed to run vale", err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, does Vale not give more specific errors to try and map onto, or is this just for a quick and dirty approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not expecting the vale invocation to fail, so this just passes the error back to us so we can understand what happened (usually it'll be because I got the command parameters wrong).
| describe('check spans for Asciidoc', function () { | ||
| testSpans('test/fixtures/basic.adoc') | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just for testing? Just curious why we have a test for checking for AsciiDoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, just:
- Confirm that my expectation that .Line and .Span should identify the string in the source file actually works for .adoc
- Having done that lets us know that the logic for checking the files is correct, and therefore a yaml failure is meaningful! (That's important because it's so easy to get off-by-one errors, I could easily have been checking the wrong text.)
- Codify the .adoc expectation as a regression test so we notice if the Vale project ever breaks that understanding.
| engine: dasel | ||
| scopes: | ||
| - expr: properties.all().property(description?) | ||
| type: md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does md just make linting this easier? Just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenAPI descriptions are specified as Markdown I think?
| Vale.Spelling = NO | ||
| [test/fixtures/test.yml] | ||
| BasedOnStyles = Vale, write-good, proselint, Couchbase, Google | ||
| View = OpenAPIInclude |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the Vale docs - you've only included one of the .yml files you added for defining a view? Does the other one not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the only view that's relevant for this file. See the POC .vale.ini linked above for more examples
| @@ -0,0 +1,4 @@ | |||
| engine: dasel | |||
| scopes: | |||
| - expr: properties.all().property(description?) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this proper Dasel syntax? What are you trying to extract with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. It's essentially .properties.*.description
| @@ -0,0 +1,4 @@ | |||
| engine: dasel | |||
| scopes: | |||
| - expr: description | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this might work for the very simple yml - do we want to make it more complex for the yml we're actually going to be linting? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an actual usecase!
https://github.com/couchbasecloud/couchbase-cloud/blob/main/cmd/cp-open-api/specs/schemas/backups/GetBackupByIDResponse.yaml is an example of OpenAPI.yml (.properties.*.description)
https://github.com/couchbasecloud/couchbase-cloud/blob/main/cmd/cp-open-api/specs/schemas/backups/Method.yaml is an example of this OpenAPIInclude.yml (.description)
The ideal would be expr: ..description which should be possible one Vale integrates the latest Dasel v3 with that feature added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, didn't realize that Vale hadn't quite caught up to the latest Dasel. Makes sense then.
I'll need to merge this in to get the "Vale review of OpenAPI files in Capella repo" feature deployed.
If you have time to check, let me know if you see any issues!
(No worry if not, I'll make good any regressions.)