14
14
import java .util .*;
15
15
import java .util .stream .Collectors ;
16
16
17
+
17
18
/**
18
19
* Default implementation of DocWorkUnitHandler. The DocWorkUnitHandler determines the template that will be
19
20
* used for a given work unit, and populates the Freemarker property map used for a single feature/work-unit.
@@ -235,6 +236,8 @@ protected void addHighLevelBindings(final DocWorkUnit workUnit)
235
236
// FreeMarker map for the index.
236
237
workUnit .setProperty ("beta" , workUnit .isBetaFeature ());
237
238
workUnit .setProperty ("experimental" , workUnit .isExperimentalFeature ());
239
+ workUnit .setProperty (TemplateProperties .FEATURE_DEPRECATED , workUnit .isDeprecatedFeature ());
240
+ workUnit .setProperty (TemplateMapConstants .FEATURE_DEPRECATION_DETAIL , workUnit .getDeprecationDetail ());
238
241
239
242
workUnit .setProperty ("description" , getDescription (workUnit ));
240
243
@@ -311,26 +314,10 @@ protected void addCommandLineArgumentBindings(final DocWorkUnit currentWorkUnit,
311
314
argMap .entrySet ().stream ().forEach ( entry -> entry .setValue (sortArguments (entry .getValue ())));
312
315
313
316
// Write out the GSON version
314
- // make a GSON-friendly map of arguments -- uses some hacky casting
317
+ // make a GSON-friendly map of arguments
315
318
final List <GSONArgument > allGSONArgs = new ArrayList <>();
316
- for (final Map <String , Object > item : argMap .get ("all" )) {
317
- GSONArgument itemGSONArg = new GSONArgument ();
318
-
319
- itemGSONArg .populate (item .get ("summary" ).toString (),
320
- item .get ("name" ).toString (),
321
- item .get ("synonyms" ).toString (),
322
- item .get ("type" ).toString (),
323
- item .get ("required" ).toString (),
324
- item .get ("fulltext" ).toString (),
325
- item .get ("defaultValue" ).toString (),
326
- item .get ("minValue" ).toString (),
327
- item .get ("maxValue" ).toString (),
328
- item .get ("minRecValue" ).toString (),
329
- item .get ("maxRecValue" ).toString (),
330
- item .get ("kind" ).toString (),
331
- (List <Map <String , Object >>)item .get ("options" )
332
- );
333
- allGSONArgs .add (itemGSONArg );
319
+ for (final Map <String , Object > detailMap : argMap .get ("all" )) {
320
+ allGSONArgs .add (new GSONArgument (detailMap ));
334
321
}
335
322
currentWorkUnit .setProperty ("gson-arguments" , allGSONArgs );
336
323
}
@@ -392,6 +379,9 @@ protected void processNamedArgument(
392
379
// Finalize argument bindings
393
380
args .get (argKind ).add (argMap );
394
381
args .get ("all" ).add (argMap );
382
+ if (argDef .isDeprecated ()) {
383
+ args .get (TemplateProperties .ARGUMENT_DEPRECATED ).add (argMap );
384
+ }
395
385
}
396
386
}
397
387
@@ -483,6 +473,11 @@ protected void processPositionalArguments(
483
473
argBindings .put ("minElements" , positionalArgDef .getPositionalArgumentsAnnotation ().minElements ());
484
474
argBindings .put ("maxElements" , positionalArgDef .getPositionalArgumentsAnnotation ().maxElements ());
485
475
argBindings .put ("collection" , positionalArgDef .isCollection ());
476
+ argBindings .put (TemplateProperties .ARGUMENT_DEPRECATED , positionalArgDef .isDeprecated ());
477
+ if (positionalArgDef .isDeprecated ()) {
478
+ argBindings .put (TemplateProperties .ARGUMENT_DEPRECATION_DETAIL , positionalArgDef .getDeprecationDetail ());
479
+ args .get (TemplateProperties .ARGLIST_TYPE_DEPRECATED ).add (argBindings );
480
+ }
486
481
args .get ("positional" ).add (argBindings );
487
482
args .get ("all" ).add (argBindings );
488
483
}
@@ -496,16 +491,12 @@ protected void processPositionalArguments(
496
491
*/
497
492
private String docKindOfArg (final NamedArgumentDefinition argumentDefinition ) {
498
493
499
- // deprecated
500
494
// required (common or otherwise)
501
495
// common optional
502
496
// advanced
503
497
// hidden
504
498
505
499
// Required first (after positional, which are separate), regardless of what else it might be
506
- if (argumentDefinition .isDeprecated ()) {
507
- return "deprecated" ;
508
- }
509
500
if (argumentDefinition .isControlledByPlugin ()) {
510
501
return "dependent" ;
511
502
}
@@ -539,7 +530,7 @@ private Map<String, List<Map<String, Object>>> createArgumentMap() {
539
530
args .put ("advanced" , new ArrayList <>());
540
531
args .put ("dependent" , new ArrayList <>());
541
532
args .put ("hidden" , new ArrayList <>());
542
- args .put ("deprecated" , new ArrayList <>());
533
+ args .put (TemplateProperties . ARGLIST_TYPE_DEPRECATED , new ArrayList <>());
543
534
return args ;
544
535
}
545
536
@@ -766,8 +757,10 @@ protected String processNamedArgument(
766
757
if (!argDef .isOptional ()) {
767
758
attributes .add ("required" );
768
759
}
760
+ argBindings .put (TemplateProperties .ARGUMENT_DEPRECATED , argDef .isDeprecated ());
769
761
if (argDef .isDeprecated ()) {
770
- attributes .add ("deprecated" );
762
+ argBindings .put (TemplateProperties .ARGUMENT_DEPRECATION_DETAIL , argDef .getDeprecationDetail ());
763
+ attributes .add (TemplateMapConstants .ARG_DEPRECATED_ATTRIBUTE );
771
764
}
772
765
argBindings .put ("attributes" , attributes .size () > 0 ? String .join (", " , attributes ) : "NA" );
773
766
argBindings .put ("collection" , argDef .isCollection ());
0 commit comments