Skip to content

Commit

Permalink
New website pipeline 2 aaron rdocs (#14)
Browse files Browse the repository at this point in the history
* R pdf docs generation

* add r jenkinsfile

* move rscript steps to runtime

* use r setup and unit test func

* make r before cd

* trying minimal r setup

* force r lib path

* force r lib path eRRywhere

* try less steps

* add texinfo dep

* fixup add texinfo dep

* add texlive dep

* add font dep and fix encoding issue

* fix R generation
  • Loading branch information
ThomasDelteil authored and aaronmarkham committed Aug 16, 2019
1 parent 7aafeec commit eee99da
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Depends:
LinkingTo: Rcpp
VignetteBuilder: knitr
RoxygenNote: 6.1.1
Encoding: UTF-8
14 changes: 14 additions & 0 deletions R-package/src/export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace mxnet {
namespace R {

// docstring related function.
std::string MakeDocString(mx_uint num_args,
const char **arg_names,
Expand Down Expand Up @@ -76,6 +77,15 @@ std::string ExportDocString(const std::string& docstring) {
return os.str();
}

std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) {
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
}
return str;
}

void ExportVArgFunction(std::ostream& os, // NOLINT(*)
const std::string& func_name,
const std::string& docstr) {
Expand Down Expand Up @@ -118,6 +128,10 @@ void Exporter::Export(const std::string& path) {
|| fname == "mx.varg.symbol.min") continue;
Rcpp::List func_info(scope->get_function(fname));
std::string docstr = Rcpp::as<std::string>(func_info[2]);

docstr = ReplaceAll(docstr, std::string("\a"), std::string("\\a"));
docstr = ReplaceAll(docstr, std::string("\b"), std::string("\\b"));

if (docstr.find("@export") == std::string::npos) continue;
if (fname.find("mx.varg.") == 0) {
ExportVArgFunction(script, fname, docstr);
Expand Down
9 changes: 6 additions & 3 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1511,15 +1511,18 @@ build_r_docs() {
build_docs_setup
r_root='R-package'
r_pdf='mxnet-r-reference-manual.pdf'
docs_build_path="$r_root/$r_pdf"
r_build='build'
docs_build_path="$r_root/$r_build/$r_pdf"
artifacts_path='docs/_build/r_artifacts.tgz'

mkdir -p $docs_build_path

unittest_ubuntu_minimal_R

pushd $r_root

#R_LIBS=/tmp/r-site-library R -e "roxygen2::roxygenize()"
R_LIBS=/tmp/r-site-library R CMD Rd2pdf . --no-preview --encoding=utf8 -o $docs_build_path
R_LIBS=/tmp/r-site-library R CMD Rd2pdf . --no-preview --encoding=utf8 -o $r_build/$r_pdf

popd

GZIP=-9 tar zcvf $artifacts_path -C $docs_build_path .
Expand Down

0 comments on commit eee99da

Please sign in to comment.