p_text2pdf: Download Package Documentation in Text Files

View source: R/p_text2pdf.R

p_text2pdfR Documentation

Download Package Documentation in Text Files

Description

p_text extracts from CRAN the most relevant information related to one or several packages and print them in a text file which can be tailored to various formats: *.txt, *.md, *.tex for further treatment.

p_text2md has preset values for markdown files.

p_text2tex has preset values for latex files.

p_text2pdf has preset values for pdf files.

Usage

p_text(..., char = NULL, filename = "txtpkgs.txt", dir = ".",
  beforetext = "", f_maintext = funmaintext, sep1 = "== ",
  sep2 = " ==", eol = "\n", README = TRUE, NEWS = TRUE,
  vignettes = TRUE, aftertext = "", editor = FALSE, pager = FALSE,
  verbose = TRUE, crandb = get("crandb", envir = .GlobalEnv),
  repos = getOption("repos")[1])

p_text2md(..., char = NULL, filename = "mdpkgs.md", dir = ".",
  beforetext = funheadermd(), f_maintext = funmaintext, sep1 = "# ",
  sep2 = "  ", eol = "  \n", README = TRUE, NEWS = TRUE,
  vignettes = TRUE, aftertext = "", editor = FALSE, pager = FALSE,
  verbose = TRUE, crandb = get("crandb", envir = .GlobalEnv),
  repos = getOption("repos")[1])

p_text2tex(..., char = NULL, filename = "texpkgs.tex", dir = ".",
  beforetext = funheadertex(), f_maintext = funmaintex,
  sep1 = "\\section{", sep2 = "}", eol = " \\\\\n",
  README = TRUE, NEWS = TRUE, vignettes = TRUE,
  aftertext = funfootertex(), editor = FALSE, pager = FALSE,
  verbose = TRUE, crandb = get("crandb", envir = .GlobalEnv),
  repos = getOption("repos")[1])

p_text2pdf(..., char = NULL, filename = "pdfpkgs.pdf", dir = ".",
  beforetext = funheadertex(), f_maintext = funmaintex,
  sep1 = "\\section{", sep2 = "}", eol = " \\\\\n",
  README = TRUE, NEWS = TRUE, vignettes = TRUE,
  aftertext = funfootertex(), cleantex = TRUE, openpdf = FALSE,
  verbose = TRUE, crandb = get("crandb", envir = .GlobalEnv),
  repos = getOption("repos")[1])

Arguments

...

any format recognized by cnsc, including list. A vector or packages or a named list of packages (with names being the keywords).

char

(name to) a character vector or a list. Use this argument if ... fails or if you call the function from another function. If used, argument ... is ignored.

filename

character. The file name with extension. If ... (or ...) is a list, the names of the list will be appended to filename.

dir

character. The directory in which the files are read or written. Default value "." is the current directory.

beforetext

character. The text written at the beginning of the file.

f_maintext

function name. The function used to extract the main text from crandb (supplied with no parenthesis).

sep1

character. The symbols written just before each package name.

sep2

character. The symbols written just after each package name. If used with with mardkdown, add two blank characters at the end to force a new line.

eol

character. The end of line for the main text (but not for the header and the footer). "\n" for text, " \n" for rmarkdown, " \\ \n" for latex.

README

logical. Write the line related to the README page, if it exists.

NEWS

logical. Write the line related to the NEWS page, if it exists.

vignettes

logical. Write the lines related to the vignette(s), if they exist.

aftertext

character. The text written at the end of the file.

editor

logical. Open the text file with editor.

pager

logical. Open the text file with pager.

verbose

logical. List the generated file(s).

crandb

data.frame crandb. The data.frame of CRAN packages.

repos

character. The address of your local CRAN.

cleantex

logical. Remove the .tex file(s).

openpdf

logical. Open the pdf files in the default pdf viewer.

Examples

## In real life, download crandb from CRAN or load it from your directory
## with functions crandb_down() or crandb_load().
## In this example, we use a small file.
crandb_load(system.file("data", "zcrandb.rda", package = "RWsearch"))

## Search in crandb
vec <- s_crandb(search, find, select = "PT") ; vec
lst <- s_crandb_list(thermodynamic, "chemical reaction") ; lst
lst2 <- lapply(lst, function(x) x[1:2]) ; lst2
dir <- file.path(tempdir(), "ptext")

## Generate a txt file

p_text(vec[1:5], filename = "SearchFind.txt", dir = dir,
       repos = "https://cloud.r-project.org")

## Generate 2 tex + 2 pdf files (10-20 seconds)
## Try the options cleantex = FALSE and openpdf = TRUE on lst
if (interactive()) {
p_text2pdf(lst2, dir = dir, cleantex = TRUE, openpdf = FALSE,
           repos = "https://cloud.r-project.org")
}


RWsearch documentation built on May 29, 2024, 6:42 a.m.