Plugin Docs CLI: Limit doc page nesting to 3 #2646
Open
sunker wants to merge 1 commit into
Open
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new filesystem validation rule to @grafana/plugin-docs-cli to cap documentation page nesting depth at 3 path segments from the docs root, surfacing as info during serve (non-strict) and error during validate --strict.
Changes:
- Introduces
Rule.MaxNestingDepthin the validation rule registry. - Implements
max-nesting-depthchecking in the filesystem rule runner (checkFilesystem). - Adds unit tests covering compliant depth, strict/non-strict severities, and per-file reporting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/plugin-docs-cli/src/validation/types.ts | Adds the new max-nesting-depth rule identifier to the central Rule list. |
| packages/plugin-docs-cli/src/validation/rules/filesystem.ts | Implements the nesting depth calculation and emits diagnostics based on strict. |
| packages/plugin-docs-cli/src/validation/rules/filesystem.test.ts | Adds test coverage for depth limits and severity behavior. |
Comment on lines
+49
to
+54
| if (depth > MAX_NESTING_DEPTH) { | ||
| diagnostics.push({ | ||
| rule: Rule.MaxNestingDepth, | ||
| severity: input.strict ? 'error' : 'info', | ||
| file: filePath, | ||
| title: `Doc page nested too deeply (${depth} levels, max ${MAX_NESTING_DEPTH})`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Adds the FS-7 max nesting depth rule to
@grafana/plugin-docs-cliwith a limit of 3 levels (soa/b/page.mdis fine buta/b/c/page.mdis too deep). Reportsinfoduringserveanderrorundervalidate --strict.We need a hard cap because the SidebarNav component on the marketing website only looks sensible up to a handful of nesting levels - past that the nav gets cramped and pages become hard to discover. Better to stop authors before they ship a structure the rendered nav can't handle than to paper over it in the website.
Which issue(s) this PR fixes:
Part of the docs validation epic.
Special notes for your reviewer:
📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install website@5.6.1-canary.2646.26289611329.0 npm install @grafana/create-plugin@7.6.1-canary.2646.26289611329.0 npm install @grafana/plugin-docs-cli@0.0.11-canary.2646.26289611329.0 npm install @grafana/plugin-meta-extractor@0.12.3-canary.2646.26289611329.0 # or yarn add website@5.6.1-canary.2646.26289611329.0 yarn add @grafana/create-plugin@7.6.1-canary.2646.26289611329.0 yarn add @grafana/plugin-docs-cli@0.0.11-canary.2646.26289611329.0 yarn add @grafana/plugin-meta-extractor@0.12.3-canary.2646.26289611329.0