Skip to content

Commit

Permalink
Process all sections
Browse files Browse the repository at this point in the history
Only the first section was being processed. Any later sections were
dropped silently.

Fixes yihui#25.
  • Loading branch information
joshuaulrich committed Mar 15, 2024
1 parent 89e828b commit 964a8bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions R/rd2roxygen.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 964a8bb

Please sign in to comment.