Repository navigation
refactor(ipa): CLOUDP-453872 defineRule collects results, generated Applies to docs - #1564
Conversation
8ad4ff2 to
e970023
Compare
83fb794 to
6cc19ba
Compare
6cc19ba to
e373e5c
Compare
| @@ -0,0 +1,5 @@ | |||
| <!--- NOTE: This file is generated, please see /scripts/generateRulesetReadme.js ---> | |||
There was a problem hiding this comment.
Any reason why we need this as separate md file. Can we append to existing docs?
There was a problem hiding this comment.
I considered rulesets/README.md, but kept it separate. That README is already ~1,800 lines, and the glossary is reference material that readers reach from an "Applies to" link rather than by reading top to bottom. On my local branch, with 71 of ~117 rules migrated, it is ~520 lines (34 conditions), which would be about a quarter of the README. CONTRIBUTING.md is for rule authors, and this file is generated from the code. To make it findable, tools/spectral/README.md now links to it next to the ruleset docs. Happy to fold it into the rules README if you would still prefer that.
| @@ -0,0 +1,5 @@ | |||
| <!--- NOTE: This file is generated, please see /scripts/generateRulesetReadme.js ---> | |||
|
|
|||
| # IPA Validation Conditions | |||
There was a problem hiding this comment.
Let's add fixes description what business purpose this chapter serves before generated content
There was a problem hiding this comment.
Added an intro before the generated content, and a "Why generate the docs" section to the PR description on what the generated docs are for.
| const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const readmeFilePath = path.join(dirname, '../rulesets', 'README.md'); | ||
| const conditionsFilePath = path.join(dirname, '../rulesets', 'CONDITIONS.md'); | ||
| const CONDITIONS_URL = 'https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/CONDITIONS.md'; |
There was a problem hiding this comment.
[nit] Why do we need whole repository path?
There was a problem hiding this comment.
The generated README already uses absolute GitHub URLs (for example the link to ipa-spectral.yaml), so the glossary links follow the same convention. The constant is only there so each "Applies to" link and the glossary's own links are built from one place.
| @@ -0,0 +1,467 @@ | |||
| # Known issues: singleton / nested-resource classification | |||
There was a problem hiding this comment.
Is this Agentic report file or something we wish to document?
There was a problem hiding this comment.
Added by mistake: it's a working-notes file that isn't part of this change. Removed it from this PR and from #1565.
wtrocki
left a comment
There was a problem hiding this comment.
We need more documentation and justification for the framework.
Feel free to reuse existing document you have shared so we surface all the relevant context and impact in the PR and source code.
|
Nothing blocking. Will approve once we get documentation updates. |
…s docs defineRule records adoptions, violations and exceptions and makes each rule's internal-error behavior an explicit option. gen-ipa-docs renders an Applies to section for rules built with defineRule and a conditions glossary. Nothing uses either yet.
e373e5c to
98f42b4
Compare
Proposed changes
Second of three PRs (CLOUDP-453872). Builds on the framework PR; still no rule uses
defineRule, so there is no change to lint results.defineRulerecords an adoption, violation or exception from the errorscheckreturns, readingx-xgen-IPA-exceptionfromexceptionTarget(the input by default).onInternalError('violation','return','throw') makes each rule's existing try/catch behavior an explicit option instead of a copied block.beforeCheckruns outside the try, for the operation ID rules whose unreadable verb override must keep failing the lint run.checkUseslists conditions the check evaluates itself, for the docs.gen-ipa-docsrenders an "Applies to" section for rules built withdefineRuleand writesrulesets/CONDITIONS.md, a glossary of each condition's definition, examples and the rules that use it. The existing docs check covers both files. Conditions get alabeland examples anotefor this.CONDITIONS.mdis empty here because no rule uses a condition yet.Why generate the docs
CONDITIONS.mdare generated from the conditions the rule declares, so the docs equal what the rule does. The docs check fails if they are out of date.Jira ticket: CLOUDP-453872
Checklist
Changes to Spectral
Further comments
Stack of three: #1529 (framework, merged), this PR, then #1565 (IPA-104/113 migration), which is based on this PR's branch.