Autocomment expectations?
hughjonesd opened this issue · 2 comments
A global or local setting could convert
#' @expect equal(2)
to
# Should equal 2:
in the Rd file.
This could be enabled globally by an option, or something in the description file: Config/doctest/comments: TRUE
?
Or locally with #' @autocomment
(maybe with an "on/off" argument).
This has to work in the parsing output. That makes an @autocomment
tag tricky. You'd have to not simply strip_first_line()
during parsing, but put a comment back which could then be deleted. Then in format.rd_section_doctest
, you decide whether to delete those comments?
Or you could just have a global setting, and then no need to worry about how to "merge sections"....
A list of tests and matching comments:
equal(x) Equals x:
match(x) Matches regex "x":
gt(x) Should be greater than x:; similarly for gte, lt, lte
output(x) Output matches "x":
message(x) Shows a message:
warning(x) Emits a warning:
error(x) Errors:
length(x) Has length x:
setequal(x) Same elements as x:
mapequal(x) Same elements as x by name:
vector(ptype, size) Has type ptype and size size:
false() FALSE:
true() TRUE:
type(x) Type is x:
s3_class(x) Class is x:
s4_class(x) Class is x:
visible() Visible:
invisible() Invisible:
I think switching autocomment on or off would be useful, because some expectations are more helpful than others as documentation.
Or, maybe comments are only sometimes useful, and the whole idea is over the top because you should just add comments manually?
Indeed this seems unnecessary.