R/rd2md_all.R

#' @title The rd2md_all() function batch converts .rd files to .md files
#'
#' @description uses the Rd2md::Rd2markdown function inside base::lapply
#'
#' @param dir_man_rd a character string for the directory containing .rd files
#' @param dir_man_md a character string for the directory to output .md files
#'
#' @return nothing is returned, but external .md files are written to dir_man_md
#' @export
#'
#' @seealso \code{\link[Rd2md]{Rd2markdown}}
#'
#' @examples
#'
rd2md_all = function(dir_man_rd,dir_man_md){

  Rds = list.files(paste0(dir_man_rd),pattern=".Rd")

  invisible(lapply(Rds,FUN=function(Rd_one){
    # xx=1
    # paste0(dir_man,Rds[xx])
    # Rd_one = Rds[[1]]

    in_rd = paste0(dir_man_rd,Rd_one)

    out_md = gsub(paste0(dir_man_md,Rd_one),pattern=".Rd",replacement=".md")

    Rd2md::Rd2markdown(rdfile=in_rd, outfile=out_md, append = FALSE)

    # if html output desired, use
    # tools::Rd2HTML(Rd=in_rd, out=out_html)

  }))
  message(paste('writing .md files into',dir_man_md))
}
mikejacktzen/datzen documentation built on June 14, 2019, 5:23 p.m.