@mui/internal-docs-infra 0.13.1-canary.13 → 0.13.1-canary.15
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/package.json +2 -2
- package/pipeline/enhanceCodeEmphasis/emphasisCommentUtils.mjs +3 -1
- package/pipeline/loaderUtils/normalizeCommentContent.d.mts +5 -0
- package/pipeline/loaderUtils/normalizeCommentContent.mjs +13 -0
- package/pipeline/loaderUtils/parseImportsAndComments.mjs +5 -25
- package/pipeline/syncTypes/generateTypesMarkdown.mjs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.13.1-canary.
|
|
3
|
+
"version": "0.13.1-canary.15",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -813,5 +813,5 @@
|
|
|
813
813
|
"bin": {
|
|
814
814
|
"docs-infra": "./cli/index.mjs"
|
|
815
815
|
},
|
|
816
|
-
"gitSha": "
|
|
816
|
+
"gitSha": "abd0d2ce073f905bfa623ebf593a5d37de499b72"
|
|
817
817
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { normalizeCommentContent } from "../loaderUtils/normalizeCommentContent.mjs";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The prefix used to identify emphasis comments in source code.
|
|
3
5
|
* Comments starting with this prefix will be processed for emphasis.
|
|
@@ -120,7 +122,7 @@ export function getUnquotedCommentTokens(comment) {
|
|
|
120
122
|
* Returns whether a parsed comment contains a real focus directive.
|
|
121
123
|
*/
|
|
122
124
|
export function hasFocusDirective(comment) {
|
|
123
|
-
const tokens = getUnquotedCommentTokens(comment);
|
|
125
|
+
const tokens = getUnquotedCommentTokens(normalizeCommentContent(comment));
|
|
124
126
|
const firstToken = tokens[0];
|
|
125
127
|
if (firstToken === FOCUS_COMMENT_PREFIX || firstToken === `${FOCUS_COMMENT_PREFIX}-start` || firstToken === `${FOCUS_COMMENT_PREFIX}-end`) {
|
|
126
128
|
return true;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes JSDoc decoration from parsed block comment content. Comment delimiters
|
|
3
|
+
* have already been removed by the source parser or ESLint.
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeCommentContent(content) {
|
|
6
|
+
if (!content.trimStart().startsWith('*')) {
|
|
7
|
+
return content;
|
|
8
|
+
}
|
|
9
|
+
return content.split('\n').map(line => {
|
|
10
|
+
const trimmed = line.trimStart();
|
|
11
|
+
return trimmed.startsWith('*') ? trimmed.slice(1).trimStart() : line;
|
|
12
|
+
}).join('\n');
|
|
13
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as path from 'path-module';
|
|
2
|
+
import { normalizeCommentContent } from "./normalizeCommentContent.mjs";
|
|
2
3
|
import { fileUrlToPortablePath, portablePathToFileUrl } from "./fileUrlToPortablePath.mjs";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -66,19 +67,8 @@ function isStringStart(ch, withinMdx) {
|
|
|
66
67
|
* @returns True if the comment starts with any of the specified prefixes
|
|
67
68
|
*/
|
|
68
69
|
function matchesCommentPrefix(commentText, removeCommentsWithPrefix) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (commentText.startsWith('//')) {
|
|
72
|
-
const content = commentText.slice(2).trim();
|
|
73
|
-
return content.startsWith(prefix);
|
|
74
|
-
}
|
|
75
|
-
// For multi-line comments, check after the /*
|
|
76
|
-
if (commentText.startsWith('/*')) {
|
|
77
|
-
const content = commentText.slice(2, -2).trim();
|
|
78
|
-
return content.startsWith(prefix);
|
|
79
|
-
}
|
|
80
|
-
return false;
|
|
81
|
-
});
|
|
70
|
+
const content = stripCommentMarkers(commentText).join('\n');
|
|
71
|
+
return removeCommentsWithPrefix.some(prefix => content.startsWith(prefix));
|
|
82
72
|
}
|
|
83
73
|
|
|
84
74
|
/**
|
|
@@ -93,7 +83,7 @@ function stripCommentMarkers(commentText) {
|
|
|
93
83
|
}
|
|
94
84
|
// For multi-line comments, remove /* and */, split by lines, and trim each line
|
|
95
85
|
if (commentText.startsWith('/*') && commentText.endsWith('*/')) {
|
|
96
|
-
const content = commentText.slice(2, -2);
|
|
86
|
+
const content = normalizeCommentContent(commentText.slice(2, -2));
|
|
97
87
|
return content.split('\n').map(line => line.trim()).filter(line => line !== '');
|
|
98
88
|
}
|
|
99
89
|
// Fallback: return as single-item array if format is unexpected
|
|
@@ -147,17 +137,7 @@ function scanForImports(sourceCode, importDetector, isMdxFile, removeCommentsWit
|
|
|
147
137
|
if (!notableCommentsPrefix || notableCommentsPrefix.length === 0) {
|
|
148
138
|
return false; // If no notable prefix specified, don't match any comments as notable
|
|
149
139
|
}
|
|
150
|
-
return
|
|
151
|
-
if (commentText.startsWith('//')) {
|
|
152
|
-
const content = commentText.slice(2).trim();
|
|
153
|
-
return content.startsWith(prefix);
|
|
154
|
-
}
|
|
155
|
-
if (commentText.startsWith('/*')) {
|
|
156
|
-
const content = commentText.slice(2, -2).trim();
|
|
157
|
-
return content.startsWith(prefix);
|
|
158
|
-
}
|
|
159
|
-
return false;
|
|
160
|
-
});
|
|
140
|
+
return matchesCommentPrefix(commentText, notableCommentsPrefix);
|
|
161
141
|
};
|
|
162
142
|
let i = 0;
|
|
163
143
|
let outputLine = 0; // Line number in output code after comment removal
|
|
@@ -393,7 +393,7 @@ export async function generateTypesMarkdown(options) {
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
} else if (typeMeta.type === 'function') {
|
|
396
|
-
const part = typeMeta.
|
|
396
|
+
const part = typeMeta.name;
|
|
397
397
|
const data = typeMeta.data;
|
|
398
398
|
const displayName = getDisplayName(part);
|
|
399
399
|
addHeading(3, displayName);
|
|
@@ -490,7 +490,7 @@ export async function generateTypesMarkdown(options) {
|
|
|
490
490
|
}
|
|
491
491
|
} else if (typeMeta.type === 'class') {
|
|
492
492
|
// For 'class' types (ClassTypeMeta)
|
|
493
|
-
const part = typeMeta.
|
|
493
|
+
const part = typeMeta.name;
|
|
494
494
|
const data = typeMeta.data;
|
|
495
495
|
const displayName = getDisplayName(part);
|
|
496
496
|
addHeading(3, displayName);
|