sum_str_helper | R Documentation |
Function is called by sum_str()
and returns summary of one code file.
sum_str_helper(path_in, dir_out, file_out, file_out_extension, rm_rh_hashes,
rm_rh_spaces, rm_break_anchors, width, line_nr, granularity, last_sep, title,
header)
path_in |
Either a path to a directory or to a single file. If it is
a directory path, all files in that directory will be summarised. If it
is a single file path, only the resepective file will be summarised.
The default value uses the RStudio API to produce a summary of content from
the source editor. This requires that the file is saved before
|
dir_out |
The directory to print the output to. "" implies the console. |
file_out |
A connection or character string naming the file to print to.
If set to |
file_out_extension |
A file extension for the file to be created. |
rm_rh_hashes |
Boolean value indicating whether or not to remove righthand hashes in section titles for the summary (see section Removing spaces and hashes). |
rm_rh_spaces |
Boolean value indicating whether or not to remove righthand spaces in section titles for the summary (see section Removing spaces and hashes). |
rm_break_anchors |
Boolean value indicating whether or not the anchors inserted in code separators should be removed for the summary. |
width |
The character width of the output. If NULL, it is set to the length of the longest separator title. |
line_nr |
A boolean value that indicates whether the line numbers should be printed along with the structure summary. |
granularity |
Indicates the lowest level of granularity that should be included in the summary. |
last_sep |
A boolean value indicating whether or not the separating lines of the highest granularity should be printed. |
title |
A boolean value indicating whether the reported summary should contain a title or not. |
header |
A boolean value indicating whether a column header should indicate the name of the columns (line, level, section). |
The core of the function is described best as follows: after a file
was read in and stored in a vector *lines* whereas each element describes a
line of code, the candidate lines (in the sense that they might be contained
in the summary) were evaluated, their indices stored in *cand*. Next,
various regex patterns are matched against *lines*. Then,
after all tests were executed, the variable *remove* contains all indices
that should be removed from *lines* before it is returned as the summary of
the code file. Hence, applying setdiff(cand, remove)
contains
the subset of *lines* that we finally want to output.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.