31 const std::string & comment)
33 if (line.empty() && comment.empty())
43 _stream << indent << line <<
"\n";
50 std::vector<std::string> elements;
58 int len = 100 - max_line_len - indent.size();
63 std::string first(max_line_len - line.size() + extra,
' ');
64 _stream << first <<
"# " << elements[0] <<
"\n";
65 std::string cindent(max_line_len + indent.size() + extra,
' ');
66 for (
size_t i = 1; i < elements.size(); ++i)
67 _stream << cindent <<
"# " << elements[i] <<
"\n";
74 const nlohmann::json & block,
84 std::string desc = block.contains(
"description") ? nlohmann::to_string(block[
"description"]) :
"";
88 if (block.contains(
"parameters"))
91 if (block.contains(
"actions"))
94 nlohmann::json all_params;
95 auto & actions = block[
"actions"];
96 for (
auto && el : actions.items())
98 auto & params = el.value()[
"parameters"];
99 for (
auto && param_el : params.items())
100 all_params[param_el.key()] = param_el.value();
105 if (block.contains(
"star"))
111 if (block.contains(
"subblocks"))
113 auto & subblocks = block[
"subblocks"];
114 if (!subblocks.is_null())
115 for (
auto && el : subblocks.items())
148 for (
auto & el : params.items())
149 if (el.key().size() > max_name)
150 max_name = el.key().size();
153 std::map<std::string, std::string> lines;
154 for (
auto && el : params.items())
156 auto & name = el.key();
157 auto & param = el.value();
159 param.contains(
"default") ?
MooseUtils::trim(nlohmann::to_string(param[
"default"])) :
"";
161 def = def.substr(1, def.size() - 2);
162 if (def.find(
' ') != std::string::npos)
163 def =
"'" + def +
"'";
164 std::string indent(max_name - name.size(),
' ');
165 std::string required;
166 if (param[
"required"])
167 required =
"(required)";
168 if (def.size() == 0 && required.size() == 0)
169 def =
"(no_default)";
170 std::string l = name + indent +
" = " + def + required;
171 if (l.size() > max_len)
175 for (
auto & el : params.items())
177 auto & name = el.key();
178 auto & param = el.value();
179 auto & l = lines[name];
180 auto desc = nlohmann::to_string(param[
"description"]);
183 const auto cpp_type = param.contains(
"cpp_type") ? param[
"cpp_type"].get<std::string>() :
"";
184 const bool is_moose_enum = cpp_type.find(
"MooseEnum") != std::string::npos ||
185 cpp_type.find(
"ExecFlagEnum") != std::string::npos;
189 const auto options_string =
MooseUtils::trim(param[
"options"].get<std::string>());
190 if (!options_string.empty())
192 std::vector<std::string> options;
194 addLine(
"", max_len + 1,
"Options: " + MooseUtils::join(options,
", "));
196 if (param.contains(
"option_docs") && param[
"option_docs"].is_object())
197 for (
const auto & option : options)
200 if (param[
"option_docs"].contains(option_doc_key))
203 option +
": " + param[
"option_docs"][option_doc_key].get<std::string>());
208 const auto doc_unit = nlohmann::to_string(param[
"doc_unit"]);
209 if (!doc_unit.empty())
211 "Unit: " + doc_unit);
213 const auto group = nlohmann::to_string(param[
"group_name"]);
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...