Title: | To Insert Title, Divider, and Block of Comments |
Version: | 0.4.1 |
Description: | For instructions, check https://github.com/Hzhang-ouce/ARTofR. This is a wrapper of 'bannerCommenter', for inserting neat comments, headers and dividers. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.2 |
Imports: | bannerCommenter (≥ 1.0.0), clipr (≥ 0.4.0), rstudioapi, shiny |
Suggests: | rmarkdown, miniUI, knitr |
VignetteBuilder: | knitr |
Date: | 2022-03-05 23:20:01 UTC |
NeedsCompilation: | no |
Packaged: | 2022-03-05 11:55:48 UTC; Huanyuan |
Author: | Huanyuan Zhang |
Maintainer: | Huanyuan Zhang <hyzhang1996@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2022-03-05 15:30:02 UTC |
Core functions for comment making
Description
This is modified from bannerCommenter::banner()
, the main modification is to extend the comment length (minHashes) to 80
Usage
my_own_banner(
x,
...,
emph = FALSE,
snug = FALSE,
upper = emph,
centre = !fold,
leftSideHashes = 2 + emph,
rightSideHashes = leftSideHashes,
minHashes = (!snug) * (80 + 10 * emph),
numLines = 1 + emph,
bandChar = "#",
center = centre,
fold = FALSE,
maxChar = 75
)
fold_it(x, maxChar, exdent = 0)
Arguments
x |
the string |
... |
Zero or more additional strings as extra lines. Strings may contain newline characters resulting in further line breaks. |
emph |
A logical value: Do you want this to be an emphasised comment? |
snug |
A logical value: Do you want the decoration to hug the strings closely? |
upper |
A logical value: Do you want the strings converted to upper case? |
centre |
A logical value: Do you want the text strings centred? (alternative: left justified) |
leftSideHashes |
A positive integer: How many hashes go on the left side? |
rightSideHashes |
A non-negative integer: How many hashes go on the right side? |
minHashes |
A non-negative integer: What is the minimum number of hashes in the boundary lines? |
numLines |
A non-negative integer: How many lines of hashes above and below do you want? |
bandChar |
A single character. Used instead of # for all characters in the bands around the text, apart from the first character of every line. |
center |
Alternative spelling of |
fold |
Logical: should the text be folded to ensure lines are not too long? |
maxChar |
same as width in str_wrap |
exdent |
for xxx_list() |
Value
A character string vector returned invisibly, but automatically displayed in the console
Functions
-
fold_it
: sub-function to fold sentence, don't use this in other circumstance
Examples
my_own_banner("This should appear clearly and stand out.",
"The lines are left justified by default.")
##This is NOT recommended!!!
##This is NOT recommended!!!
##This is NOT recommended!!!
##pls use bannerCommenter::banner()
Convert sentences into a box of comments
Description
For user guide, please refer to https://github.com/Hzhang-ouce/ARTofR
Usage
xxx_box(mystring = NULL, center = FALSE)
xxx_box1(mystring = NULL, center = FALSE)
xxx_list(mystring = NULL, center = FALSE)
xxx_list1(mystring = NULL, center = FALSE)
Arguments
mystring |
A string, will be a line of comment. If missing, the function will try to grab texts from your clipboard. |
center |
A logical value: Do you want the text strings centred? (alternative: left justified) |
Details
xxx_box is for paragraph, xxx_list is for bullet points or numbered list.
Number 1 in xxx_box1 and xxx_list1 imply style 1.
Value
A character string vector returned invisibly, but automatically displayed in the console, the output will be saved into clipboard
Functions
-
xxx_box1
: Same as xxx_box but add border -
xxx_list
: Same as xxx_box but looks better for bullet points list or numbered list -
xxx_list1
: Same as xxx_list but add border
Examples
# COMMON WORKFLOW OF THIS PACKAGE
# 1. type your text in any text editor
# 2. copy your text
# 3. call xxx_box() etc without arguments to grab text from clipboard
# 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them
# 5. paste into your R script
#
#
#...............................................
# # OTHER USAGE
xxx_box('test sentence, test sentence, test sentence, test sentence',center = FALSE )
xxx_box1('test sentence, test sentence, test sentence, test sentence',center = FALSE )
xxx_box1('test sentence, test sentence, test sentence, test sentence',center = TRUE )
Insert a divider (line break or page break)
Description
For user guide, please refer to https://github.com/Hzhang-ouce/ARTofR
Usage
xxx_divider1(mystring = NULL)
xxx_divider2(mystring = NULL)
Arguments
mystring |
the content of your break, must be one line only, not too long |
Details
Divider is shorter than title for hierarchy purpose, title will be come a section (for folding) in Rstudio, but divider will not
There are two styles of break, xxx_divider1 and xxx_divider2
Please note that a super long divider string will result in an error
call xxx_divider1()
will grab text from clipboard,
call xxx_divider1('')
will make a line without text,
call xxx_divider1('mystring')
will make a divider with 'mystring'
Value
A character string vector returned invisibly, but automatically displayed in the console, the output will be saved into clipboard
Functions
-
xxx_divider2
: Same as xxx_divider1 but different style
Examples
# COMMON WORKFLOW OF THIS PACKAGE
# 1. type your text in any text editor
# 2. copy your text
# 3. call xxx_box() etc without arguments to grab text from clipboard
# 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them
# 5. paste into your R script
#
#
#...............................................
# # OTHER USAGE
xxx_divider1('mystring')
xxx_divider1('')
xxx_divider2('mystring')
xxx_divider2('')
Insert a title
Description
For user guide, please refer to https://github.com/Hzhang-ouce/ARTofR
Usage
xxx_title1(mystring = NULL)
xxx_title0(mystring = NULL)
xxx_title2(mystring = NULL)
xxx_title3(mystring = NULL)
Arguments
mystring |
the content of your title, must be one line only, not too long |
Details
There are three levels of titles, inserting a title with xxx_title() will also add a section in Rstudio automatically.
Please note that a super long title string will result in an error
xxx_title0() was designed as the main title of the whole script
xxx_title1() is the largest header
xxx_title2() is the middle size header
xxx_title3() is the smallest header
Value
A character string vector returned invisibly, but automatically displayed in the console, the output will be saved into clipboard
Functions
-
xxx_title0
: the middle size title -
xxx_title2
: the middle size title -
xxx_title3
: the smallest title
Examples
# COMMON WORKFLOW OF THIS PACKAGE
# 1. type your text in any text editor
# 2. copy your text
# 3. call xxx_box() etc without arguments to grab text from clipboard
# 4. decorated text will be displayed and sent to clipboard, NO NEED to copy them
# 5. paste into your R script
#
#
#...............................................
# # OTHER USAGE
xxx_title0('my title')
xxx_title1('my title')
xxx_title2('my title')
xxx_title3('my title')