diff --git a/main/coverage-report/index.html b/main/coverage-report/index.html index 1ad028be8..b98b34d8b 100644 --- a/main/coverage-report/index.html +++ b/main/coverage-report/index.html @@ -5,7 +5,7 @@ - + @@ -94,7 +94,7 @@ font-size: 11px; }
-

formatters coverage - 94.52%

+

formatters coverage - 94.37%

-
- +
+
@@ -6540,1751 +6540,1779 @@

formatters coverage - 94.52%

                     verbose = FALSE) {
- - 919 - - -

-                    
-                  
                   
-                    920
+                    919
                     19x
                     
                       
    mpf <- matrix_form(obj, TRUE, TRUE, indent_size = indent_size)
- 921 + 920 19x
    if(is.null(colwidths))
- 922 + 921 11x
        colwidths <- mf_col_widths(mpf) %||% propose_column_widths(mpf)
- 923 + 922
    else
- 924 + 923 8x
        mf_col_widths(mpf) <- colwidths
- 925 + 924 19x
    if(NROW(mf_cinfo(mpf)) == 0)
- 926 + 925 19x
        mpf <- mpf_infer_cinfo(mpf, colwidths, rep_cols)
- 927 + 926

                     
                   
                   
-                    928
+                    927
                     
                     
                       

                     
                   
                   
-                    929
+                    928
                     19x
                     
                       
    if(is.null(pg_size_spec)) {
- 930 + 929 17x
        pg_size_spec <- calc_lcpp(page_type = page_type,
- 931 + 930 17x
                        font_family = font_family,
- 932 + 931 17x
                        font_size = font_size,
- 933 + 932 17x
                        lineheight = lineheight,
- 934 + 933 17x
                        landscape = landscape,
- 935 + 934 17x
                        pg_width = pg_width,
- 936 + 935 17x
                        pg_height = pg_height,
- 937 + 936 17x
                        margins = margins,
- 938 + 937 17x
                        lpp = lpp,
- 939 + 938 17x
                        cpp = cpp,
- 940 + 939 17x
                        tf_wrap = tf_wrap,
- 941 + 940 17x
                        max_width = max_width,
- 942 + 941 17x
                        colwidths = colwidths,
- 943 + 942 17x
                        inset = table_inset(mpf),
- 944 + 943 17x
                        col_gap = col_gap)
- 945 + 944
    }
- 946 + 945
    ## this MUST alsways return a list, inluding list(obj) when
- 947 + 946
    ## no forced pagination is needed! otherwise stuff breaks for things
- 948 + 947
    ## based on s3 classes that are lists underneath!!!
- 949 + 948 19x
    fpags <- do_forced_paginate(obj)
- 950 + 949

                     
                   
                   
-                    951
+                    950
                     
                     
                       
    ## if we have more than one forced "page",
- 952 + 951
    ## paginate each of them individually and return the result.
- 953 + 952
    ## forced pagination is ***currently*** only vertical, so
- 954 + 953
    ## we don't have to worry about divying up colwidths here,
- 955 + 954
    ## but we will if we ever allow force_paginate to do horiz
- 956 + 955
    ## pagination.
- 957 + 956 19x
    if(length(fpags) > 1) {
- 958 + 957 1x
        deep_pag <- lapply(fpags, paginate_to_mpfs,
- 959 + 958 1x
                      pg_size_spec = pg_size_spec,
- 960 + 959 1x
                      colwidths = colwidths,
- 961 + 960 1x
                      min_siblings = min_siblings,
- 962 + 961 1x
                      nosplitin = nosplitin,
- 963 + 962 1x
                      verbose = verbose)
- 964 + 963 1x
        return(unlist(deep_pag, recursive = FALSE))
- 965 + 964 18x
    } else if (has_page_title(fpags[[1]])) {
- 966 + 965 !
      obj <- fpags[[1]]
- 967 + 966
    }
- 968 + 967

                     
                   
                   
-                    969
+                    968
                     
                     
                       

                     
                   
                   
-                    970
+                    969
                     
                     
                       
    ## we run into forced pagination, but life is short and this should work fine.
- 971 + 970 18x
    mpf <- matrix_form(obj, TRUE, TRUE, indent_size = indent_size)
- 972 + 971 18x
    if(is.null(colwidths))
- 973 + 972 !
        colwidths <- mf_col_widths(mpf) %||% propose_column_widths(mpf)
- 974 + 973 18x
    mf_col_widths(mpf) <- colwidths
- 975 + 974

                     
                   
                   
-                    976
+                    975
                     18x
                     
                       
    page_indices <- paginate_indices(obj = obj,
- 977 + 976
                                     ## page_type = page_type,
- 978 + 977
                                     ## font_family = font_family,
- 979 + 978
                                     ## font_size = font_size,
- 980 + 979
                                     ## lineheight = lineheight,
- 981 + 980
                                     ## landscape = landscape,
- 982 + 981
                                     ## pg_width = pg_width,
- 983 + 982
                                     ## pg_height = pg_height,
- 984 + 983
                                     ## margins = margins,
- 985 + 984 18x
                                     pg_size_spec = pg_size_spec,
- 986 + 985
                                     ## lpp = lpp,
- 987 + 986
                                     ## cpp = cpp,
- 988 + 987 18x
                                     min_siblings = min_siblings,
- 989 + 988 18x
                                     nosplitin = nosplitin,
- 990 + 989 18x
                                     colwidths = colwidths,
- 991 + 990 18x
                                     tf_wrap = tf_wrap,
- 992 + 991
                                     ## max_width = max_width,
- 993 + 992 18x
                                     rep_cols = rep_cols,
- 994 + 993 18x
                                     verbose = verbose)
- 995 + 994

                     
                   
                   
+                    995
+                    15x
+                    
+                      
    if (any(inherits(obj, "listing_df"))) {
+ + + 996 + ! + +
      pagmats <- lapply(page_indices$pag_row_indices,
+ + + + 997 + ! + +
                        function(ii) matrix_form(obj[ii, ], TRUE, TRUE,
+ + + + 998 + ! + +
                                                 indent_size = indent_size))
+ + + + 999 + + +
    } else {
+ + + + 1000 15x -
    pagmats <- lapply(page_indices$pag_row_indices, function(ii) {
+
      pagmats <- lapply(page_indices$pag_row_indices, function(ii) {
- 997 + 1001 34x -
        mpf_subset_rows(mpf, ii)
+
          mpf_subset_rows(mpf, ii)
- 998 + 1002 -
    })
+
      })
- 999 + 1003 -

+                      
    }
- 1000 + 1004
    ## these chunks now carry around their (correctly subset) col widths...
- 1001 + 1005 15x
    res <- lapply(pagmats, function(matii) {
- 1002 + 1006 34x
        lapply(page_indices$pag_col_indices, function(jj) {
- 1003 + 1007 68x
            mpf_subset_cols(matii, jj)
- 1004 + 1008
        })
- 1005 + 1009
    })
- 1006 + 1010 15x
    unlist(res, recursive = FALSE)
- 1007 + 1011
}
- 1008 + 1012

                     
                   
                   
-                    1009
+                    1013
                     
                     
                       

                     
                   
                   
-                    1010
+                    1014
                     
                     
                       
