miscellaneous documentation updates

1. config.cpp: replace angle quotes with typographic single quotes
2. config.hpp: typo fix
3. widget_definition.cpp, window_builder.cpp: show id for window/widget
4. wml_exception: implement missing tag message, use typographic single quotes in missing key/tag messages
This commit is contained in:
Subhraman Sarkar 2024-08-25 09:38:06 +05:30 committed by Charles Dang
parent 60640dc8bd
commit 5251ca1593
5 changed files with 21 additions and 19 deletions

View file

@ -327,7 +327,7 @@ auto get_child_impl(Tchildren& children, config_key_type key, int n) -> optional
auto i = children.find(key);
if(i == children.end()) {
DBG_CF << "The config object has no child named »" << key << "«.";
DBG_CF << "The config object has no child named " << key << ".";
return utils::nullopt;
}
@ -338,8 +338,8 @@ auto get_child_impl(Tchildren& children, config_key_type key, int n) -> optional
try {
return *i->second.at(n);
} catch(const std::out_of_range&) {
DBG_CF << "The config object has only »" << i->second.size() << "« children named »" << key
<< "«; request for the index »" << n << "« cannot be honored.";
DBG_CF << "The config object has only " << i->second.size() << " children named " << key
<< "; request for the index " << n << " cannot be honored.";
return utils::nullopt;
}
}
@ -351,7 +351,7 @@ config& config::mandatory_child(config_key_type key, const std::string& parent)
if(auto res = get_child_impl(children_, key, 0)) {
return *res;
} else {
throw error("Mandatory WML child »[" + std::string(key) + "]« missing in »" + parent + "«. Please report this bug.");
throw error("Mandatory WML child [" + std::string(key) + "] missing in " + parent + ". Please report this bug.");
}
}
@ -360,7 +360,7 @@ const config& config::mandatory_child(config_key_type key, const std::string& pa
if(auto res = get_child_impl(children_, key, 0)) {
return *res;
} else {
throw error("Mandatory WML child »[" + std::string(key) + "]« missing in »" + parent + "«. Please report this bug.");
throw error("Mandatory WML child [" + std::string(key) + "] missing in " + parent + ". Please report this bug.");
}
}
@ -788,7 +788,7 @@ optional_config config::find_child(config_key_type key, const std::string& name,
{
const child_map::iterator i = children_.find(key);
if(i == children_.end()) {
DBG_CF << "Key »" << name << "« value »" << value << "« pair not found as child of key »" << key << "«.";
DBG_CF << "Key " << name << " value " << value << " pair not found as child of key " << key << ".";
return utils::nullopt;
@ -805,7 +805,7 @@ optional_config config::find_child(config_key_type key, const std::string& name,
return **j;
}
DBG_CF << "Key »" << name << "« value »" << value << "« pair not found as child of key »" << key << "«.";
DBG_CF << "Key " << name << " value " << value << " pair not found as child of key " << key << ".";
return utils::nullopt;
}
@ -818,6 +818,7 @@ config& config::find_mandatory_child(config_key_type key, const std::string &nam
}
throw error("Cannot find child [" + std::string(key) + "] with " + name + "=" + value);
}
const config& config::find_mandatory_child(config_key_type key, const std::string &name, const std::string &value) const
{
auto res = find_child(key, name, value);
@ -827,7 +828,6 @@ const config& config::find_mandatory_child(config_key_type key, const std::strin
throw error("Cannot find child [" + std::string(key) + "] with " + name + "=" + value);
}
void config::clear()
{
// No validity check for this function.

View file

@ -396,10 +396,10 @@ public:
*/
const config& mandatory_child(config_key_type key, int n = 0) const;
/** Euivalent to @ref mandatory_child, but returns an empty optional if the nth child was not found. */
/** Equivalent to @ref mandatory_child, but returns an empty optional if the nth child was not found. */
optional_config_impl<config> optional_child(config_key_type key, int n = 0);
/** Euivalent to @ref mandatory_child, but returns an empty optional if the nth child was not found. */
/** Equivalent to @ref mandatory_child, but returns an empty optional if the nth child was not found. */
optional_config_impl<const config> optional_child(config_key_type key, int n = 0) const;
/**
@ -634,7 +634,6 @@ public:
const config& find_mandatory_child(config_key_type key, const std::string &name,
const std::string &value) const;
private:
void clear_children_impl(config_key_type key);
public:

View file

@ -64,7 +64,7 @@ styled_widget_definition::styled_widget_definition(const config& cfg)
* extra header dependencies.
*/
config::const_child_itors itors = cfg.child_range("resolution");
VALIDATE(!itors.empty(), _("No resolution defined."));
VALIDATE(!itors.empty(), _("No resolution defined for ") + id);
}
} // namespace gui2

View file

@ -129,7 +129,7 @@ void builder_window::read(const config& cfg)
DBG_GUI_P << "Window builder: reading data for window " << id_ << ".";
config::const_child_itors cfgs = cfg.child_range("resolution");
VALIDATE(!cfgs.empty(), _("No resolution defined."));
VALIDATE(!cfgs.empty(), _("No resolution defined for ") + id_);
for(const auto& i : cfgs) {
resolutions.emplace_back(i);

View file

@ -86,11 +86,11 @@ std::string missing_mandatory_wml_key(
symbols["primary_key"] = primary_key;
symbols["primary_value"] = primary_value;
return VGETTEXT("In section '[$section|]' where '$primary_key| = "
"$primary_value' the mandatory key '$key|' isn't set.", symbols);
return VGETTEXT("In section [$section|] where $primary_key| = "
"$primary_value the mandatory key $key| isn't set.", symbols);
} else {
return VGETTEXT("In section '[$section|]' the "
"mandatory key '$key|' isn't set.", symbols);
return VGETTEXT("In section [$section|] the "
"mandatory key $key| isn't set.", symbols);
}
}
@ -98,6 +98,9 @@ std::string missing_mandatory_wml_tag(
const std::string &section
, const std::string &tag)
{
// TODO in 1.19: revisit this when we can add new strings
return missing_mandatory_wml_key(section, "[" + tag + "]");
utils::string_map symbols;
symbols["section"] = section;
symbols["tag"] = tag;
return VGETTEXT("In section [$section|] the "
"mandatory subtag [$tag|] is missing.", symbols);
}