diff --git a/src/help/topic_generators.cpp b/src/help/topic_generators.cpp index b50b50b4642f..87d157e91ab2 100644 --- a/src/help/topic_generators.cpp +++ b/src/help/topic_generators.cpp @@ -37,6 +37,57 @@ static lg::log_domain log_help("help"); namespace help { +namespace +{ +std::string make_unit_link(const std::string& type_id) +{ + std::string link; + const unit_type* type = unit_types.find(type_id, unit_type::HELP_INDEXED); + + if(!type) { + std::cerr << "Unknown unit type : " << type_id << "\n"; + + // Don't return a hyperlink (no page). Instead show the id (as hint) + link = type_id; + } else if(!type->hide_help()) { + std::string name = type->type_name(); + std::string ref_id; + + if(description_type(*type) == FULL_DESCRIPTION) { + const std::string section_prefix = type->show_variations_in_help() ? ".." : ""; + ref_id = section_prefix + unit_prefix + type->id(); + } else { + ref_id = unknown_unit_topic; + name += " (?)"; + } + + link = make_link(name, ref_id); + } // if hide_help then link is an empty string + + return link; +} + +std::vector make_unit_links_list(const std::vector& type_id_list, bool ordered) +{ + std::vector links_list; + + for(const std::string& type_id : type_id_list) { + std::string unit_link = make_unit_link(type_id); + + if(!unit_link.empty()) { + links_list.push_back(std::move(unit_link)); + } + } + + if(ordered) { + std::sort(links_list.begin(), links_list.end()); + } + + return links_list; +} + +} // end anon namespace + topic_list generate_ability_topics(const bool sort_generated) { topic_list topics; diff --git a/src/help/utils.cpp b/src/help/utils.cpp index f64ae7641497..d1dbb7ac66ef 100644 --- a/src/help/utils.cpp +++ b/src/help/utils.cpp @@ -34,34 +34,6 @@ namespace help /** Implementation helpers. */ namespace { -std::string make_unit_link(const std::string& type_id) -{ - std::string link; - const unit_type* type = unit_types.find(type_id, unit_type::HELP_INDEXED); - - if(!type) { - std::cerr << "Unknown unit type : " << type_id << "\n"; - - // Don't return a hyperlink (no page). Instead show the id (as hint) - link = type_id; - } else if(!type->hide_help()) { - std::string name = type->type_name(); - std::string ref_id; - - if(description_type(*type) == FULL_DESCRIPTION) { - const std::string section_prefix = type->show_variations_in_help() ? ".." : ""; - ref_id = section_prefix + unit_prefix + type->id(); - } else { - ref_id = unknown_unit_topic; - name += " (?)"; - } - - link = make_link(name, ref_id); - } // if hide_help then link is an empty string - - return link; -} - } // end anon namespace bool string_less::operator()(const std::string& s1, const std::string& s2) const @@ -124,25 +96,6 @@ std::string escape(const std::string& s) return utils::escape(s, "'\\"); } -std::vector make_unit_links_list(const std::vector& type_id_list, bool ordered) -{ - std::vector links_list; - - for(const std::string& type_id : type_id_list) { - std::string unit_link = make_unit_link(type_id); - - if(!unit_link.empty()) { - links_list.push_back(std::move(unit_link)); - } - } - - if(ordered) { - std::sort(links_list.begin(), links_list.end()); - } - - return links_list; -} - ter_data_cache load_terrain_types_data() { if(display* d = display::get_singleton()) { diff --git a/src/help/utils.hpp b/src/help/utils.hpp index 99fdb4ea0ab3..23a405b55169 100644 --- a/src/help/utils.hpp +++ b/src/help/utils.hpp @@ -76,8 +76,6 @@ inline std::string jump(const unsigned amount) return formatter() << "amount=" << amount << ""; } -std::vector make_unit_links_list(const std::vector& type_id_list, bool ordered); - using ter_data_cache = std::shared_ptr; /// Load the appropriate terrain types data to use