-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added update_documentation to quickly update everything and generate … #356
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,47 @@ | |
width = 6, | ||
scientific = FALSE) | ||
} | ||
|
||
#' @title Update documentation | ||
#' | ||
#' @description This functions generates the documentation for a package if both /man and /documentation folders exist within the project: | ||
#' \itemize{ | ||
#' \item{devtools::document(pkg=pkg) is used to generate Rd files} | ||
#' \item{Rd files are rendered using ?'anyfunction' eg ?visR} | ||
#' \item{Documentation is collected within 'pkg'.pdf. This pdf is written to the documentation folder} | ||
#' } | ||
#' | ||
#' @usage update_documentation(pkg = "~/visR") | ||
#' | ||
#' @param pkg Path to package. | ||
#' | ||
#' @return .Rd files inside man/ folder and an updated pdf within the documentation folder. | ||
#' @noRd | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' update_documentation(pkg = "~/visR") | ||
#' } | ||
|
||
update_documentation <- function(pkg = "~/visR", fileNm="visR") | ||
{ | ||
|
||
## Create Rd files document #### | ||
devtools::document(pkg = pkg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, this adds a {devtools} dependency (a pretty big one). If you choose to keep it, it needs to be added to DESCRIPTION There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if it is only for internal usage? I have moved it to my local folder now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, because the code was in the R folder, and was shipped as part of the package, it would need to be listed as a dependency. |
||
|
||
## Look for exported functions | ||
tmp <- data.frame(lines = trimws(suppressWarnings(readLines(paste0(pkg, "/NAMESPACE"))), which=("both")), stringsAsFactors = F) | ||
tmp <- data.frame(lines = tmp$lines[which(grepl("export", tmp$lines) == "TRUE")], stringsAsFactors = F) | ||
tmp <- data.frame(lines = gsub("export(", "", tmp$lines, fixed = TRUE)) | ||
fcts <- as.vector(gsub(")", "", tmp$lines, fixed = TRUE)) | ||
|
||
## Render Rd files | ||
for (j in 1:length(fcts)){ | ||
eval(parse(text=paste0("?",fcts[j]))) | ||
writeLines(paste0("?",fcts[j])) | ||
} | ||
|
||
## create pdf | ||
system(paste0("R CMD Rd2pdf ", pkg, "/man --force --no-preview --output='", pkg, "/documentation/", fileNm, ".pdf'")) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some details describing the need this function fulfills?
I see it creates a PDF of the help files. Is this something needed given that the package build already includes the PDF?
I personally find the website to be a much much much better representation of the help files compared to the PDFs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved it locally and see if we get the request for some documentation in pdf inside the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI
devtools::build_manual()