From ea39cd3c8c4e7aa70dd9cb3d902a3bdf87737472 Mon Sep 17 00:00:00 2001 From: Yashwant Date: Tue, 6 Oct 2020 21:08:37 +0530 Subject: [PATCH] Fix R documentation. --- src/mlpack/bindings/R/print_R.cpp | 3 ++- .../bindings/R/print_doc_functions_impl.hpp | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mlpack/bindings/R/print_R.cpp b/src/mlpack/bindings/R/print_R.cpp index bf047c2769..5b089cbd28 100644 --- a/src/mlpack/bindings/R/print_R.cpp +++ b/src/mlpack/bindings/R/print_R.cpp @@ -92,7 +92,8 @@ void PrintR(const util::BindingDetails& doc, cout << "#'" << endl; // Next, print information on the output options. - cout << "#' @return A list with several components:" << endl; + if (outputOptions.size() > 0) + cout << "#' @return A list with several components:" << endl; for (size_t i = 0; i < outputOptions.size(); ++i) { diff --git a/src/mlpack/bindings/R/print_doc_functions_impl.hpp b/src/mlpack/bindings/R/print_doc_functions_impl.hpp index 2273f83197..dcdfd5d15d 100644 --- a/src/mlpack/bindings/R/print_doc_functions_impl.hpp +++ b/src/mlpack/bindings/R/print_doc_functions_impl.hpp @@ -61,10 +61,10 @@ inline std::string PrintValue(const T& value, bool quotes) { std::ostringstream oss; if (quotes) - oss << "\""; + oss << "`"; oss << value; if (quotes) - oss << "\""; + oss << "`"; return oss.str(); } @@ -76,7 +76,7 @@ inline std::string PrintValue(const std::vector& value, bool quotes) { std::ostringstream oss; if (quotes) - oss << "\""; + oss << "`"; oss << "c("; if (value.size() > 0) { @@ -86,7 +86,7 @@ inline std::string PrintValue(const std::vector& value, bool quotes) } oss << ")"; if (quotes) - oss << "\""; + oss << "`"; return oss.str(); } @@ -229,7 +229,9 @@ std::string ProgramCall(const bool markdown, // Find out if we have any output options first. std::ostringstream ossOutput; - oss << "output <- "; + ossOutput << PrintOutputOptions(markdown, args...); + if (ossOutput.str() != "") + oss << "output <- "; oss << programName << "("; // Now process each input option. @@ -330,7 +332,7 @@ inline std::string ProgramCall(const std::string& programName) */ inline std::string PrintModel(const std::string& modelName) { - return "\"" + modelName + "\""; + return "`" + modelName + "`"; } /** @@ -339,7 +341,7 @@ inline std::string PrintModel(const std::string& modelName) */ inline std::string PrintDataset(const std::string& datasetName) { - return "\"" + datasetName + "\""; + return "`" + datasetName + "`"; } /** @@ -357,7 +359,7 @@ inline std::string ProgramCallClose() inline std::string ParamString(const std::string& paramName) { // For a R binding we don't need to know the type. - return "\"" + paramName + "\""; + return "`" + paramName + "`"; } /**