@@ -263,7 +263,11 @@ const parseDeclaration = (declaration, packageName) => {
263
263
264
264
let sections = [ ] ;
265
265
266
- if ( declaration . _ui5experimental ) {
266
+ if ( declaration . deprecated ) {
267
+ sections . push ( `:::warning
268
+ ${ deprecatedText ( declaration ) }
269
+ :::` )
270
+ } else if ( declaration . _ui5experimental ) {
267
271
sections . push ( `:::info
268
272
${ experimentalText ( declaration ) }
269
273
:::` )
@@ -296,22 +300,29 @@ ${declaration._implementations.map(_implementation => `| ${_implementation.split
296
300
297
301
let fileContent = sections . join ( "\n\n" ) ;
298
302
299
- if ( declaration . _ui5experimental ) {
303
+
304
+ if ( declaration . deprecated ) {
305
+ fileContent = addDeprecatedClassName ( fileContent , declaration ) ;
306
+ } else if ( declaration . _ui5experimental ) {
300
307
fileContent = addExperimentalClassName ( fileContent , declaration ) ;
301
308
}
302
309
303
310
304
311
return fileContent ;
305
312
}
306
313
307
-
308
-
309
314
const experimentalText = declaration => {
310
- return typeof declaration . _ui5experimental === "boolean" ?
315
+ return typeof declaration . _ui5experimental === "boolean" ?
311
316
"The following entity is available under an experimental flag and its API and behavior are subject to change."
312
317
: declaration . _ui5experimental ;
313
318
}
314
319
320
+ const deprecatedText = declaration => {
321
+ return typeof declaration . deprecated === "boolean" ?
322
+ "The following entity is deprecated and will be removed in the next major version."
323
+ : declaration . deprecated ;
324
+ }
325
+
315
326
316
327
const parseComponentDeclaration = ( declaration , fileContent ) => {
317
328
if ( ! declaration || ! fileContent ) {
@@ -326,7 +337,15 @@ const parseComponentDeclaration = (declaration, fileContent) => {
326
337
fileContent = enhanceFrontMatter ( fileContent , "ui5_since" , `${ declaration . _ui5since } ` )
327
338
}
328
339
329
- if ( declaration . _ui5experimental ) {
340
+ if ( declaration . deprecated ) {
341
+ fileContent = addDeprecatedClassName ( fileContent , declaration ) ;
342
+
343
+ fileContent = fileContent . replace ( "<%COMPONENT_OVERVIEW%>" , `:::warning
344
+ ${ deprecatedText ( declaration ) }
345
+ :::
346
+
347
+ ${ parseDeclarationDescription ( declaration . description ) } `)
348
+ } else if ( declaration . _ui5experimental ) {
330
349
fileContent = addExperimentalClassName ( fileContent , declaration ) ;
331
350
332
351
fileContent = fileContent . replace ( "<%COMPONENT_OVERVIEW%>" , `:::info
@@ -352,6 +371,25 @@ ${parseDeclarationDescription(declaration.description)}`)
352
371
}
353
372
354
373
const experimentalCssClass = "expComponentBadge" ;
374
+ const deprecatedCssClass = "deprComponentBadge" ;
375
+
376
+ const addDeprecatedClassName = ( fileContent , declaration ) => {
377
+ if ( ! declaration . deprecated ) {
378
+ return fileContent ;
379
+ }
380
+
381
+ const frontMatter = fileContent . match ( / ^ - - - \n (?: .+ \n ) * - - - / ) ;
382
+
383
+ if ( ! frontMatter ) {
384
+ return `---
385
+ sidebar_class_name: ${ deprecatedCssClass }
386
+ ---
387
+
388
+ ${ fileContent } `
389
+ }
390
+
391
+ return enhanceFrontMatter ( fileContent , "sidebar_class_name" , deprecatedCssClass )
392
+ }
355
393
356
394
const addExperimentalClassName = ( fileContent , declaration ) => {
357
395
if ( ! declaration . _ui5experimental ) {
@@ -390,7 +428,7 @@ ${fileContent}`
390
428
if ( classLine && ! hasExperimentalClass ) {
391
429
frontMatterLines [ classLineIndex ] = `${ classLine } ${ value } ` ;
392
430
} else if ( ! classLine ) {
393
- frontMatterLines . splice ( frontMatterLines . length - 1 , 0 , `${ front_matter_name } : ${ value } ` ) ;
431
+ frontMatterLines . splice ( frontMatterLines . length - 1 , 0 , `${ front_matter_name } : ${ value } ` ) ;
394
432
}
395
433
396
434
return fileContent . replace ( frontMatter [ 0 ] , frontMatterLines . join ( "\n" ) ) ;
0 commit comments