@shepherdjerred/helm-types 1.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -0
- package/LICENSE +674 -0
- package/README.md +82 -63
- package/demos/argo-cd-cli.cast +50 -0
- package/demos/record-cli-demo.sh +132 -0
- package/dist/chart-fetcher.d.ts +14 -0
- package/dist/chart-fetcher.d.ts.map +1 -0
- package/dist/chart-fetcher.js +105 -0
- package/dist/chart-fetcher.js.map +1 -0
- package/dist/chart-info-parser.d.ts +6 -0
- package/dist/chart-info-parser.d.ts.map +1 -0
- package/dist/chart-info-parser.js +50 -0
- package/dist/chart-info-parser.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +140 -22841
- package/dist/cli.js.map +1 -0
- package/dist/comment-parser.d.ts +10 -0
- package/dist/comment-parser.d.ts.map +1 -0
- package/dist/comment-parser.js +150 -0
- package/dist/comment-parser.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +169 -0
- package/dist/config.js.map +1 -0
- package/dist/helm-types.d.ts +16 -0
- package/dist/helm-types.d.ts.map +1 -0
- package/{src/helm-types.ts → dist/helm-types.js} +1 -1
- package/dist/helm-types.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -23
- package/dist/index.js.map +1 -0
- package/dist/interface-generator.d.ts +6 -0
- package/dist/interface-generator.d.ts.map +1 -0
- package/dist/interface-generator.js +181 -0
- package/dist/interface-generator.js.map +1 -0
- package/dist/schemas.d.ts +13 -0
- package/dist/schemas.d.ts.map +1 -0
- package/{src/schemas.ts → dist/schemas.js} +12 -23
- package/dist/schemas.js.map +1 -0
- package/dist/type-converter-helpers.d.ts +20 -0
- package/dist/type-converter-helpers.d.ts.map +1 -0
- package/dist/type-converter-helpers.js +75 -0
- package/dist/type-converter-helpers.js.map +1 -0
- package/dist/type-converter.d.ts +26 -0
- package/dist/type-converter.d.ts.map +1 -0
- package/dist/type-converter.js +378 -0
- package/dist/type-converter.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +69 -0
- package/dist/utils.js.map +1 -0
- package/dist/yaml-comment-filters.d.ts +7 -0
- package/dist/yaml-comment-filters.d.ts.map +1 -0
- package/dist/yaml-comment-filters.js +91 -0
- package/dist/yaml-comment-filters.js.map +1 -0
- package/dist/yaml-comment-regex-parser.d.ts +8 -0
- package/dist/yaml-comment-regex-parser.d.ts.map +1 -0
- package/dist/yaml-comment-regex-parser.js +120 -0
- package/dist/yaml-comment-regex-parser.js.map +1 -0
- package/dist/yaml-comments.d.ts +74 -0
- package/dist/yaml-comments.d.ts.map +1 -0
- package/dist/yaml-comments.js +406 -0
- package/dist/yaml-comments.js.map +1 -0
- package/dist/yaml-preprocess.d.ts +15 -0
- package/dist/yaml-preprocess.d.ts.map +1 -0
- package/dist/yaml-preprocess.js +170 -0
- package/dist/yaml-preprocess.js.map +1 -0
- package/examples/argo-cd/generate.mjs +23 -0
- package/package.json +17 -12
- package/src/__fixtures__/sample-chart/Chart.yaml +0 -6
- package/src/__fixtures__/sample-chart/values.schema.json +0 -32
- package/src/__fixtures__/sample-chart/values.yaml +0 -22
- package/src/chart-fetcher.ts +0 -221
- package/src/chart-info-parser.ts +0 -64
- package/src/cli.ts +0 -217
- package/src/code-generator.ts +0 -226
- package/src/comment-parser.ts +0 -180
- package/src/config.ts +0 -195
- package/src/index.ts +0 -28
- package/src/interface-generator.ts +0 -238
- package/src/reset.d.ts +0 -1
- package/src/type-converter-helpers.ts +0 -108
- package/src/type-converter.ts +0 -520
- package/src/type-inference.ts +0 -548
- package/src/types.ts +0 -41
- package/src/utils.ts +0 -76
- package/src/yaml-comment-filters.ts +0 -103
- package/src/yaml-comment-regex-parser.ts +0 -150
- package/src/yaml-comments.ts +0 -507
- package/src/yaml-preprocess.ts +0 -235
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex-based fallback parser for comments that the YAML AST loses
|
|
3
|
+
* This handles cases with commented-out YAML keys and inconsistent indentation
|
|
4
|
+
* Returns comments with metadata for debugging
|
|
5
|
+
*/
|
|
6
|
+
export function parseCommentsWithRegex(yamlContent) {
|
|
7
|
+
const comments = new Map();
|
|
8
|
+
const lines = yamlContent.split("\n");
|
|
9
|
+
let pendingComment = [];
|
|
10
|
+
let pendingCommentIndent = -1;
|
|
11
|
+
let pendingDebugInfo = [];
|
|
12
|
+
lines.forEach((line, lineNum) => {
|
|
13
|
+
const trimmed = line.trim();
|
|
14
|
+
// Skip empty lines - blank lines reset pending comments
|
|
15
|
+
// This ensures comments for commented-out keys don't leak to next real key
|
|
16
|
+
if (!trimmed) {
|
|
17
|
+
// Only reset if we had a commented-out key (pendingCommentIndent === -1)
|
|
18
|
+
// This allows multi-line comments for real keys to work
|
|
19
|
+
if (pendingCommentIndent === -1 && pendingComment.length > 0) {
|
|
20
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: Blank line after commented-out key, resetting pending`);
|
|
21
|
+
pendingComment = [];
|
|
22
|
+
pendingDebugInfo = [];
|
|
23
|
+
}
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Check if this is a comment line
|
|
27
|
+
if (trimmed.startsWith("#")) {
|
|
28
|
+
// Extract comment text (handle multiple # characters)
|
|
29
|
+
let commentText = trimmed;
|
|
30
|
+
while (commentText.startsWith("#")) {
|
|
31
|
+
commentText = commentText.slice(1);
|
|
32
|
+
}
|
|
33
|
+
commentText = commentText.trim();
|
|
34
|
+
// Skip commented-out YAML keys (these are not documentation)
|
|
35
|
+
// Match patterns like "key: value" or "key:" but NOT prose-like text
|
|
36
|
+
// This includes quoted values like: key: "value"
|
|
37
|
+
const looksLikeYAMLKeyLocal = /^[\w.-]+:\s*(?:\||$|[\w.-]+$|"[^"]*"$|'[^']*'$|[[{])/.test(commentText);
|
|
38
|
+
if (looksLikeYAMLKeyLocal) {
|
|
39
|
+
// This is a commented-out YAML key, which means the pending comments
|
|
40
|
+
// were describing this commented-out section, not a future real key
|
|
41
|
+
// So we should discard them
|
|
42
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: Commented-out YAML key detected: "${commentText}", discarding pending`);
|
|
43
|
+
pendingComment = [];
|
|
44
|
+
pendingCommentIndent = -1;
|
|
45
|
+
pendingDebugInfo = [];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const commentIndent = line.search(/\S/);
|
|
49
|
+
// If we just discarded comments (indent === -1), this is a fresh start
|
|
50
|
+
if (pendingCommentIndent === -1) {
|
|
51
|
+
pendingComment = [commentText];
|
|
52
|
+
pendingCommentIndent = commentIndent;
|
|
53
|
+
pendingDebugInfo = [
|
|
54
|
+
`Line ${String(lineNum)}: Fresh start (indent=${String(commentIndent)}): "${commentText}"`,
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
else if (commentIndent === pendingCommentIndent ||
|
|
58
|
+
Math.abs(commentIndent - pendingCommentIndent) <= 2) {
|
|
59
|
+
// Same indent level, add to pending
|
|
60
|
+
pendingComment.push(commentText);
|
|
61
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: Continuing (indent=${String(commentIndent)}): "${commentText}"`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Different indent, reset
|
|
65
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: Different indent (${String(commentIndent)} vs ${String(pendingCommentIndent)}), resetting`);
|
|
66
|
+
pendingComment = [commentText];
|
|
67
|
+
pendingCommentIndent = commentIndent;
|
|
68
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: New start: "${commentText}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Check if this is a YAML key line
|
|
74
|
+
const keyMatchRegex = /^([\w.-]+):\s/;
|
|
75
|
+
const keyMatch = keyMatchRegex.exec(trimmed);
|
|
76
|
+
if (keyMatch && pendingComment.length > 0) {
|
|
77
|
+
const key = keyMatch[1];
|
|
78
|
+
if (key !== "" && key != null) {
|
|
79
|
+
const keyIndent = line.search(/\S/);
|
|
80
|
+
// Only associate comment if indentation matches closely
|
|
81
|
+
// Allow 2 space difference (for comment being indented slightly different)
|
|
82
|
+
if (pendingCommentIndent === -1 ||
|
|
83
|
+
Math.abs(keyIndent - pendingCommentIndent) <= 2) {
|
|
84
|
+
const commentText = pendingComment.join("\n");
|
|
85
|
+
const debugInfo = [
|
|
86
|
+
...pendingDebugInfo,
|
|
87
|
+
`Line ${String(lineNum)}: Associating with key "${key}"`,
|
|
88
|
+
].join("\n");
|
|
89
|
+
comments.set(key, {
|
|
90
|
+
text: commentText,
|
|
91
|
+
metadata: {
|
|
92
|
+
source: "REGEX",
|
|
93
|
+
rawComment: commentText,
|
|
94
|
+
indent: keyIndent,
|
|
95
|
+
debugInfo,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: Skipping key "${key}" due to indent mismatch (${String(keyIndent)} vs ${String(pendingCommentIndent)})`);
|
|
101
|
+
}
|
|
102
|
+
// Reset for next key
|
|
103
|
+
pendingComment = [];
|
|
104
|
+
pendingCommentIndent = -1;
|
|
105
|
+
pendingDebugInfo = [];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (!trimmed.startsWith("#")) {
|
|
109
|
+
// Non-comment, non-key line - reset pending comment
|
|
110
|
+
if (pendingComment.length > 0) {
|
|
111
|
+
pendingDebugInfo.push(`Line ${String(lineNum)}: Non-comment/non-key line, resetting pending`);
|
|
112
|
+
}
|
|
113
|
+
pendingComment = [];
|
|
114
|
+
pendingCommentIndent = -1;
|
|
115
|
+
pendingDebugInfo = [];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return comments;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=yaml-comment-regex-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-comment-regex-parser.js","sourceRoot":"","sources":["../src/yaml-comment-regex-parser.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;IACxD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,cAAc,GAAa,EAAE,CAAC;IAClC,IAAI,oBAAoB,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,gBAAgB,GAAa,EAAE,CAAC;IAEpC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAE5B,wDAAwD;QACxD,2EAA2E;QAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,yEAAyE;YACzE,wDAAwD;YACxD,IAAI,oBAAoB,KAAK,CAAC,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7D,gBAAgB,CAAC,IAAI,CACnB,QAAQ,MAAM,CAAC,OAAO,CAAC,yDAAyD,CACjF,CAAC;gBACF,cAAc,GAAG,EAAE,CAAC;gBACpB,gBAAgB,GAAG,EAAE,CAAC;YACxB,CAAC;YACD,OAAO;QACT,CAAC;QAED,kCAAkC;QAClC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,sDAAsD;YACtD,IAAI,WAAW,GAAG,OAAO,CAAC;YAC1B,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnC,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AE,OAAO;4BACf,UAAU,EAAE,WAAW;4BACvB,MAAM,EAAE,SAAS;4BACjB,SAAS;yBACV;qBACF,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,gBAAgB,CAAC,IAAI,CACnB,QAAQ,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,6BAA6B,MAAM,CAAC,SAAS,CAAC,OAAO,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAClI,CAAC;gBACJ,CAAC;gBAED,qBAAqB;gBACrB,cAAc,GAAG,EAAE,CAAC;gBACpB,oBAAoB,GAAG,CAAC,CAAC,CAAC;gBAC1B,gBAAgB,GAAG,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,oDAAoD;YACpD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,gBAAgB,CAAC,IAAI,CACnB,QAAQ,MAAM,CAAC,OAAO,CAAC,+CAA+C,CACvE,CAAC;YACJ,CAAC;YACD,cAAc,GAAG,EAAE,CAAC;YACpB,oBAAoB,GAAG,CAAC,CAAC,CAAC;YAC1B,gBAAgB,GAAG,EAAE,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata about how a comment was extracted
|
|
3
|
+
*/
|
|
4
|
+
export type CommentMetadata = {
|
|
5
|
+
source: "AST" | "REGEX";
|
|
6
|
+
rawComment?: string;
|
|
7
|
+
indent?: number;
|
|
8
|
+
debugInfo?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Comment with metadata for debugging
|
|
12
|
+
*/
|
|
13
|
+
export type CommentWithMetadata = {
|
|
14
|
+
text: string;
|
|
15
|
+
metadata: CommentMetadata;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Helper: Check if a line looks like a YAML key (e.g., "key: value" or "key:")
|
|
19
|
+
* Exported for testing purposes
|
|
20
|
+
*/
|
|
21
|
+
export declare function isYAMLKey(line: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Helper: Check if a line looks like a simple YAML value assignment
|
|
24
|
+
* Exported for testing purposes
|
|
25
|
+
*/
|
|
26
|
+
export declare function isSimpleYAMLValue(line: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Helper: Check if a line is a section header (short line followed by YAML config)
|
|
29
|
+
* Exported for testing purposes
|
|
30
|
+
*/
|
|
31
|
+
export declare function isSectionHeader(line: string, nextLine?: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Helper: Check if a line looks like code/YAML example
|
|
34
|
+
* Exported for testing purposes
|
|
35
|
+
*/
|
|
36
|
+
export declare function isCodeExample(line: string, wordCount: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Helper: Check if a line looks like prose (real documentation)
|
|
39
|
+
* Exported for testing purposes
|
|
40
|
+
*/
|
|
41
|
+
export declare function looksLikeProse(line: string, wordCount: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Helper: Normalize a comment line by removing markers
|
|
44
|
+
* Exported for testing purposes
|
|
45
|
+
*/
|
|
46
|
+
export declare function normalizeCommentLine(line: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Clean up YAML comment text for use in JSDoc
|
|
49
|
+
* Removes Helm-specific markers and filters out code examples and section headers
|
|
50
|
+
*/
|
|
51
|
+
export declare function cleanYAMLComment(comment: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Parse Bitnami-style @param directives from a comment
|
|
54
|
+
* Format: @param key.path Description
|
|
55
|
+
* Returns: Map of extracted params and remaining non-param lines
|
|
56
|
+
* Exported for testing purposes
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseBitnamiParams(comment: string): {
|
|
59
|
+
params: Map<string, string>;
|
|
60
|
+
remainingLines: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Parse YAML comments with metadata for debugging
|
|
64
|
+
* Returns comments with information about how they were extracted
|
|
65
|
+
* Exported for testing purposes
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseYAMLCommentsWithMetadata(yamlContent: string): Map<string, CommentWithMetadata>;
|
|
68
|
+
/**
|
|
69
|
+
* Parse YAML comments and associate them with keys
|
|
70
|
+
* Returns a simple Map<string, string> for backward compatibility
|
|
71
|
+
* Exported for testing purposes
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseYAMLComments(yamlContent: string): Map<string, string>;
|
|
74
|
+
//# sourceMappingURL=yaml-comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-comments.d.ts","sourceRoot":"","sources":["../src/yaml-comments.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAiCxE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CA0BtE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAsBvE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2ExD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG;IACnD,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CA4BA;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,GAClB,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAiNlC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAS1E"}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { parseDocument } from "yaml";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { filterCommentedOutYAML } from "./yaml-comment-filters.js";
|
|
4
|
+
import { parseCommentsWithRegex } from "./yaml-comment-regex-parser.js";
|
|
5
|
+
import { preprocessYAMLComments } from "./yaml-preprocess.js";
|
|
6
|
+
/**
|
|
7
|
+
* Helper: Check if a line looks like a YAML key (e.g., "key: value" or "key:")
|
|
8
|
+
* Exported for testing purposes
|
|
9
|
+
*/
|
|
10
|
+
export function isYAMLKey(line) {
|
|
11
|
+
return /^[\w.-]+:\s*(?:\||$)/.test(line);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Helper: Check if a line looks like a simple YAML value assignment
|
|
15
|
+
* Exported for testing purposes
|
|
16
|
+
*/
|
|
17
|
+
export function isSimpleYAMLValue(line) {
|
|
18
|
+
const hasURL = line.includes("http://") || line.includes("https://");
|
|
19
|
+
const isRef = /^ref:/i.test(line);
|
|
20
|
+
return /^[\w.-]+:\s[^:]+$/.test(line) && !hasURL && !isRef;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Helper: Check if a line is a section header (short line followed by YAML config)
|
|
24
|
+
* Exported for testing purposes
|
|
25
|
+
*/
|
|
26
|
+
export function isSectionHeader(line, nextLine) {
|
|
27
|
+
if (nextLine === "" || nextLine == null) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const isFollowedByYAMLKey = /^[\w.-]+:\s*\|/.test(nextLine) ||
|
|
31
|
+
/^[\w.-]+:\s*$/.test(nextLine) ||
|
|
32
|
+
/^[\w.-]+:\s+/.test(nextLine);
|
|
33
|
+
if (!isFollowedByYAMLKey) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const wordCount = line.split(/\s+/).length;
|
|
37
|
+
const hasConfigKeywords = /\b(?:configuration|config|example|setup|settings?|options?|alternative)\b/i.test(line);
|
|
38
|
+
const endsWithPunctuation = /[.!?]$/.test(line);
|
|
39
|
+
const hasURL = line.includes("http://") || line.includes("https://");
|
|
40
|
+
const startsWithArticle = /^(?:This|The|A|An)\s/i.test(line);
|
|
41
|
+
const startsWithCommonWord = /^(?:This|The|A|An|It|For|To|If|When|You|We|Use|Configure)\s/i.test(line);
|
|
42
|
+
return (((wordCount === 2 && !startsWithCommonWord) ||
|
|
43
|
+
(hasConfigKeywords && !startsWithCommonWord)) &&
|
|
44
|
+
!endsWithPunctuation &&
|
|
45
|
+
!hasURL &&
|
|
46
|
+
!/^ref:/i.test(line) &&
|
|
47
|
+
!startsWithArticle);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Helper: Check if a line looks like code/YAML example
|
|
51
|
+
* Exported for testing purposes
|
|
52
|
+
*/
|
|
53
|
+
export function isCodeExample(line, wordCount) {
|
|
54
|
+
const looksLikeYAMLKey = isYAMLKey(line);
|
|
55
|
+
const looksLikeSimpleYAMLValue = isSimpleYAMLValue(line);
|
|
56
|
+
const looksLikeYAMLList = line.startsWith("-") && (line.includes(":") || /^-\s+\|/.test(line));
|
|
57
|
+
const looksLikePolicyRule = /^[pg],\s*/.test(line);
|
|
58
|
+
const hasIndentation = /^\s{2,}/.test(line);
|
|
59
|
+
const looksLikeCommand = /^echo\s+/.test(line) ||
|
|
60
|
+
line.includes("$ARGOCD_") ||
|
|
61
|
+
line.includes("$KUBE_");
|
|
62
|
+
const isSeparator = /^-{3,}/.test(line) ||
|
|
63
|
+
/^BEGIN .*(?:KEY|CERTIFICATE)/.test(line) ||
|
|
64
|
+
/^END .*(?:KEY|CERTIFICATE)/.test(line);
|
|
65
|
+
return (isSeparator ||
|
|
66
|
+
looksLikeYAMLKey ||
|
|
67
|
+
(looksLikeSimpleYAMLValue && wordCount <= 4) ||
|
|
68
|
+
looksLikeYAMLList ||
|
|
69
|
+
looksLikePolicyRule ||
|
|
70
|
+
hasIndentation ||
|
|
71
|
+
looksLikeCommand ||
|
|
72
|
+
line.startsWith("|"));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Helper: Check if a line looks like prose (real documentation)
|
|
76
|
+
* Exported for testing purposes
|
|
77
|
+
*/
|
|
78
|
+
export function looksLikeProse(line, wordCount) {
|
|
79
|
+
const hasURL = line.includes("http://") || line.includes("https://");
|
|
80
|
+
const startsWithCapital = /^[A-Z]/.test(line);
|
|
81
|
+
const hasEndPunctuation = /[.!?:]$/.test(line);
|
|
82
|
+
const notYamlKey = !(!hasURL && isYAMLKey(line) && !/^ref:/i.test(line));
|
|
83
|
+
const reasonableLength = line.length > 10;
|
|
84
|
+
const hasMultipleWords = wordCount >= 3;
|
|
85
|
+
const startsWithArticle = /^(?:This|The|A|An)\s/i.test(line);
|
|
86
|
+
// Lines starting with markers like ^, ->, etc. are documentation references
|
|
87
|
+
const isReferenceMarker = /^(?:\^|->|→)\s/.test(line);
|
|
88
|
+
return ((startsWithCapital || isReferenceMarker) &&
|
|
89
|
+
(hasEndPunctuation ||
|
|
90
|
+
hasURL ||
|
|
91
|
+
startsWithArticle ||
|
|
92
|
+
hasMultipleWords ||
|
|
93
|
+
isReferenceMarker) &&
|
|
94
|
+
notYamlKey &&
|
|
95
|
+
reasonableLength);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Helper: Normalize a comment line by removing markers
|
|
99
|
+
* Exported for testing purposes
|
|
100
|
+
*/
|
|
101
|
+
export function normalizeCommentLine(line) {
|
|
102
|
+
let normalized = line.trim();
|
|
103
|
+
normalized = normalized.replace(/^#+\s*/, ""); // Remove leading # symbols
|
|
104
|
+
normalized = normalized.replace(/^--\s*/, ""); // Remove Helm's -- marker
|
|
105
|
+
normalized = normalized.replace(/^@param\s+[\w.-]+\s+/, ""); // Remove Bitnami's @param prefix
|
|
106
|
+
normalized = normalized.replace(/^@section\s+/, ""); // Remove Bitnami's @section prefix
|
|
107
|
+
return normalized.trim();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Clean up YAML comment text for use in JSDoc
|
|
111
|
+
* Removes Helm-specific markers and filters out code examples and section headers
|
|
112
|
+
*/
|
|
113
|
+
export function cleanYAMLComment(comment) {
|
|
114
|
+
if (!comment) {
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
// Normalize all lines
|
|
118
|
+
const lines = comment.split("\n").map((line) => normalizeCommentLine(line));
|
|
119
|
+
// Filter out code examples and section headers, keep documentation
|
|
120
|
+
const cleaned = [];
|
|
121
|
+
let inCodeBlock = false;
|
|
122
|
+
let inExample = false; // Track if we're in an "Example:" section (keep these!)
|
|
123
|
+
for (let i = 0; i < lines.length; i++) {
|
|
124
|
+
const line = lines[i] ?? "";
|
|
125
|
+
// Empty lines end code blocks (but not examples)
|
|
126
|
+
if (!line) {
|
|
127
|
+
if (inCodeBlock && !inExample) {
|
|
128
|
+
inCodeBlock = false;
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
// Skip @default lines (we'll generate our own)
|
|
133
|
+
if (line.startsWith("@default")) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
// Check if this line starts an Example section (preserve these!)
|
|
137
|
+
if (/^Example:?$/i.test(line.trim())) {
|
|
138
|
+
inExample = true;
|
|
139
|
+
inCodeBlock = true; // Treat examples as special code blocks
|
|
140
|
+
cleaned.push(line);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const nextLine = lines[i + 1];
|
|
144
|
+
const wordCount = line.split(/\s+/).length;
|
|
145
|
+
// Skip section headers
|
|
146
|
+
if (isSectionHeader(line, nextLine)) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
// If we're in an example section, keep all lines (including code)
|
|
150
|
+
if (inExample) {
|
|
151
|
+
cleaned.push(line);
|
|
152
|
+
// Check if we're exiting the example section
|
|
153
|
+
if (line.startsWith("For more information") || line.startsWith("Ref:")) {
|
|
154
|
+
inExample = false;
|
|
155
|
+
inCodeBlock = false;
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// Check if this line is a code example
|
|
160
|
+
if (isCodeExample(line, wordCount)) {
|
|
161
|
+
inCodeBlock = true;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
// Resume prose when we hit a proper sentence
|
|
165
|
+
if (inCodeBlock) {
|
|
166
|
+
if (looksLikeProse(line, wordCount)) {
|
|
167
|
+
inCodeBlock = false;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
cleaned.push(line);
|
|
174
|
+
}
|
|
175
|
+
return cleaned.join("\n").trim();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Parse Bitnami-style @param directives from a comment
|
|
179
|
+
* Format: @param key.path Description
|
|
180
|
+
* Returns: Map of extracted params and remaining non-param lines
|
|
181
|
+
* Exported for testing purposes
|
|
182
|
+
*/
|
|
183
|
+
export function parseBitnamiParams(comment) {
|
|
184
|
+
const lines = comment.split("\n");
|
|
185
|
+
const params = new Map();
|
|
186
|
+
const remainingLines = [];
|
|
187
|
+
for (const line of lines) {
|
|
188
|
+
const trimmedLine = line
|
|
189
|
+
.trim()
|
|
190
|
+
.replace(/^#+\s*/, "")
|
|
191
|
+
.replace(/^--\s*/, "");
|
|
192
|
+
const paramMatch = /^@param\s+([\w.-]+)\s+(\S.*)$/.exec(trimmedLine);
|
|
193
|
+
if (paramMatch) {
|
|
194
|
+
const [, paramKey, description] = paramMatch;
|
|
195
|
+
if (paramKey !== "" &&
|
|
196
|
+
description !== "" &&
|
|
197
|
+
paramKey != null &&
|
|
198
|
+
description != null) {
|
|
199
|
+
params.set(paramKey, description);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (trimmedLine) {
|
|
203
|
+
remainingLines.push(trimmedLine);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return { params, remainingLines };
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Parse YAML comments with metadata for debugging
|
|
210
|
+
* Returns comments with information about how they were extracted
|
|
211
|
+
* Exported for testing purposes
|
|
212
|
+
*/
|
|
213
|
+
export function parseYAMLCommentsWithMetadata(yamlContent) {
|
|
214
|
+
const comments = new Map();
|
|
215
|
+
try {
|
|
216
|
+
// Pre-process to uncomment commented-out keys
|
|
217
|
+
// This allows Helm chart commented-out options to be parsed as real keys
|
|
218
|
+
const preprocessedYaml = preprocessYAMLComments(yamlContent);
|
|
219
|
+
const doc = parseDocument(preprocessedYaml);
|
|
220
|
+
// Build a regex-based fallback map for cases where YAML parser loses comments
|
|
221
|
+
// Use preprocessed YAML so commented-out keys are treated as real keys
|
|
222
|
+
const regexComments = parseCommentsWithRegex(preprocessedYaml);
|
|
223
|
+
// Zod schemas for YAML AST parsing, defined once
|
|
224
|
+
const MapNodeSchema = z.object({
|
|
225
|
+
items: z.array(z.unknown()),
|
|
226
|
+
commentBefore: z.unknown().optional(),
|
|
227
|
+
});
|
|
228
|
+
const PairSchema = z.object({ key: z.unknown(), value: z.unknown() });
|
|
229
|
+
const KeyValueSchema = z.object({ value: z.string() });
|
|
230
|
+
const CommentBeforeSchema = z.object({ commentBefore: z.unknown() });
|
|
231
|
+
const InlineCommentSchema = z.object({ comment: z.unknown() });
|
|
232
|
+
/**
|
|
233
|
+
* Extract the commentBefore string from a YAML node
|
|
234
|
+
*/
|
|
235
|
+
function extractCommentBefore(node) {
|
|
236
|
+
const check = CommentBeforeSchema.safeParse(node);
|
|
237
|
+
if (!check.success) {
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
const strCheck = z.string().safeParse(check.data.commentBefore);
|
|
241
|
+
return strCheck.success ? strCheck.data : "";
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Extract the inline comment string from a YAML value node
|
|
245
|
+
*/
|
|
246
|
+
function extractInlineComment(node) {
|
|
247
|
+
const check = InlineCommentSchema.safeParse(node);
|
|
248
|
+
if (!check.success) {
|
|
249
|
+
return "";
|
|
250
|
+
}
|
|
251
|
+
const strCheck = z.string().safeParse(check.data.comment);
|
|
252
|
+
return strCheck.success ? strCheck.data : "";
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Collect all comment sources for a YAML pair (key comment, pair comment, inline comment)
|
|
256
|
+
*/
|
|
257
|
+
function collectItemComment(pairData, context) {
|
|
258
|
+
let comment = extractCommentBefore(pairData.keyNode);
|
|
259
|
+
const pairComment = extractCommentBefore(pairData.item);
|
|
260
|
+
if (pairComment) {
|
|
261
|
+
comment = comment ? `${pairComment}\n${comment}` : pairComment;
|
|
262
|
+
}
|
|
263
|
+
const inlineComment = extractInlineComment(pairData.valueNode);
|
|
264
|
+
if (inlineComment) {
|
|
265
|
+
comment = comment ? `${comment}\n${inlineComment}` : inlineComment;
|
|
266
|
+
}
|
|
267
|
+
// First item inherits map comment if it has none
|
|
268
|
+
if (!comment && context.index === 0 && context.mapComment) {
|
|
269
|
+
comment = context.mapComment;
|
|
270
|
+
}
|
|
271
|
+
if (comment) {
|
|
272
|
+
comment = filterCommentedOutYAML(comment);
|
|
273
|
+
}
|
|
274
|
+
return comment;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Store a comment (with @param handling) into the comments map
|
|
278
|
+
*/
|
|
279
|
+
function storeComment(comment, fullKey) {
|
|
280
|
+
const hasParamDirective = comment.includes("@param ");
|
|
281
|
+
if (hasParamDirective) {
|
|
282
|
+
const { params, remainingLines } = parseBitnamiParams(comment);
|
|
283
|
+
for (const [paramKey, description] of params.entries()) {
|
|
284
|
+
comments.set(paramKey, {
|
|
285
|
+
text: description,
|
|
286
|
+
metadata: {
|
|
287
|
+
source: "AST",
|
|
288
|
+
rawComment: comment,
|
|
289
|
+
debugInfo: `Bitnami @param directive for ${paramKey}`,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
const remainingCleaned = remainingLines.length > 0
|
|
294
|
+
? cleanYAMLComment(remainingLines.join("\n"))
|
|
295
|
+
: "";
|
|
296
|
+
if (remainingCleaned) {
|
|
297
|
+
comments.set(fullKey, {
|
|
298
|
+
text: remainingCleaned,
|
|
299
|
+
metadata: {
|
|
300
|
+
source: "AST",
|
|
301
|
+
rawComment: comment,
|
|
302
|
+
debugInfo: `AST comment after extracting @param directives`,
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else if (comment) {
|
|
308
|
+
const cleaned = cleanYAMLComment(comment);
|
|
309
|
+
if (cleaned) {
|
|
310
|
+
comments.set(fullKey, {
|
|
311
|
+
text: cleaned,
|
|
312
|
+
metadata: {
|
|
313
|
+
source: "AST",
|
|
314
|
+
rawComment: comment,
|
|
315
|
+
debugInfo: `Direct AST comment for ${fullKey}`,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// Recursively walk the YAML AST and extract comments
|
|
322
|
+
function visitNode(node, keyPath = [], inheritedComment = "") {
|
|
323
|
+
if (node == null) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const mapNodeCheck = MapNodeSchema.safeParse(node);
|
|
327
|
+
if (!mapNodeCheck.success) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
// Extract the map's own comment (to be inherited by first child if needed)
|
|
331
|
+
let mapComment = inheritedComment;
|
|
332
|
+
const mapCommentCheck = z
|
|
333
|
+
.string()
|
|
334
|
+
.safeParse(mapNodeCheck.data.commentBefore);
|
|
335
|
+
if (mapCommentCheck.success) {
|
|
336
|
+
mapComment = mapCommentCheck.data;
|
|
337
|
+
}
|
|
338
|
+
for (let i = 0; i < mapNodeCheck.data.items.length; i++) {
|
|
339
|
+
const item = mapNodeCheck.data.items[i];
|
|
340
|
+
const itemCheck = PairSchema.safeParse(item);
|
|
341
|
+
if (!itemCheck.success) {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const keyNodeCheck = KeyValueSchema.safeParse(itemCheck.data.key);
|
|
345
|
+
if (!keyNodeCheck.success) {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
const key = keyNodeCheck.data.value;
|
|
349
|
+
const newPath = [...keyPath, key];
|
|
350
|
+
const fullKey = newPath.join(".");
|
|
351
|
+
const comment = collectItemComment({
|
|
352
|
+
keyNode: itemCheck.data.key,
|
|
353
|
+
item,
|
|
354
|
+
valueNode: itemCheck.data.value,
|
|
355
|
+
}, { index: i, mapComment });
|
|
356
|
+
storeComment(comment, fullKey);
|
|
357
|
+
const valueInheritedComment = extractCommentBefore(itemCheck.data.value);
|
|
358
|
+
if (itemCheck.data.value != null) {
|
|
359
|
+
visitNode(itemCheck.data.value, newPath, valueInheritedComment);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// Start with the document contents
|
|
364
|
+
if (doc.contents) {
|
|
365
|
+
visitNode(doc.contents, []);
|
|
366
|
+
}
|
|
367
|
+
// Merge regex comments as fallback - only use them if AST parsing didn't find a comment
|
|
368
|
+
// This handles cases where YAML parser loses comments due to:
|
|
369
|
+
// - Inconsistent indentation
|
|
370
|
+
// - Commented-out YAML keys mixed with documentation
|
|
371
|
+
// - Other edge cases
|
|
372
|
+
for (const [key, commentWithMeta] of regexComments.entries()) {
|
|
373
|
+
if (!comments.has(key)) {
|
|
374
|
+
const cleaned = cleanYAMLComment(commentWithMeta.text);
|
|
375
|
+
if (cleaned) {
|
|
376
|
+
comments.set(key, {
|
|
377
|
+
text: cleaned,
|
|
378
|
+
metadata: {
|
|
379
|
+
...commentWithMeta.metadata,
|
|
380
|
+
debugInfo: `${commentWithMeta.metadata.debugInfo ?? ""}\nCleaned from: "${commentWithMeta.text}"`,
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
// If YAML parsing fails, fall back to empty map
|
|
389
|
+
console.warn("Failed to parse YAML comments:", error);
|
|
390
|
+
}
|
|
391
|
+
return comments;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Parse YAML comments and associate them with keys
|
|
395
|
+
* Returns a simple Map<string, string> for backward compatibility
|
|
396
|
+
* Exported for testing purposes
|
|
397
|
+
*/
|
|
398
|
+
export function parseYAMLComments(yamlContent) {
|
|
399
|
+
const commentsWithMetadata = parseYAMLCommentsWithMetadata(yamlContent);
|
|
400
|
+
const simpleComments = new Map();
|
|
401
|
+
for (const [key, commentWithMeta] of commentsWithMetadata.entries()) {
|
|
402
|
+
simpleComments.set(key, commentWithMeta.text);
|
|
403
|
+
}
|
|
404
|
+
return simpleComments;
|
|
405
|
+
}
|
|
406
|
+
//# sourceMappingURL=yaml-comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-comments.js","sourceRoot":"","sources":["../src/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,GAAG,CAAC,EAAE,CAAC;gBACvB,MAAM,OAAO,GAAG,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBACvD,IAAI,OAAO,EAAE,CAAC;oBACZ,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE;wBAChB,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE;4BACR,GAAG,eAAe,CAAC,QAAQ;4BAC3B,SAAS,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,oBAAoB,eAAe,CAAC,IAAI,GAAG;yBAClG;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gDAAgD;QAChD,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,MAAM,oBAAoB,GAAG,6BAA6B,CAAC,WAAW,CAAC,CAAC;IACxE,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEjD,KAAK,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,IAAI,oBAAoB,CAAC,OAAO,EAAE,EAAE,CAAC;QACpE,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-process YAML to uncomment commented-out keys
|
|
3
|
+
* In Helm charts, commented-out keys are documentation of available options
|
|
4
|
+
* e.g., "## key: value" or "# key: value"
|
|
5
|
+
*
|
|
6
|
+
* This allows us to parse them as real keys and associate their comments
|
|
7
|
+
*
|
|
8
|
+
* Only uncomments keys that are:
|
|
9
|
+
* - At root level or similar indentation to real keys
|
|
10
|
+
* - Not part of "Example:" blocks
|
|
11
|
+
* - Not part of documentation prose (have their own dedicated comment block)
|
|
12
|
+
* - Not deeply nested (which would indicate example YAML)
|
|
13
|
+
*/
|
|
14
|
+
export declare function preprocessYAMLComments(yamlContent: string): string;
|
|
15
|
+
//# sourceMappingURL=yaml-preprocess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-preprocess.d.ts","sourceRoot":"","sources":["../src/yaml-preprocess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA4JH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAkElE"}
|