Description Usage Arguments Details Removing spaces and hashes See Also Examples
Create a summary of one or multiple code files based on the section separators and their titles.
1 2 3 4 5 |
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
|
file_in_extension |
If |
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. |
width |
The character width of the output. If NULL, it is set to the length of the longest separator title. |
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. |
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). |
... |
futher arguments to be passed from and to other methods, in
particular |
To create the summary, sum_str
uses regular expressions.
Hence it is crucial that the code separators and the separator titles
match the regular expression pattern. We recommend inserting
separators and their titles using the RStudio Add-in that is contained
in this package. The definition is rather intuitive as can be seen in the
example section below. However, we shall provide a formal definition here
as well.
A code separator is defined as a line that starts with n hashes,
followed by 4-n spaces where 0 < n < 4. This sequence is followed by one
or more either .
or _
.
A title associated with a code separator is defined as a line
that starts with n hashes, followed by 4-n spaces where 0 < n < 4. This
sequence is not followed by .
or _
.
Lines that do not satisfy these requirements (e.g. do not start with #s,
do not contain the right number of spaces after the #, indent before any #
ect.) are not considered by sum_str
.
The add-in contained in this package inserts section titles in a way that
that they are recognised by RStudio as sections (for details, see
RStudio's official website. One structure that is
recognised by RStudio as section is a line starting with a hash and ending
with four hashes. This structure is implemented with strcode
.
Hence when creating the summary, it might be desired to remove the right
hand hashes and spaces, which can be specified with the respective options
rm_rh_hashes
and rm_rh_spaces
.
insert_l_break
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # the following separator is an example of a valid
# separator and associated title
# __________________________________________________
# this is a level 1 title ####
## . . . . . . . . . . . . . . . . . . . . . . . . .
## note that the title or the separator character (_, .)
## always starts at indention 4.
## Not run:
# Open a new .R file in RStudio, insert some code breaks
# using the Add-in of this package, save the file and run:
sum_str() # get a summary of the source editor.
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.