How to add extra files to pkgdown site?

345 Views Asked by At

I have a package that contains some Javascript code as well as R code. I can use pkgdown to build a website hosted by Github for the R documentation in the package by setting things up properly and running

pkgdown::deploy_to_branch()

I can also use JSDoc to build a local website documenting the Javascript code, and place it in the docs directory that pkgdown uses, with links from the other parts. This works locally, but the JSDoc files aren't included when I deploy it to Github using the command above.

How do I tell pkgdown to include the JSDoc files in the website it deploys to Github?

The question really has nothing to do with JSDoc; I can think of it as having a subdirectory of files that I want deployed along with all the files that pkgdown produces.

1

There are 1 best solutions below

1
On

I found the answer to this: I need to consider the files produced by JSDoc as "assets" to be copied into the web site.

In detail:

I can produce those files anywhere I like. I chose to put them in a subdirectory named .JSDoc/javascript below the same directory where they live.

Then I need to edit the _pkgdown.yml file in the main directory of the package, and add a section containing

template:
  assets: path/to/.JSDoc

where path/to is relative to the main directory. Notice that I don't include the second part (javascript) of the subdir name.

Then when pkgdown::build_site() or pkgdown::deploy_to_branch() runs, it will copy everthing in that .JSDoc directory into the top level of the website that it is producing. Since I only have the javascript directory there, I get a top level directory in the final website named javascript. I can refer to that from other pkgdown files.