Skip to content

Commit

Permalink
R HTML docs source code (#4782)
Browse files Browse the repository at this point in the history
* Start docsite

* More docsite, vignettes do not work in R studio

* More docsite, need to fix vignettes

* Done with docsite?

* Use R CMD to install in r-build.sh

* Change readme, not totally happy with this

* Use R CMD build

* Update cpp-clients-multi image SHA

* Gradle tasks and script for building docsite

* Update gradle.properties

* Update readme

* Update files

* Remove mistaken comment
  • Loading branch information
alexpeters1208 committed Nov 16, 2023
1 parent cd416bd commit 6b1df15
Show file tree
Hide file tree
Showing 81 changed files with 2,268 additions and 1,890 deletions.
40 changes: 40 additions & 0 deletions R/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def buildRClient = Docker.registerDockerTask(project, 'rClient') {
include 'rdeephaven/R/**'
include 'rdeephaven/src/*.cpp'
include 'rdeephaven/src/Makevars'
include 'rdeephaven/vignettes/*.Rmd'
}
}
dockerfile {
Expand All @@ -64,6 +65,7 @@ def buildRClient = Docker.registerDockerTask(project, 'rClient') {
copyFile('rdeephaven/R/', "${prefix}/src/rdeephaven/R/")
copyFile('rdeephaven/src/*.cpp', "${prefix}/src/rdeephaven/src/")
copyFile('rdeephaven/src/Makevars', "${prefix}/src/rdeephaven/src/")
copyFile('rdeephaven/vignettes/*.Rmd', "${prefix}/src/rdeephaven/vignettes/")
copyFile('r-build.sh', "${prefix}/bin/rdeephaven")
runCommand("PREFIX=${prefix}; " +
'''set -eux ; \
Expand Down Expand Up @@ -155,5 +157,43 @@ def rClientDoc = Docker.registerDockerTask(project, 'rClientDoc') {
containerOutPath = "${prefix}/src/rdeephaven/man"
}

def rClientSite = Docker.registerDockerTask(project, 'rClientSite') {
// Only tested on x86-64, and we only build dependencies for x86-64
platform = 'linux/amd64'
copyIn {
from(layout.projectDirectory) {
include 'r-site.sh'
include 'rdeephaven/man/**'
}
}
copyOut {
into layout.projectDirectory.dir('rdeephaven/docs')
}
dockerfile {
from('deephaven/r-client-doc:local-build')
// We need the contents of 'man' to build the docsite
copyFile('rdeephaven/man/**', "${prefix}/src/rdeephaven/man/")
runCommand("mkdir -p ${prefix}/src/rdeephaven/docs")
runCommand('''echo "status = tryCatch(" \
" {" \
" install.packages('pkgdown', repos='http://cran.us.r-project.org'); " \
" 0" \
" }," \
" error=function(e) 1," \
" warning=function(w) 2" \
");" \
"print(paste0('status=', status));" \
"quit(save='no', status=status)" | \
MAKE="make -j`getconf _NPROCESSORS_ONLN`" R --no-save --no-restore
''')
// Keep this after the package installs above;
// it is likely it changes more frequently.
copyFile('r-site.sh', "${prefix}/bin/rdeephaven")
}
parentContainers = [ project.tasks.getByName('rClientDoc') ]
entrypoint = ["${prefix}/bin/rdeephaven/r-site.sh"]
containerOutPath = "${prefix}/src/rdeephaven/docs"
}

deephavenDocker.shouldLogIfTaskFails testRClient
tasks.check.dependsOn(testRClient)
20 changes: 8 additions & 12 deletions R/r-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ fi
trap 'rm -f src/*.o src/*.so' 1 2 15
rm -f src/*.o src/*.so

MAKE="make -j${NCPUS}" R --no-save --no-restore <<EOF
status = tryCatch(
{
install.packages(".", repos=NULL, type="source")
0
},
error=function(e) 1,
warning=function(w) 2
)
print(paste0('status=', status))
quit(save='no', status=status)
EOF
MAKE="make -j${NCPUS}"
cd .. && \
rm -f rdeephaven_*.tar.gz && \
R CMD build rdeephaven && \
R CMD INSTALL --no-multiarch --with-keep.source rdeephaven_*.tar.gz && \
rm -f rdeephaven_*.tar.gz && \
cd rdeephaven ||
exit 1

rm -f src/*.o src/*.so

Expand Down
25 changes: 25 additions & 0 deletions R/r-site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -euo pipefail

if [ -z "${DH_PREFIX}" ]; then
echo "$0: Environment variable DH_PREFIX is not set, aborting." 1>&2
exit 1
fi

source $DH_PREFIX/env.sh

cd $DH_PREFIX/src/rdeephaven

R --no-save --no-restore <<EOF
library('pkgdown')
status = tryCatch(
{
pkgdown::build_site()
0
},
error=function(e) 1
)
print(paste0('status=', status))
quit(save='no', status=status)
EOF
5 changes: 5 additions & 0 deletions R/rdeephaven/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^doc$
^Meta$
4 changes: 4 additions & 0 deletions R/rdeephaven/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ lib/cpp-dependencies/src
lib/cpp-dependencies/env.sh
*.o
*.so
docs
inst/doc
/doc/
/Meta/
8 changes: 7 additions & 1 deletion R/rdeephaven/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ License: Apache License (== 2.0)
Depends: R (>= 3.5.3)
Imports: Rcpp (>= 1.0.10), arrow (>= 12.0.0), R6 (>= 2.5.0), dplyr (>= 1.1.0), utils (>= 3.5.3)
LinkingTo: Rcpp
Suggests: testthat (>= 3.0.0), lubridate (>= 1.9.0), zoo (>= 1.8-0)
Suggests:
testthat (>= 3.0.0),
lubridate (>= 1.9.0),
zoo (>= 1.8-0),
knitr,
rmarkdown
Config/testthat/edition: 3
RoxygenNote: 7.2.3
VignetteBuilder: knitr
Loading

0 comments on commit 6b1df15

Please sign in to comment.