Skip to content

Commit

Permalink
fix minor errors and roxygenise
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakillo committed Feb 6, 2022
1 parent a073265 commit 79f7fc6
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 149 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Description: Facilitates citation of R packages used in analysis projects.
Depends: R (>= 3.0.0)
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports:
renv,
rmarkdown,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(cite_packages)
export(create_rmd)
export(get_citations)
export(get_csl)
export(get_pkgs_info)
export(nocite_references)
export(scan_packages)
6 changes: 3 additions & 3 deletions R/cite_packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' bibliography file in the YAML header of the Rmarkdown document.
#'
#' Finally, you can use \code{output = "citekeys"} to obtain a vector of citation keys,
#' and then call \code{\link{nocite_references()}} within an Rmarkdown document
#' and then call \code{\link{nocite_references}} within an Rmarkdown document
#' to cite these packages in the reference list without mentioning them in the text.
#'
#'
Expand All @@ -38,7 +38,7 @@
#' references are put into the text manually, they may need to be updated
#' periodically.
#'
#' @param output. Either "file" to generate a separate document with formatted citations
#' @param output Either "file" to generate a separate document with formatted citations
#' for all packages; "paragraph" to return a paragraph with in-text citations of
#' used packages, suitable to be used within an Rmarkdown document;
#' or "citekeys" to return a vector with citation keys.
Expand Down Expand Up @@ -145,7 +145,7 @@ cite_packages <- function(output = c("file", "paragraph", "citekeys"),
}

if (output == "citekeys") {
return(citekeys)
return(unlist(pkgs.df$citekeys))
}

}
6 changes: 4 additions & 2 deletions R/create_rmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @param out.format Output format. One of: "docx" (Word), "pdf", "html", "Rmd", or "md" (markdown).
#' @param Rmd.file Name of the Rmarkdown file to be created.
#' @param out.dir Directory to save the output document. Default is the working directory.
#' @param ... Further arguments for \code{\link{render_citations}}.
#'
#' @return An Rmarkdown file, if out.format = "Rmd", or a rendered document otherwise.
#' @noRd
Expand All @@ -23,7 +24,8 @@ create_rmd <- function(pkgs.df = NULL,
csl = NULL,
Rmd.file = "grateful-report.Rmd",
out.format = "html",
out.dir = getwd()) {
out.dir = getwd(),
...) {

use.csl <- ifelse(is.null(csl), "#csl: null", "csl: ")

Expand Down Expand Up @@ -64,7 +66,7 @@ create_rmd <- function(pkgs.df = NULL,
if (tolower(out.format) == "rmd") {
return(Rmd.file)
} else {
render_citations(Rmd.file, out.format = out.format, out.dir = out.dir)
render_citations(Rmd.file, out.format = out.format, out.dir = out.dir, ...)
file.remove(Rmd.file)
}

Expand Down
2 changes: 1 addition & 1 deletion R/get_citations.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ get_citations <- function(pkgs,

if (include.RStudio == TRUE) {
# Put an RStudio citation on the end
if (!require(rstudioapi)) {
if (!requireNamespace("rstudioapi")) {
stop("Please install the {rstudioapi} package to cite RStudio.")
} else {
rstudio_cit <- tryCatch(rstudioapi::versionInfo()$citation,
Expand Down
2 changes: 1 addition & 1 deletion R/get_pkgs_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ get_pkgs_info <- function(all.pkgs = TRUE,

citekeys <- get_citations(pkgs.df$pkg,
out.dir = out.dir,
bibfile = bib.file,
bib.file = bib.file,
include.RStudio = include.RStudio)

# Group all citations from same package
Expand Down
2 changes: 1 addition & 1 deletion R/scan_packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ scan_packages <- function(all.pkgs = TRUE, ...) {
pkgs <- sort(pkgs)

# Get package versions
pkgVersion <- Vectorize(packageVersion, SIMPLIFY = FALSE)
pkgVersion <- Vectorize(utils::packageVersion, SIMPLIFY = FALSE)
versions <- pkgVersion(pkgs)
versions <- unlist(lapply(versions, as.character))

Expand Down
135 changes: 77 additions & 58 deletions man/cite_packages.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions man/create_rmd.Rd

This file was deleted.

8 changes: 4 additions & 4 deletions man/get_citations.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 79f7fc6

Please sign in to comment.