Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S4 (@slot implementation) #85

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ S3method(format,rd_tag)
S3method(format,references_tag)
S3method(format,section_tag)
S3method(format,seealso_tag)
S3method(format,slot_tag)
S3method(format,source_tag)
S3method(format,title_tag)
S3method(format,usage_tag)
Expand Down
8 changes: 4 additions & 4 deletions R/rd-tag-api.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ format.arguments_tag <- function(x, ...) {
#' @S3method format slot_tag
format.slot_tag <- function(x, ...) {
names <- names(x$values)
items <- str_c("\\item{", names, "}{", x$values, "}", collapse = "\n\n")
str_c("\\section{Slots}\n\n",
"\\itemize{\n",
items <- str_c("\\item{\\code{", names, "}:}{", x$values, "}", collapse = "\n\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need a colon here - that's a formatting decision that should be left to the renderer of the Rd file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fully agree - I was religiously mimicking the mle-class.Rd style

str_c("\\section{Slots}{\n",
"\\describe{\n",
str_wrap(items, width = 60, exdent = 2, indent = 2),
"\n}\n")
"\n}\n}\n")
}


Expand Down
4 changes: 2 additions & 2 deletions inst/tests/test-rd-s4.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ test_that("@slot creates a new section and lists slots", {
setClass('test')
")[[1]]

expect_equal(get_tag(out, "slot")$values
})
expect_equal(get_tag(out, "slot")$values, c(a = "slot a", b = "slot b"))
})