From 964a8bbddf80c98cd6384d31a40a788fb12b2f27 Mon Sep 17 00:00:00 2001 From: Joshua Ulrich Date: Fri, 15 Mar 2024 12:35:44 -0500 Subject: [PATCH] Process all sections Only the first section was being processed. Any later sections were dropped silently. Fixes #25. --- R/rd2roxygen.R | 10 +++++++--- R/utils.R | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/rd2roxygen.R b/R/rd2roxygen.R index f5ab07d..8b10515 100644 --- a/R/rd2roxygen.R +++ b/R/rd2roxygen.R @@ -27,9 +27,13 @@ parse_file = function(path) { out$usage = reconstruct(untag(rd$usage)) out$desc = gsub("$\n+|\n+^", "", reconstruct(untag(rd$description))) out$details = reconstruct(untag(rd$details)) - out$section = paste(reconstruct(untag(rd$section[1])), - reconstruct(untag(rd$section[-1])), sep = ': ') - if (length(out$section) == 0) out$section = NULL + + # Process sections + out$section = lapply(rd[names(rd) == "section"], function(section) { + paste(reconstruct(untag(section[1])), + reconstruct(untag(section[-1])), sep = ': ') + }) + out$format = reconstruct(untag(rd$format)) out$value = reconstruct(untag(rd$value)) out$note = reconstruct(untag(rd$note)) diff --git a/R/utils.R b/R/utils.R index d1b086a..c0ca19a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -13,7 +13,8 @@ reconstruct = function(rd) { if (is.null(rd)) return() if (is.list(rd)) { - if (length(tag(rd)) && tag(rd) %in% c('\\item', '\\tabular', '\\eqn', '\\deqn', '\\link')) { + multi = c('\\section', '\\subsection', '\\item', '\\tabular', '\\eqn', '\\deqn', '\\link') + if (length(tag(rd)) && tag(rd) %in% multi) { if (tag(rd) == '\\link') return(paste('\\link', sprintf('[%s]', attr(rd, 'Rd_option')), '{', rd, '}', sep = "")) if (length(rd) == 2) {