File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,6 @@ export const LINT_MESSAGES = {
55 missingChangeVersion : 'Missing version field in the API doc entry' ,
66 invalidChangeVersion : 'Invalid version number: {{version}}' ,
77 duplicateStabilityNode : 'Duplicate stability node' ,
8+ missingLlmDescription :
9+ 'Missing llm_description field or paragraph node in the API doc entry' ,
810} ;
Original file line number Diff line number Diff line change 33import { duplicateStabilityNodes } from './duplicate-stability-nodes.mjs' ;
44import { invalidChangeVersion } from './invalid-change-version.mjs' ;
55import { missingIntroducedIn } from './missing-introduced-in.mjs' ;
6+ import { missingLlmDescription } from './missing-llm-description.mjs' ;
67
78/**
89 * @type {Record<string, import('../types').LintRule> }
@@ -11,4 +12,5 @@ export default {
1112 'duplicate-stability-nodes' : duplicateStabilityNodes ,
1213 'invalid-change-version' : invalidChangeVersion ,
1314 'missing-introduced-in' : missingIntroducedIn ,
15+ 'missing-llm-description' : missingLlmDescription ,
1416} ;
Original file line number Diff line number Diff line change 1+ import { LINT_MESSAGES } from '../constants.mjs' ;
2+
3+ /**
4+ * Checks if a top-level entry is missing a llm_description field or a paragraph
5+ * node.
6+ *
7+ * @param {ApiDocMetadataEntry[] } entries
8+ * @returns {Array<import('../types.d.ts').LintIssue> }
9+ */
10+ export const missingLlmDescription = entries => {
11+ const issues = [ ] ;
12+
13+ for ( const entry of entries ) {
14+ if ( entry . heading . depth !== 1 || entry . llm_description ) {
15+ continue ;
16+ }
17+
18+ const descriptionNode = entry . content . children . find (
19+ child => child . type === 'paragraph'
20+ ) ;
21+
22+ if ( ! descriptionNode ) {
23+ issues . push ( {
24+ level : 'warn' ,
25+ message : LINT_MESSAGES . missingLlmDescription ,
26+ location : {
27+ path : entry . api_doc_source ,
28+ } ,
29+ } ) ;
30+ }
31+ }
32+
33+ return issues ;
34+ } ;
You can’t perform that action at this time.
0 commit comments