public static void renderIndex ( final PrintWriter out , final Collection < ? extends HelpPage > pages ) { checkNotNull ( out ) ; checkNotNull ( pages ) ; checkArgument ( ! pages . isEmpty ( ) , "No help pages to render index" ) ; // construct a printf format with sizing for showing columns int max = pages . stream ( ) . mapToInt ( page -> page . getName ( ) . length ( ) ) . max ( ) . orElse ( 0 ) ; String nameFormat = "%-" + max + ' ' ; for ( HelpPage page : pages ) { String formattedName = String . format ( nameFormat , page . getName ( ) ) ; out . format ( " @{bold %s}" , formattedName ) ; String description = page . getDescription ( ) ; if ( description != null ) { out . printf ( " %s%n" , description ) ; } else { out . println ( ) ; } } }
Render a column - formatted index of help pages .