Skip to content

Commit

Permalink
Updates to accommadate Roxygen2 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustT committed Nov 13, 2019
1 parent 628a1d7 commit 5ba5ba1
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 72 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: zoon
Type: Package
Title: Reproducible, Accessible & Shareable Species Distribution Modelling
Version: 0.6.3
Date: 2018-01-22
Version: 0.6.4
Date: 2019-11-13
Authors@R: c(person("Tom", "August", role = c("aut", "cre"),
email = "[email protected]"),
person("Tim", "Lucas", role = "aut", comment = c(ORCID = "0000-0003-4694-8107")),
Expand Down Expand Up @@ -38,4 +38,4 @@ VignetteBuilder: knitr
LazyData: TRUE
URL: https://github.com/zoonproject/zoon
BugReports: https://github.com/zoonproject/zoon/issues
RoxygenNote: 6.0.1
RoxygenNote: 7.0.0
134 changes: 81 additions & 53 deletions R/ZoonModuleParse.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,66 +22,95 @@ ZoonModuleParse <- function(modulePath) {

# Behaviour varies on the version of
# Roxygen2 being used
if ("fields" %in% names(rd)) {
if(packageVersion("roxygen2") >= "7.0.0"){
rds <- rd$sections
res <- lapply(
names(rds),
function(field, x) x[[field]]$value,
x = rds
)
names(res) <- names(rd$sections)

field_fun <- function (field, x) {
if ("section" %in% names(res)) {
sections <- paste0(res$section$title, ":", res$section$content)

# name sections
names(sections) <- rep("section", length(sections))

# replace old section with new sections
res[["section"]] <- NULL
res <- append(res, sections)

if ("values" %in% names(x[[field]])) {

named_tag <- list(x[[field]]$values)
names(named_tag) <- field
return (unlist(named_tag))

} else {

list_tag <- list()

for (i in seq_along(x[[field]]$title)) {
list_tag <- c(list_tag,
list(list(name = x[[field]]$title[i],
content = x[[field]]$content[i])))
}
return (list_tag)

}
}

res <- lapply(names(rd$fields),
field_fun,
rd$fields)

names(res) <- names(rd$fields)

if ("param" %in% names(res))
names(res$param) <- gsub("^param.", "", names(res$param))

} else {
res <- lapply(
names(rd),
function(field, x) x[[1]][[field]]$values,
rd
)
}

# flatten 'sections'
if ("section" %in% names(res)) {

sections <- lapply(
res$section,
function (x) {
paste0(x$name, ":", x$content)
if ("fields" %in% names(rd)) {

field_fun <- function (field, x) {

if ("values" %in% names(x[[field]])) {

named_tag <- list(x[[field]]$values)
names(named_tag) <- field
return (unlist(named_tag))

} else {

list_tag <- list()

for (i in seq_along(x[[field]]$title)) {
list_tag <- c(list_tag,
list(list(name = x[[field]]$title[i],
content = x[[field]]$content[i])))
}
return (list_tag)

}
}
)

# name sections
names(sections) <- rep("section", length(sections))

# replace old section with new sections
res[["section"]] <- NULL
res <- append(res, sections)

res <- lapply(names(rd$fields),
field_fun,
rd$fields)

names(res) <- names(rd$fields)

if ("param" %in% names(res))
names(res$param) <- gsub("^param.", "", names(res$param))

} else if(length(rd)==1){
res <- lapply(
names(rd),
function(field, x) x[[1]][[field]]$values,
rd
)
} else {
res <- lapply(
names(rd),
function(field, x) x[field]$values,
x = rd
)
}

# flatten 'sections'
if ("section" %in% names(res)) {

sections <- lapply(
res$section,
function (x) {
paste0(x$name, ":", x$content)
}
)

# name sections
names(sections) <- rep("section", length(sections))

# replace old section with new sections
res[["section"]] <- NULL
res <- append(res, sections)

}
}

# format params
if ("param" %in% names(res)) {

Expand All @@ -92,7 +121,6 @@ ZoonModuleParse <- function(modulePath) {
description = as.character(x[field]))
},
res$param

)

names(params) <- rep("param", length(params))
Expand Down
19 changes: 15 additions & 4 deletions man/BuildModule.Rd

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

11 changes: 9 additions & 2 deletions man/ChangeWorkflow.Rd

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

7 changes: 5 additions & 2 deletions man/FindExtent.Rd

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

6 changes: 4 additions & 2 deletions man/GetModuleList.Rd

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

11 changes: 8 additions & 3 deletions man/ZoonFigshare.Rd

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

10 changes: 8 additions & 2 deletions man/workflow.Rd

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

1 change: 0 additions & 1 deletion man/zoon.Rd

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

0 comments on commit 5ba5ba1

Please sign in to comment.