Skip to content

Commit

Permalink
update pkgdown building
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Nov 17, 2023
1 parent 43a0fd2 commit e64d909
Show file tree
Hide file tree
Showing 36 changed files with 64 additions and 11 deletions.
7 changes: 7 additions & 0 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ setMethod(
#' x = list(a=list(b=list(c="~/test.txt")))
#' .expandList(x)
#' @export
#' @keywords internal
.expandList <- function(x) {
if (is.list(x))
return(lapply(x, .expandList))
Expand All @@ -79,6 +80,7 @@ setMethod(
#' l = list(a="a", b="b")
#' .getSubscript(l, 1) == .getSubscript(l, "a")
#' @export
#' @keywords internal
.getSubscript <- function(lst, i) {
if (is.character(i))
return(grep(paste0("^", i, "$"), names(lst)))
Expand Down Expand Up @@ -183,6 +185,7 @@ setMethod(
#' @param object an object of \code{"\linkS4class{Config}"}
#'
#' @return an object of \code{"\linkS4class{Config}"}
#' @keywords internal
setGeneric(".reformat", function(object)
standardGeneric(".reformat"))

Expand Down Expand Up @@ -264,6 +267,7 @@ setMethod(
#' @param filename file path to config file
#'
#' @seealso \url{https://pep.databio.org/}
#' @keywords internal
.loadConfig = function(filename = NULL,
amendments = NULL) {
if (!file.exists(filename)) {
Expand Down Expand Up @@ -320,6 +324,7 @@ setMethod(
#' @return possibly updated config
#'
#' @return config
#' @keywords internal
.applyAmendments = function(cfg, amendments = NULL) {
if (!is.null(amendments)) {
for (amendment in amendments) {
Expand All @@ -344,6 +349,7 @@ setMethod(
#'
#' @return config data enriched in imported sections, if imports existed in the
#' input
#' @keywords internal
.applyImports = function(cfg_data, filename) {
if (!CFG_P_MODIFIERS_KEY %in% names(cfg_data) ||
!CFG_IMPORT_KEY %in% names(cfg_data[[CFG_P_MODIFIERS_KEY]]))
Expand All @@ -365,6 +371,7 @@ setMethod(
#' @param filename path to the config file
#'
#' @return string project name
#' @keywords internal
.inferProjectName = function(cfg, filename) {
if (!is.null(cfg$name))
return(cfg$name)
Expand Down
11 changes: 11 additions & 0 deletions R/project.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ setMethod(
#' @param object an object of \code{"\linkS4class{Project}"}
#'
#' @return modified Project object
#' @keywords internal
setGeneric(".modifySamples", function(object)
standardGeneric(".modifySamples"))

Expand Down Expand Up @@ -375,6 +376,7 @@ setMethod(
#' @param .Object an object of \code{"\linkS4class{Project}"}
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.removeAttrs <- function(.Object) {
if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object)))
return(.Object)
Expand All @@ -399,6 +401,7 @@ setMethod(
#' @param .Object an object of \code{\link{Project-class}}
#'
#' @return an object of \code{\link{Project-class}}
#' @keywords internal
.appendAttrs <- function(.Object) {
if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object)))
return(.Object)
Expand Down Expand Up @@ -432,6 +435,7 @@ setMethod(
#' @param .Object an object of \code{"\linkS4class{Project}"}
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.duplicateAttrs <- function(.Object) {
if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object)))
return(.Object)
Expand All @@ -450,6 +454,7 @@ setMethod(
#' @param .Object an object of \code{"\linkS4class{Project}"}
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.implyAttrs = function(.Object) {
if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object)))
return(.Object)
Expand Down Expand Up @@ -499,6 +504,7 @@ setMethod(
#' @param .Object an object of \code{"\linkS4class{Project}"}
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.deriveAttrs = function(.Object) {
if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object)))
return(.Object)
Expand Down Expand Up @@ -539,6 +545,7 @@ setMethod(
#' @param sampleTablePath a character string indicating a path to the sample table
#'
#' @return an data.frame with samples; one sample per row
#' @keywords internal
.loadSampleAnnotation = function(sampleTablePath) {
if (.safeFileExists(sampleTablePath)) {
samples = data.table::fread(sampleTablePath)
Expand All @@ -555,6 +562,7 @@ setMethod(
#' @param path string, a path to the subsample table to read and incorporate
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.loadSubsampleAnnotation = function(.Object, path) {
if (.safeFileExists(path)) {
subsamplesTable = data.table::fread(path)
Expand Down Expand Up @@ -608,6 +616,7 @@ setMethod(
#' @param subsampleAannotationPaths a vector of strings specifying the paths to sample
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.mergeAttrs = function(.Object, subsampleAannotationPaths) {
if (is.null(subsampleAannotationPaths))
return(.Object)
Expand All @@ -625,6 +634,7 @@ setMethod(
#' @param .Object an object of \code{"\linkS4class{Project}"}
#'
#' @return an object of \code{"\linkS4class{Project}"}
#' @keywords internal
.autoMergeDuplicatedNames = function(.Object) {
s = sampleTable(.Object)
sampleNames = s[[.Object@sampleNameAttr]]
Expand Down Expand Up @@ -675,6 +685,7 @@ setMethod(
#' @param .Object an object of \code{"\linkS4class{Project}"}
#' @param stIndex character string indicating a constructor-specified sample table index
#' @param sstIndex character string indicating a constructor-specified subsample table index
#' @keywords internal
.getTableIndexes <- function(.Object, stIndex, sstIndex) {
.getIndexVal <- function(spec, config, default, key) {
if (!is.null(spec))
Expand Down
14 changes: 14 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' path = "$HOME/my/path/string.txt"
#' .expandPath(path)
#' @export
#' @keywords internal
.expandPath = function(path) {
# helper function
removeNonWords = function(str) {
Expand Down Expand Up @@ -90,6 +91,7 @@
#' @examples
#' .strformat("~/{VAR1}{VAR2}_file", list(VAR1="hi", VAR2="hello"))
#' .strformat("$HOME/{VAR1}{VAR2}_file", list(VAR1="hi", VAR2="hello"))
#' @keywords internal
.strformat = function(string, args, parent = NULL) {
result = c()
# if parent provided, make the path absolute and expand it.
Expand Down Expand Up @@ -130,6 +132,7 @@
#'
#' @export
#' @return Target itself if already absolute, else target nested within parent.
#' @keywords internal
.makeAbsPath = function(perhapsRelative, parent) {
res = c()
for (pR in perhapsRelative) {
Expand All @@ -155,6 +158,7 @@

# Must test for is.null first, since is.na(NULL) returns a logical(0) which is
# not a boolean
#' @keywords internal
.isDefined = function(var) {
!(is.null(var) || is.na(var))
}
Expand All @@ -163,6 +167,7 @@
#'
#' @param path The path to check for seeming absolute-ness.
#' @return Flag indicating whether the \code{path} appears to be absolute.
#' @keywords internal
.isAbsolute = function(path) {
if (!is.character(path))
stop("The path must be character")
Expand All @@ -176,6 +181,7 @@
#' @import RCurl
#'
#' @return logical indicating whether a string is a valid URL
#' @keywords internal
.isValidUrl = function(str) {
ans = FALSE
if (grepl("www.|http:|https:", str)) {
Expand All @@ -189,6 +195,7 @@
#' @param path string to be checked
#'
#' @return a logical indicating whether it's an existing path or valid URL
#' @keywords internal
.safeFileExists = function(path) {
(.isValidUrl(path) || (!is.null(path) && file.exists(path)))
}
Expand All @@ -205,6 +212,7 @@
#' dataFrame=mtcars
#' listifiedDataFrame=.listifyDF(dataFrame)
#' @export
#' @keywords internal
.listifyDF = function(DF) {
if (!is.data.frame(DF))
stop("The input object must be a data.frame.")
Expand Down Expand Up @@ -296,6 +304,7 @@ fetchSamples = function(samples,
#' @param rgx string to expand in the system
#'
#' @return a list of all the elements after possible expansion
#' @keywords internal
.matchesAndRegexes = function(rgx) {
res = c()
for (i in rgx) {
Expand Down Expand Up @@ -327,6 +336,7 @@ fetchSamples = function(samples,
#' p = Project(file = projectConfig)
#' .printNestedList(config(p),level=2)
#' @export
#' @keywords internal
.printNestedList = function(lst, level = 0) {
if (!is.list(lst))
stop("The input is not a list, cannot be displayed.")
Expand Down Expand Up @@ -358,6 +368,7 @@ fetchSamples = function(samples,
#' l = list(a=list(b="test"))
#' .checkSection(l,c("a","b"))
#' .checkSection(l,c("c","b"))
#' @keywords internal
.checkSection = function(object, sectionNames) {
tryToNum = function(x) {
convertedX = suppressWarnings(as.numeric(x))
Expand All @@ -382,6 +393,7 @@ fetchSamples = function(samples,
#' @param config an object of \code{"\linkS4class{Config}"}
#'
#' @return a string which specifies a path to the sample table file
#' @keywords internal
.getSampleTablePathFromConfig = function(config) {
if (!CFG_SAMPLE_TABLE_KEY %in% names(config))
stop("Sample table not defined in config")
Expand All @@ -393,6 +405,7 @@ fetchSamples = function(samples,
#' @param config an object of \code{"\linkS4class{Config}"}
#'
#' @return string/vector of strings/NULL depending on the configuration
#' @keywords internal
.getSubSampleTablePathFromConfig = function(config) {
if (!CFG_SUBSAMPLE_TABLE_KEY %in% names(config))
return(NULL)
Expand All @@ -408,6 +421,7 @@ fetchSamples = function(samples,
#'
#' @return a boolean, TRUE if indicating the path seems to be pointing to a config,
#' or FALSE if the path seems to be pointing to an annotation file.
#' @keywords internal
.isCfg = function(filePath) {
if (endsWith(tolower(filePath), ".yaml") ||
endsWith(tolower(filePath), ".yml"))
Expand Down
11 changes: 0 additions & 11 deletions _pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,5 @@ articles:
contents:
- starts_with("feature")

reference:
- title: "pepr API"
desc: "Exported functions of `pepr`."
contents:
- -matches("\\.")
- title: "utilities"
desc: "Extra non-exported utility functions."
contents:
- .strformat
- .expandPath
- .printNestedList
news:
- one_page: true
1 change: 1 addition & 0 deletions man/dot-appendAttrs.Rd

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

1 change: 1 addition & 0 deletions man/dot-applyAmendments.Rd

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

1 change: 1 addition & 0 deletions man/dot-applyImports.Rd

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

1 change: 1 addition & 0 deletions man/dot-autoMergeDuplicatedNames.Rd

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

1 change: 1 addition & 0 deletions man/dot-checkSection.Rd

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

1 change: 1 addition & 0 deletions man/dot-deriveAttrs.Rd

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

1 change: 1 addition & 0 deletions man/dot-duplicateAttrs.Rd

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

1 change: 1 addition & 0 deletions man/dot-expandList.Rd

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

1 change: 1 addition & 0 deletions man/dot-expandPath.Rd

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

1 change: 1 addition & 0 deletions man/dot-getSampleTablePathFromConfig.Rd

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

1 change: 1 addition & 0 deletions man/dot-getSubSampleTablePathFromConfig.Rd

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

1 change: 1 addition & 0 deletions man/dot-getSubscript.Rd

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

1 change: 1 addition & 0 deletions man/dot-getTableIndexes.Rd

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

1 change: 1 addition & 0 deletions man/dot-implyAttrs.Rd

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

1 change: 1 addition & 0 deletions man/dot-inferProjectName.Rd

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

1 change: 1 addition & 0 deletions man/dot-isAbsolute.Rd

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

1 change: 1 addition & 0 deletions man/dot-isCfg.Rd

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

1 change: 1 addition & 0 deletions man/dot-isValidUrl.Rd

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

1 change: 1 addition & 0 deletions man/dot-listifyDF.Rd

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

1 change: 1 addition & 0 deletions man/dot-loadConfig.Rd

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

1 change: 1 addition & 0 deletions man/dot-loadSampleAnnotation.Rd

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

1 change: 1 addition & 0 deletions man/dot-loadSubsampleAnnotation.Rd

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

1 change: 1 addition & 0 deletions man/dot-makeAbsPath.Rd

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

1 change: 1 addition & 0 deletions man/dot-matchesAndRegexes.Rd

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

1 change: 1 addition & 0 deletions man/dot-mergeAttrs.Rd

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

Loading

0 comments on commit e64d909

Please sign in to comment.