diff --git a/src/mlpack/bindings/markdown/CMakeLists.txt b/src/mlpack/bindings/markdown/CMakeLists.txt index 613284b8f7..f59c6f1e22 100644 --- a/src/mlpack/bindings/markdown/CMakeLists.txt +++ b/src/mlpack/bindings/markdown/CMakeLists.txt @@ -24,8 +24,6 @@ set(SOURCES "binding_info.hpp" "binding_info.cpp" "default_param.hpp" - "get_binding_name.hpp" - "get_binding_name.cpp" "get_param.hpp" "get_printable_param.hpp" "get_printable_param_name.hpp" @@ -208,8 +206,6 @@ function (post_markdown_setup) "${BINDING_SOURCE_DIR}/binding_info.hpp" "${BINDING_SOURCE_DIR}/binding_info.cpp" "${BINDING_SOURCE_DIR}/default_param.hpp" - "${BINDING_SOURCE_DIR}/get_binding_name.hpp" - "${BINDING_SOURCE_DIR}/get_binding_name.cpp" "${BINDING_SOURCE_DIR}/get_param.hpp" "${BINDING_SOURCE_DIR}/get_printable_param.hpp" "${BINDING_SOURCE_DIR}/get_printable_param_name.hpp" diff --git a/src/mlpack/bindings/markdown/generate_markdown.binding.cpp.in b/src/mlpack/bindings/markdown/generate_markdown.binding.cpp.in index a9167d2e41..360524f0d3 100644 --- a/src/mlpack/bindings/markdown/generate_markdown.binding.cpp.in +++ b/src/mlpack/bindings/markdown/generate_markdown.binding.cpp.in @@ -15,7 +15,6 @@ #include "generate_markdown.${BINDING}.hpp" #include "binding_info.hpp" #include "print_docs.hpp" -#include "get_binding_name.hpp" ${INCLUDE_MAIN_FILES} diff --git a/src/mlpack/bindings/markdown/generate_markdown.binding.hpp.in b/src/mlpack/bindings/markdown/generate_markdown.binding.hpp.in index 182437f578..9c57ffe952 100644 --- a/src/mlpack/bindings/markdown/generate_markdown.binding.hpp.in +++ b/src/mlpack/bindings/markdown/generate_markdown.binding.hpp.in @@ -15,7 +15,6 @@ #define MLPACK_BINDINGS_MARKDOWN_GENERATE_MARKDOWN_${BINDING}_HPP #include "print_docs.hpp" -#include "get_binding_name.hpp" using namespace std; diff --git a/src/mlpack/bindings/markdown/get_binding_name.cpp b/src/mlpack/bindings/markdown/get_binding_name.cpp deleted file mode 100644 index b3cf4e51e8..0000000000 --- a/src/mlpack/bindings/markdown/get_binding_name.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file bindings/markdown/get_binding_name.cpp - * @author Ryan Curtin - * - * Given the name of a binding as it appears in CMake, return the corresponding - * name of the binding that is generated for a given language. - * - * mlpack is free software; you may redistribute it and/or modify it under the - * terms of the 3-clause BSD license. You should have received a copy of the - * 3-clause BSD license along with mlpack. If not, see - * http://www.opensource.org/licenses/BSD-3-Clause for more information. - */ -#include "get_binding_name.hpp" - -namespace mlpack { -namespace bindings { -namespace markdown { - -std::string GetBindingName(const std::string& language, - const std::string& name) -{ - // Unfortunately, every time a new binding is added, this code will need to be - // modified. - if (language == "cli") - { - // For command-line programs, all bindings have 'mlpack_' prepended to the - // name. - return "mlpack_" + name; - } - else if (language == "python") - { - // For Python bindings, the name is unchanged. - return name; - } - else if (language == "julia") - { - // For Julia bindings, the name is unchanged. - return name; - } - else if (language == "go") - { - // For Go bindings, the name is unchanged. - return name; - } - else if (language == "r") - { - // For R bindings, the name is unchanged. - return name; - } - else - { - throw std::invalid_argument("Don't know how to compute binding name for " - "language \"" + language + "\"! Is the language specified in " - "src/mlpack/bindings/markdown/get_binding_name.cpp?"); - } -} - -} // namespace markdown -} // namespace bindings -} // namespace mlpack diff --git a/src/mlpack/bindings/markdown/get_binding_name.hpp b/src/mlpack/bindings/markdown/get_binding_name.hpp deleted file mode 100644 index a661aae83b..0000000000 --- a/src/mlpack/bindings/markdown/get_binding_name.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file bindings/markdown/get_binding_name.hpp - * @author Ryan Curtin - * - * Given the name of a binding as it appears in CMake, return the corresponding - * name of the binding that is generated for a given language. - * - * mlpack is free software; you may redistribute it and/or modify it under the - * terms of the 3-clause BSD license. You should have received a copy of the - * 3-clause BSD license along with mlpack. If not, see - * http://www.opensource.org/licenses/BSD-3-Clause for more information. - */ -#ifndef MLPACK_BINDINGS_MARKDOWN_GET_BINDING_NAME_HPP -#define MLPACK_BINDINGS_MARKDOWN_GET_BINDING_NAME_HPP - -#include - -namespace mlpack { -namespace bindings { -namespace markdown { - -/** - * Given a language name and a binding name, return the name of that binding for - * that language. Note that if a new language is added to the mlpack bindings, - * this method will need to be updated so that documentation can be successfully - * generated for that language. - */ -std::string GetBindingName(const std::string& language, - const std::string& name); - -} // namespace markdown -} // namespace bindings -} // namespace mlpack - -#endif diff --git a/src/mlpack/bindings/markdown/print_docs.cpp b/src/mlpack/bindings/markdown/print_docs.cpp index 38cee5aeeb..381136e251 100644 --- a/src/mlpack/bindings/markdown/print_docs.cpp +++ b/src/mlpack/bindings/markdown/print_docs.cpp @@ -45,24 +45,17 @@ void PrintHeaders(const string& bindingName, // Get the name of the binding in the target language, and convert it to // lowercase (since the anchor link will be in lowercase). - const string langBindingName = + const string langBindingName = addWrapperDocs[i] ? GetWrapperName(bindingName) : GetBindingName(bindingName); - string anchorName = GetBindingName(bindingName); - transform(anchorName.begin(), anchorName.end(), anchorName.begin(), - [](unsigned char c) { return tolower(c); }); - // Strip '()' from the end if needed. - if (anchorName.substr(anchorName.size() - 2, 2) == "()") - anchorName = anchorName.substr(0, anchorName.size() - 2); - cout << " - [" << langBindingName << "](#" << languages[i] << "_"; if (addWrapperDocs[i]) cout << GetWrapperLink(bindingName); else - cout << anchorName; + cout << bindingName; cout << "){: .language-link #" << languages[i] << " }" << endl;