#' @importFrom utils capture.output
- 1011 + 1015
#' @details
- 1012 + 1016
#'
- 1013 + 1017
#' `diagnose_pagination` attempts pagination and then, regardless of success
- 1014 + 1018
#' or failure, returns diagnostic information about pagination
- 1015 + 1019
#' attempts (if any) after each row and column.
- 1016 + 1020
#'
- 1017 + 1021
#' The diagnostics data reflects the final time the pagination algorithm
- 1018 + 1022
#' evaluated a page break at the specified location, regardless of how
- 1019 + 1023
#' many times the position was assessed total.
- 1020 + 1024
#'
- 1021 + 1025
#' To get information about intermediate attempts, perform pagination
- 1022 + 1026
#' with `verbose = TRUE` and inspect the messages in order.
- 1023 + 1027
#'
- 1024 + 1028
#' @return For `diagnose_pagination` a list containing:
- 1025 + 1029
#'
- 1026 + 1030
#' \describe{
- 1027 + 1031
#' \item{`lpp_diagnostics`}{diagnostic information regarding lines per page}
- 1028 + 1032
#' \item{`row_diagnostics`}{basic information about rows, whether pagination was attempted after each row, and the final result of such an attempt, if made}
- 1029 + 1033
#' \item{`cpp_diagnostics}{diagnostic information regarding columns per page}
- 1030 + 1034
#' \item{`col_diagnostics`}{(very) basic information about leaf columns, whether pagination was attempted after each leaf column, ad the final result of such attempts, if made}
- 1031 + 1035
#' }
- 1032 + 1036
#'
- 1033 + 1037
#' @note  For  `diagnose_pagination`,   the  column  labels  are  not
- 1034 + 1038
#'     displayed  in  the  `col_diagnostics` element  due  to  certain
- 1035 + 1039
#'     internal  implementation details;  rather  the diagnostics  are
- 1036 + 1040
#'     reported in terms of absolute (leaf) column position. This is a
- 1037 + 1041
#'     known  limitation,  and  may  eventually be  changed,  but  the
- 1038 + 1042
#'     information remains useful as it is currently reported.
- 1039 + 1043
#'
- 1040 + 1044
#' @note `diagnose_pagination` is intended for interactive debugging
- 1041 + 1045
#' use and \emph{should not be programmed against}, as the exact
- 1042 + 1046
#' content and form of the  verbose messages it captures and
- 1043 + 1047
#' returns is subject to change.
- 1044 + 1048
#'
- 1045 + 1049
#' @note because `diagnose_pagination` relies on `capture.output(type = "message")`,
- 1046 + 1050
#' it cannot be used within the `testthat` (and likely other) testing frameworks,
- 1047 + 1051
#' and likely cannot be used within `knitr`/`rmarkdown` contexts either,
- 1048 + 1052
#' as this clashes with those systems' capture of messages.
- 1049 + 1053
#'
- 1050 + 1054
#' @export
- 1051 + 1055
#'
- 1052 + 1056
#' @rdname paginate_indices
- 1053 + 1057
#' @examples
- 1054 + 1058
#'
- 1055 + 1059
#' diagnose_pagination(mpf, pg_width = 5, pg_height = 3)
- 1056 + 1060
#' clws <- propose_column_widths(mpf)
- 1057 + 1061
#' clws[1] <- floor(clws[1]/3)
- 1058 + 1062
#' dgnost <- diagnose_pagination(mpf, pg_width = 5, pg_height = 3, colwidths = clws)
- 1059 + 1063
#' try(diagnose_pagination(mpf, pg_width = 1)) #fails
- 1060 + 1064
#'
- 1061 + 1065
diagnose_pagination <- function(obj,
- 1062 + 1066
                                page_type = "letter",
- 1063 + 1067
                                font_family = "Courier",
- 1064 + 1068
                                font_size = 8,
- 1065 + 1069
                                lineheight = 1,
- 1066 + 1070
                                landscape = FALSE,
- 1067 + 1071
                                pg_width = NULL,
- 1068 + 1072
                                pg_height = NULL,
- 1069 + 1073
                                margins = c(top = .5, bottom = .5, left = .75, right = .75),
- 1070 + 1074
                                lpp = NA_integer_,
- 1071 + 1075
                                cpp = NA_integer_,
- 1072 + 1076
                                min_siblings = 2,
- 1073 + 1077
                                nosplitin = character(),
- 1074 + 1078
                                colwidths = propose_column_widths(matrix_form(obj, TRUE)),
- 1075 + 1079
                                tf_wrap = FALSE,
- 1076 + 1080
                                max_width = NULL,
- 1077 + 1081
                                indent_size = 2,
- 1078 + 1082
                                pg_size_spec = NULL,
- 1079 + 1083
                                rep_cols = num_rep_cols(obj),
- 1080 + 1084
                                col_gap = 2,
- 1081 + 1085
                                verbose = FALSE,
- 1082 + 1086
                                ...) {
- 1083 + 1087

                     
                   
                   
-                    1084
+                    1088
                     
                     
                       

                     
                   
                   
-                    1085
+                    1089
                     6x
                     
                       
    fpag <- do_forced_paginate(obj)
- 1086 + 1090 6x
    if(length(fpag) > 1) {
- 1087 + 1091 1x
        return(lapply(fpag,
- 1088 + 1092 1x
                      diagnose_pagination,
- 1089 + 1093 1x
                      page_type = page_type,
- 1090 + 1094 1x
                      font_family = font_family,
- 1091 + 1095 1x
                      font_size = font_size,
- 1092 + 1096 1x
                      lineheight = lineheight,
- 1093 + 1097 1x
                      landscape = landscape,
- 1094 + 1098 1x
                      pg_width = pg_width,
- 1095 + 1099 1x
                      pg_height = pg_height,
- 1096 + 1100 1x
                      margins = margins,
- 1097 + 1101 1x
                      lpp = lpp,
- 1098 + 1102 1x
                      cpp = cpp,
- 1099 + 1103 1x
                      tf_wrap = tf_wrap,
- 1100 + 1104 1x
                      max_width = max_width,
- 1101 + 1105 1x
                      colwidths = colwidths,
- 1102 + 1106 1x
                      col_gap = col_gap,
- 1103 + 1107 1x
                      min_siblings = min_siblings,
- 1104 + 1108 1x
                      nosplitin = nosplitin))
- 1105 + 1109
    }
- 1106 + 1110

                     
                   
                   
-                    1107
+                    1111
                     5x
                     
                       
    mpf <- matrix_form(obj, TRUE)
- 1108 + 1112 5x
    msgres <- capture.output({tmp <- try(paginate_to_mpfs(obj, page_type = page_type,
- 1109 + 1113 5x
                     font_family = font_family,
- 1110 + 1114 5x
                     font_size = font_size,
- 1111 + 1115 5x
                     lineheight = lineheight,
- 1112 + 1116 5x
                     landscape = landscape,
- 1113 + 1117 5x
                     pg_width = pg_width,
- 1114 + 1118 5x
                     pg_height = pg_height,
- 1115 + 1119 5x
                     margins = margins,
- 1116 + 1120 5x
                     lpp = lpp,
- 1117 + 1121 5x
                     cpp = cpp,
- 1118 + 1122 5x
                     tf_wrap = tf_wrap,
- 1119 + 1123 5x
                     max_width = max_width,
- 1120 + 1124 5x
                     colwidths = colwidths,
- 1121 + 1125 5x
                     col_gap = col_gap,
- 1122 + 1126 5x
                     min_siblings = min_siblings,
- 1123 + 1127 5x
                     nosplitin = nosplitin,
- 1124 + 1128 5x
                     verbose = TRUE))},
- 1125 + 1129 5x
                     type = "message")
- 1126 + 1130 5x
    if(is(tmp, "try-error") && grepl("Width of row labels equal to or larger", tmp)) {
- 1127 + 1131 !
        cond <- attr(tmp, "condition")
- 1128 + 1132 !
        stop(conditionMessage(cond), call. = conditionCall(cond))
- 1129 + 1133
    }
- 1130 + 1134

                     
                   
                   
-                    1131
+                    1135
                     5x
                     
                       
    lpp_diagnostic <- grep("^(Determining lines|Lines per page available).*$", msgres, value = TRUE)
- 1132 + 1136 5x
    cpp_diagnostic <- unique(grep("^Adjusted characters per page.*$", msgres, value = TRUE))
- 1133 + 1137

                     
                   
                   
-                    1134
+                    1138
                     5x
                     
                       
    mpf  <- do_cell_fnotes_wrap(mpf, widths = colwidths, max_width = max_width, tf_wrap = tf_wrap)
- 1135 + 1139 5x
    mpf <- mpf_infer_cinfo(mpf, colwidths = colwidths)
- 1136 + 1140

                     
                   
                   
-                    1137
+                    1141
                     5x
                     
                       
    rownls <- grep("Checking pagination after row", msgres, fixed = TRUE)
- 1138 + 1142 5x
    rownum <- as.integer(gsub("[^[:digit:]]*(.*)$", "\\1", msgres[rownls]))
- 1139 + 1143 5x
    rowmsgs <- vapply(unique(rownum), function(ii) {
- 1140 + 1144 !
        idx <- max(which(rownum == ii))
- 1141 + 1145 !
        gsub("\\t[.]*", "", msgres[rownls[idx] + 1])
- 1142 + 1146
    }, "")
- 1143 + 1147

                     
                   
                   
-                    1144
+                    1148
                     5x
                     
                       
    msgdf <- data.frame(abs_rownumber = unique(rownum),
- 1145 + 1149 5x
                        final_pag_result = rowmsgs, stringsAsFactors = FALSE)
- 1146 + 1150 5x
    rdf <-mf_rinfo(mpf)[, c("abs_rownumber", "label", "self_extent", "par_extent", "node_class")]
- 1147 + 1151 5x
    rdf$pag_attempted <- rdf$abs_rownumber %in% rownum
- 1148 + 1152 5x
    row_diagnose <- merge(rdf, msgdf, by = "abs_rownumber", all.x = TRUE)
- 1149 + 1153

                     
                   
                   
-                    1150
+                    1154
                     5x
                     
                       
    colnls <- grep("Checking pagination after column", msgres, fixed = TRUE)
- 1151 + 1155 5x
    colnum <- as.integer(gsub("[^[:digit:]]*(.*)$", "\\1", msgres[colnls]))
- 1152 + 1156 5x
    colmsgs <- vapply(unique(colnum), function(ii) {
- 1153 + 1157 !
        idx <- max(which(colnum == ii))
- 1154 + 1158 !
        gsub("\\t[.]*", "", msgres[colnls[idx] + 1])
- 1155 + 1159
    }, "")
- 1156 + 1160

                     
                   
                   
-                    1157
+                    1161
                     5x
                     
                       
    colmsgdf <- data.frame(abs_rownumber = unique(colnum),
- 1158 + 1162 5x
                           final_pag_result = colmsgs,
- 1159 + 1163 5x
                           stringsAsFactors = FALSE)
- 1160 + 1164 5x
    cdf <- mf_cinfo(mpf)[, c("abs_rownumber", "self_extent")]
- 1161 + 1165 5x
    cdf$pag_attempted <- cdf$abs_rownumber %in% colnum
- 1162 + 1166 5x
    col_diagnose <- merge(cdf, colmsgdf, by = "abs_rownumber", all.x = TRUE)
- 1163 + 1167 5x
    names(col_diagnose) <- gsub("^abs_rownumber$", "abs_colnumber", names(col_diagnose))
- 1164 + 1168 5x
    list(lpp_diagnostics = lpp_diagnostic,
- 1165 + 1169 5x
         row_diagnostics = row_diagnose,
- 1166 + 1170 5x
         cpp_diagnostics = cpp_diagnostic,
- 1167 + 1171 5x
         col_diagnostics = col_diagnose)
- 1168 + 1172
}
@@ -15110,511 +15138,511 @@

formatters coverage - 94.52%

-