print_doc.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_BINDINGS_PYTHON_PRINT_DOC_HPP
13 #define MLPACK_BINDINGS_PYTHON_PRINT_DOC_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 #include "get_printable_type.hpp"
18 
19 namespace mlpack {
20 namespace bindings {
21 namespace python {
22 
35 template<typename T>
36 void PrintDoc(const util::ParamData& d,
37  const void* input,
38  void* /* output */)
39 {
40  const size_t indent = *((size_t*) input);
41  std::ostringstream oss;
42  oss << " - ";
43  if (d.name == "lambda") // Don't print Python keywords.
44  oss << d.name << "_ (";
45  else
46  oss << d.name << " (";
47  oss << GetPrintableType<typename std::remove_pointer<T>::type>(d) << "): "
48  << d.desc;
49 
50  // Print a default, if possible.
51  if (!d.required)
52  {
53  // Call the correct overload to get the default value directly.
54  if (d.cppType == "std::string" || d.cppType == "double" ||
55  d.cppType == "int" || d.cppType == "std::vector<int>" ||
56  d.cppType == "std::vector<std::string>" ||
57  d.cppType == "std::vector<double>")
58  {
59  std::string defaultValue = DefaultParamImpl<T>(d);
60  oss << " Default value " << defaultValue << ".";
61  }
62  }
63 
64  std::cout << util::HyphenateString(oss.str(), indent + 4);
65 }
66 
67 } // namespace python
68 } // namespace bindings
69 } // namespace mlpack
70 
71 #endif
strip_type.hpp
Definition: add_to_po.hpp:21
void PrintDoc(const util::ParamData &d, const void *input, void *)
Print the docstring documentation for a given parameter.
Definition: print_doc.hpp:36
The core includes that mlpack expects; standard C++ includes and Armadillo.
std::string desc
Description of this parameter, if any.
Definition: param_data.hpp:58
python
Definition: CMakeLists.txt:5
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
if(BUILD_GO_BINDINGS) find_package(Go 1.11.0) if(NOT GO_FOUND) macro(add_go_binding name) endmacro() return() endif() find_package(Gonum) if(NOT GONUM_FOUND) macro(add_go_binding name) endmacro() endif() set(BINDING_SOURCES get_type.hpp get_param.hpp get_printable_param.hpp go_option.hpp mlpack/arma_util.h mlpack/arma_util.hpp mlpack/cli_util.h mlpack/cli_util.hpp print_class_defn.hpp print_cpp.cpp print_cpp.hpp print_defn_input.hpp print_defn_output.hpp print_doc.hpp print_doc_functions.hpp print_doc_functions_impl.hpp print_go.hpp print_go.cpp print_h.hpp print_h.cpp print_import_decl.hpp print_input_processing.hpp print_method_config.hpp print_method_init.hpp print_output_processing.hpp camel_case.hpp strip_type.hpp) set(CGO_SOURCES mlpack/arma_util.go mlpack/cli_util.go mlpack/doc.go) set(CAPI_SOURCES mlpack/capi/arma_util.cpp mlpack/capi/arma_util.h mlpack/capi/arma_util.hpp mlpack/capi/cli_util.cpp mlpack/capi/cli_util.h mlpack/capi/cli_util.hpp) set(UTIL_SOURCES mlpack/capi/arma_util.cpp mlpack/capi/cli_util.cpp) set(TEST_SOURCES tests/go_binding_test.go) add_custom_target(go ALL DEPENDS mlpack) add_custom_target(go_copy ALL DEPENDS mlpack) if(BUILD_TESTS) foreach(test_file $
Definition: CMakeLists.txt:1
std::string name
Name of this parameter.
Definition: param_data.hpp:56
bool required
True if this option is required.
Definition: param_data.hpp:71
std::string HyphenateString(const std::string &str, int padding)
 * Hyphenate a string or split it onto multiple 80-character lines, with some  * amount of padding on...
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84