@@ -367,23 +367,28 @@ format_usage <- function(
367367 return (single_line )
368368 }
369369
370- # Otherwise, wrap to multiple lines like roxygen2
371- # roxygen2 uses 2-space indent
372- indent <- " "
370+ # Wrap to multiple lines, packing multiple args per line
371+ # Continuation lines indented to align after opening paren
372+ open <- paste0(display_name , " (" )
373+ cont_indent <- paste(rep(" " , nchar(open )), collapse = " " )
373374 lines <- character ()
374- lines <- c( lines , paste0( display_name , " ( " ))
375+ current <- open
375376
376377 for (i in seq_along(args )) {
377378 arg <- args [i ]
378- if (i < length(args )) {
379- suffix <- " ,"
379+ suffix <- if (i < length(args )) " , " else " "
380+ piece <- paste0(arg , suffix )
381+
382+ if (nchar(current ) + nchar(piece ) > 80 && current != open ) {
383+ lines <- c(lines , sub(" ,? $" , " ," , current ))
384+ current <- paste0(cont_indent , piece )
380385 } else {
381- suffix <- " "
386+ current <- paste0( current , piece )
382387 }
383- lines <- c(lines , paste0(indent , arg , suffix ))
384388 }
385389
386- lines <- c(lines , " )" )
390+ current <- paste0(current , " )" )
391+ lines <- c(lines , current )
387392 paste(lines , collapse = " \n " )
388393}
389394
0 commit comments