public static void addFunctionDoc ( PageExceptionImpl pe , FunctionLibFunction flf ) { ArrayList < FunctionLibFunctionArg > args = flf . getArg ( ) ; Iterator < FunctionLibFunctionArg > it = args . iterator ( ) ; // Pattern StringBuilder pattern = new StringBuilder ( flf . getName ( ) ) ; StringBuilder end = new StringBuilder ( ) ; pattern . append ( "(" ) ; FunctionLibFunctionArg arg ; int c = 0 ; while ( it . hasNext ( ) ) { arg = it . next ( ) ; if ( ! arg . isRequired ( ) ) { pattern . append ( " [" ) ; end . append ( "]" ) ; } if ( c ++ > 0 ) pattern . append ( ", " ) ; pattern . append ( arg . getName ( ) ) ; pattern . append ( ":" ) ; pattern . append ( arg . getTypeAsString ( ) ) ; } pattern . append ( end ) ; pattern . append ( "):" ) ; pattern . append ( flf . getReturnTypeAsString ( ) ) ; pe . setAdditional ( KeyConstants . _Pattern , pattern ) ; // Documentation StringBuilder doc = new StringBuilder ( flf . getDescription ( ) ) ; StringBuilder req = new StringBuilder ( ) ; StringBuilder opt = new StringBuilder ( ) ; StringBuilder tmp ; doc . append ( "\n" ) ; it = args . iterator ( ) ; while ( it . hasNext ( ) ) { arg = it . next ( ) ; tmp = arg . isRequired ( ) ? req : opt ; tmp . append ( "- " ) ; tmp . append ( arg . getName ( ) ) ; tmp . append ( " (" ) ; tmp . append ( arg . getTypeAsString ( ) ) ; tmp . append ( "): " ) ; tmp . append ( arg . getDescription ( ) ) ; tmp . append ( "\n" ) ; } if ( req . length ( ) > 0 ) doc . append ( "\nRequired:\n" ) . append ( req ) ; if ( opt . length ( ) > 0 ) doc . append ( "\nOptional:\n" ) . append ( opt ) ; pe . setAdditional ( KeyImpl . init ( "Documentation" ) , doc ) ; }
add detailed function documentation to the exception