Skip to content

Commit 914e536

Browse files
AugustinMauroyavivkellerovflowd
committed
apply suggestion
Co-Authored-By: Aviv Keller <[email protected]> Co-Authored-By: Claudio Wunder <[email protected]>
1 parent 02848c2 commit 914e536

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

src/generators/jsx-ast/utils/buildContent.mjs

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
TYPE_PREFIX_LENGTH,
2121
} from '../constants.mjs';
2222
import insertSignature, { getFullName } from './buildSignature.mjs';
23+
import { transformNodesToString } from '../../../utils/unist.mjs';
2324

2425
/**
2526
* Processes lifecycle and change history data into a sorted array of change entries.
@@ -170,51 +171,21 @@ export const transformStabilityNode = (node, index, parent) => {
170171
* @returns {string} The corresponding AlertBox level
171172
*/
172173
const getLevelFromDeprecationType = typeText => {
173-
const normalized = String(typeText || '')
174-
.trim()
175-
.toLowerCase()
176-
.replace(/[.,]/g, ' ')
177-
.split(/\s+/)
178-
.filter(Boolean);
179-
180174
if (
181-
normalized.includes('documentation') ||
182-
normalized.includes('compilation')
175+
typeText.startsWith('Documentation') ||
176+
typeText.startsWith('Compilation')
183177
) {
184178
return 'info';
185179
} else if (
186-
normalized.includes('runtime') ||
187-
normalized.includes('application')
180+
typeText.startsWith('Runtime') ||
181+
typeText.startsWith('Application')
188182
) {
189183
return 'warning';
190184
} else {
191185
return 'danger';
192186
}
193187
};
194188

195-
/**
196-
*
197-
* @param nodes
198-
*/
199-
const getTextValue = nodes =>
200-
(nodes || [])
201-
.map(node => {
202-
if (!node) {
203-
return '';
204-
}
205-
if (typeof node.value === 'string') {
206-
return node.value;
207-
}
208-
if (typeof node.alt === 'string') {
209-
return node.alt;
210-
}
211-
if (Array.isArray(node.children)) {
212-
return getTextValue(node.children);
213-
}
214-
return '';
215-
})
216-
.join('');
217-
218189
/**
219190
* Transforms a heading node by injecting metadata, source links, and signatures.
220191
* @param {ApiDocMetadataEntry} entry - The API metadata entry
@@ -240,7 +211,7 @@ export const transformHeadingNode = (entry, remark, node, index, parent) => {
240211
{ textHandling: { boundaries: 'preserve' } }
241212
).node.children;
242213

243-
const typeText = getTextValue(sliced);
214+
const typeText = transformNodesToString(sliced);
244215

245216
parent.children[index + 1] = createJSXElement(JSX_IMPORTS.AlertBox.name, {
246217
children: sliced,

0 commit comments

Comments
 (0)