<!--
%\VignetteEngine{knitr}
%\VignetteIndexEntry{An Introduction to qdap}
-->

```{r setup, include=FALSE}
# set global chunk options
library(knitr)
```

# qdap Package Vignette

This is a temporary place holder for the actual *Introduction to qdap Vignette*.  The HTML vignette contains many images and is larger in size (~2.3 mb).  Rather than housing the HTML document on [CRAN](https://CRAN.R-project.org) I am opting to store the Rmd file internally and the user will have to manually run `knitr` to render the HTML version.  The user may do this and replace this temporary vignette via the following options.  After running this the user may call the following to access the actual Introduction Vignette:

```{r eval=FALSE}
browseVignettes(package = 'qdap')
```

## (1) Via the `build_qdap_vignette` Function    

To use `knitr` to build the HTML file from the Rmd file (~4 minutes build time):

```{r eval=FALSE}
build_qdap_vignette()
```

or to download the latest CRAN version HTML use (< 30 seconds build time):

```{r eval=FALSE}
build_qdap_vignette(TRUE)
```

## (2) Manual `knitr` Code to Build It     

```{r eval=FALSE}
path <- system.file("Rmd_vignette", package = "qdap")
path2 <- system.file("doc", package = "qdap")

fls <- paste0("qdap_vignette", c(".Rmd", ".html", ".R"))
new <- file.path(path, fls)
old <- file.path(path2, fls)
   
knitr::knit(new[1], output = old[3], tangle=TRUE)
knitr::knit2html(new[1], output = old[2], stylesheet=file.path(path, 'css/style.css'),
    options=c("use_xhtml","smartypants","mathjax","highlight_code", "base64_images"))
file.copy(new[1], old[1], overwrite = TRUE)
```


## (3) Manually Download the HTML from the Internet         

The `knitr` built HTML approach above takes about 4 minutes.  The user may choose the faster approach (< 30 seconds) that downloads the HTML file directly from the Internet (this is for the latest CRAN release of `qdap`).  The following script uses the HTML download approach:

```{r eval=FALSE}
knitr::knit(new[1], output = old[3], tangle=TRUE)
file.copy(new[1], old[1], overwrite = TRUE)

url <- paste0("https://raw.githubusercontent.com/trinker/qdap", 
    "/master/inst/Rmd_vignette/qdap_vignette.html")

bin <- RCurl::getBinaryURL(url, ssl.verifypeer = FALSE)
temp <- tempdir()
con <- file(old[2], open = "wb")
writeBin(bin, con)
close(con)
```






