prepareRepo.R

################################################################################
# This script writes an introduction text and selected vignettes to the        #
# README.md file.                                                              #
#                                                                              #
# Author: Mira CĂ©line Klein                                                    #
# E-mail: mira.klein@inwt-statistic.de                                         #
################################################################################

library(dplyr)

devtools::build_vignettes()

topic <- "checkCodeStyle"

# Create md files of vignettes
knitr::knit(paste0("doc/", topic, ".Rmd"),
            paste0("inst/", topic, ".md"))
text <- readLines(paste0("inst/", topic, ".md"))

# Add folder "vignette" to image paths
picLines <- grep("\\(\\w+\\.PNG", text, value = FALSE)
text[picLines] <- gsub("\\(", "(vignettes/", x = text[picLines])

# Remove YAML header, add title
title <- text[2] %>%
  gsub("title: \"", "", .) %>%
  gsub("\"", "", .) %>%
  paste("#", .)
text <- c("", "", title, text[-(1:10)])

assign(topic, text)

text <- c("# INWTUtils",
          # Introduction
          "This repository contains a package which provides utility functions",
          "used by the INWT Statistics GmbH. This includes amongst others",
          "functions to check",
          "code for violations of style conventions and to keep the searchpath",
          "clean. In addition, an example R script is included.",
          checkCodeStyle)

writeLines(text, "README.md")

unlink(c(paste0("inst/", topic, ".md"), "inst/doc"), recursive = TRUE)
INWT/INWTUtils documentation built on May 22, 2024, 4:45 p.m.