Skip to content
Prev 9639 / 63421 Next

Documenting classes and methods: was [Rd] Re: R-devel Digest, Vol 3, Issue 23

Gordon Smyth wrote:
The "structure" of the skeletons (the \alias lines especially) are
intended to be used by the help system.  You're not meant to "use" these
directly, much of the time.  It's the case that the tools to work with
the .Rd structure haven't caught up yet, but please don't modify the
skeleton's structure arbitrarily.
Good point, but related to the behavior of "?".  It's related to a
number of other issues about multiple packages referring to the same
generic function.  Not likely to change for 1.7.1, but likely to be
different in several ways in 1.8
Seems ok to have separate discussion of arguments, but don't "abandon"
the rest of the material in the skeleton (see below).

Heavy use of extra arguments in the methods is a little bit worrisome. 
There is an efficiency penalty, though not likely serious in sizable
computations.  More basic (this is just my personal view), I like to
think of the function as having a single conceptual definition--what it
does and (by and large) what arguments it takes to describe what it
should do.  Then the methods are the implementation.  The function
description is likely what users, begining users particularly, want to
see.  More advanced users and programmers may also be concerned with the
implementation.

So, most of the time, one would like the function to define the
arguments, and the methods to work from these.

In some examples of extra arguments (the S3 print() methods, for
instance), these are style-setting parameters, or perhaps control
parameters for numeric computations.  It might be clearer in such cases
to say that "..." is always passed to a (class-dependant)
parameter-setting function.  Documenting that function is then a
separate step.

Again, this is just by way of what may help users to understand the
functions and help designers to write functions cleanly; not suggesting
you should be forced to take this route.
Don't do that.  It's not what you like that counts, it's what works with
the ? function, and your change will wipe out the ability of the help
functions to identify correctly which method is being documented.

For 1.8 (unfortunately, unlikely to be ironed out for 1.7.1), users
should be able to get documentation on the method, say, for function
f(x,y) corresponding to signature(x = "character", y = "numeric") by the
expression
  method ? f(x="character", y = "numeric")
(or something along these lines).

In any case, the \alias lines are crucial to going from any way of
requesting method documentation to the correct documentation.
It's a useful document to have.  The whole area of documentation and
online help is being worked on by a number of people, so there is the
"moving target" difficulty.

You mention in your document altering the output of the promptMethods
skeleton.  Adding material, up to a point, is OK, but changing or
deleting the "\" lines is not a good idea if you want the documentation
to work with R's (evolving) help system.  As noted, the \alias lines
should be left alone.

There are a few other points we can discuss off-list, not directly
related to this thread.
Commented on above--yes changes are in prospect.  Bioconductor may want
to encourage documentation even before things settle down--really for
the people in the project to assess whether guidelines are helpful at
this point.

As said, there will be some changes for 1.8, mostly additions to the
code that processes the online help requests. It's a fairly good guess
that the structure of \ lines, esp. the \alias lines, will be kept or
extended, not radically changed, so keeping the current prompt output of
these lines would be desirable.  If there are changes in the structure,
you're more likely to see tools to modify what you have if you follow
the current prompt output.

In the longer run, it would be useful to have a documentation system
based on a more modern form (e.g., XML), making possible more powerful
online help software.  Duncan Temple Lang and others have done some good
work on such systems.  My crystal ball is very foggy on what will happen
with the R community in this direction.

Regards,
 John