knit rmd normally generates pdf and html in the same folder. This deletes those files. The file generates a new subfolder by default called htmlpdfr that stores the knit pdf and html files, along with curled R file.

The RMD files should not clear all at the top. That would lead to deleting the rest of the string paths to be searched over.

ff_sup_clean_rmd(
  ar_spt_root,
  ar_spn_skip,
  st_file_pattern = ".Rmd",
  st_git_pattern = ".Rmd",
  st_folder_pdf = "/htmlpdfr/",
  st_folder_html = "/htmlpdfr/",
  st_folder_R = "/htmlpdfr/",
  bl_gen_if_git_old = FALSE,
  bl_recursive = TRUE,
  bl_verbose = TRUE,
  bl_test = TRUE,
  it_hierachy_lower_rmd = 0,
  it_hierachy_shift = 2,
  it_toc_depth = 3,
  ls_bool_convert = list(bl_pdf = TRUE, bl_html = TRUE, bl_R = TRUE),
  ls_bool_remove = list(bl_remove_html = TRUE)
)

Arguments

ar_spt_root

array of string paths of folders to search in

ar_spn_skip

array a string array of names, if path found contains any of the string in the array, will skip.

st_file_pattern

string name of file suffix to search over

st_git_pattern

string name of file suffix based on which to consider if updating. If this is difference from st_file_pattern, use the file base with this suffix to detect if file has been changed. This is needed to detect if mlx files have changed for rmd files, where rmd files are not git tracked.

st_folder_pdf

string subfolder where to store the pdf file, if just empty, store in rmd folder

st_folder_html

string subfolder where to store the html file, if just empty, store in rmd folder

st_folder_R

string subfolder where to store the R file, if just empty, store in rmd folder

bl_gen_if_git_old

boolean if true then even if RMD files do not have git status change, still update pdf and html files.

bl_recursive

boolean if to search in folders recursively

bl_test

boolean if testing, meaning do not generate pdf html, just see which files are been

it_hierachy_lower_rmd

integer promote saved hierrachy for rmd files and resave.

it_hierachy_shift

int modification level of promotion from bookdown hierachy to own file hierarchy for individual files

it_toc_depth

rmd own file outputs toc levels to show

ls_bool_convert

list of booleans to generate pdf, html and or R file. Generate only HTML for example. considered included, searched and found

ls_bool_remove

list of booleans contorling if removing certain files in the same directory where the rmd file is

Value

a list of string paths of files generated

  • ls_spt_pdf_generated - a list of pdf file names

  • ls_spt_html_generated - a list of html file names

  • ls_spt_R_generated - a list of R file names generated

#'

Author

Fan Wang, http://fanwangecon.github.io

Examples

ar_spt_root = c('C:/Users/fan/R4Econ/amto/array/', 'C:/Users/fan/R4Econ/math/integration')
ar_spt_root = c('C:/Users/fan/R4Econ/math/integration')
ar_spt_root = c('C:/Users/fan/R4Econ/development/inout')
ar_spn_skip <- c('matrix', 'tibble', '_main', '_mod')
ff_sup_clean_rmd(ar_spt_root, ar_spn_skip)
#> Search and Check
#> NO CHNGE: C:/Users/fan/R4Econ/development/inout/fs_path.Rmd
#> NO CHNGE: C:/Users/fan/R4Econ/development/inout/fs_rmd_pdf_html.Rmd
#> NO CHNGE: C:/Users/fan/R4Econ/development/inout/fs_text_save.Rmd
#> NO CHNGE: C:/Users/fan/R4Econ/development/inout/main.Rmd
#> Generated pdf files:
#> [1] ""
#>    
#> "" 
#> 
#> Generated html files:
#> [1] ""
#>    
#> "" 
#> 
#> Generated R files:
#> [1] ""
#>    
#> "" 
#> 
#> $ls_spt_pdf_generated
#> character(0)
#> 
#> $ls_spt_html_generated
#> character(0)
#> 
#> $ls_spt_R_generated
#> character(0)
#> 
# ff_sup_clean_rmd(ar_spt_root, ar_spn_skip, bl_test = FALSE, bl_gen_if_git_old = TRUE)