Skip to content
Prev 6577 / 12125 Next

[R-pkg-devel] How to build *-package description from *-package.R files ... and a luser/newbie question about pkgdown

Regarding 'pkgdown', can't you just use the default directory , docs/, that pkgdown populates? When you push to your repository, github will automatically regenerate the pkgdown website (for this to work, you need to go to the settings on your github repo and activate building the website). 

As to documentation, go to the github site of pkgdown and start from there. To customise the site, you can add an yaml file, as documented in pkgdown. 

I am not sure why you wish to use DIY directory for the site generated by pkgdown. When you run build_site(), pkgdown builds it and opens it in a browser by default. Also, it only rebuilds the pages that have changed since the previous built. So, it is useful also during development. I don't remember at the moment if you could even set it up to watch for changes in the package and rebuild the site behind the scene. 


Georgi Boshnakov


-----Original Message-----
From: R-package-devel <r-package-devel-bounces at r-project.org> On Behalf Of Duncan Murdoch
Sent: 12 February 2021 13:50
To: Chris Evans <chrishold at psyctc.org>; r-package-devel at r-project.org
Subject: Re: [R-pkg-devel] How to build *-package description from *-package.R files ... and a luser/newbie question about pkgdown
On 12/02/2021 6:28 a.m., Chris Evans wrote:
c
There are two general approaches for writing help pages in R.

The older approach (that I use) is to use functions like prompt() and
promptPackage() to create skeletons of documentation in the man directory, then edit them by hand.  The main disadvantage of this approach is that the Rd format is pretty ugly:  it's kind of like LaTeX, but different enough that even if you know LaTeX, you'll have to spend some time learning it.  It's also a bit of a pain to keep your documentation in sync with your source code:  when you change the arguments to a function, you don't get automatic changes to the help page.

RStudio has pretty good support for this approach, in that you can preview the pages as you work on them, it knows a bit about their syntax so things are highlighted nicely, and there are easy methods to jump from a function to the corresponding .Rd file.

To set this up you uncheck the "Generate documentation with ROxygen" 
option in the project build tools options.  That's it!

The approach that a lot of newer packages use is to generate the .Rd files from comments in the .R files using Roxygen2.  In recent versions of Roxygen2, what you type can be entered in Markdown instead of Rd format.  Some parts of the Rd file will be generated automatically, so you don't need to type them at all:  that's another advantage.

What I don't like about this approach is:

  - Mixing source code and documentation makes your source files bigger which discourages careful documentation and makes it harder to read the code.  Source and docs are different things, so in my opinion, they shouldn't be mixed in the same file.

  - I don't think RStudio supports a "Preview" for the help page for a function (but I might be wrong about this, since I don't use it much).

On the other hand, it's definitely quicker to learn and to get minimal documentation out of the Roxygen approach.

In my opinion, what would be ideal is to have separate files for source and docs, with a less ugly format for the docs, and some kind of automatic link between source and doc files so updates to one are reflected in the other (or at least differences are signalled).
I don't use pkgDown, so can't comment on these questions.

Duncan Murdoch
______________________________________________
R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel