22 for (
auto && el : root[
"blocks"].items())
23 addBlock(el.key(), el.value(),
true);
30 const std::string & comment)
32 if (line.empty() && comment.empty())
49 std::vector<std::string> elements;
57 int len = 100 - max_line_len -
indent.size();
62 std::string first(max_line_len - line.size() + extra,
' ');
63 _stream << first <<
"# " << elements[0] <<
"\n";
64 std::string cindent(max_line_len +
indent.size() + extra,
' ');
65 for (
size_t i = 1; i < elements.size(); ++i)
66 _stream << cindent <<
"# " << elements[i] <<
"\n";
73 const nlohmann::json & block,
83 std::string desc = block.contains(
"description") ? nlohmann::to_string(block[
"description"]) :
"";
87 if (block.contains(
"parameters"))
90 if (block.contains(
"actions"))
93 nlohmann::json all_params;
94 auto & actions = block[
"actions"];
95 for (
auto && el : actions.items())
97 auto & params = el.value()[
"parameters"];
98 for (
auto && param_el : params.items())
99 all_params[param_el.key()] = param_el.value();
104 if (block.contains(
"star"))
110 if (block.contains(
"subblocks"))
112 auto & subblocks = block[
"subblocks"];
113 if (!subblocks.is_null())
114 for (
auto && el : subblocks.items())
128 if (!block.contains(key))
130 auto & types = block[key];
137 for (
auto && el : types.items())
138 addBlock(
"<" + el.key() +
">", el.value());
147 for (
auto & el : params.items())
148 if (el.key().size() > max_name)
149 max_name = el.key().size();
152 std::map<std::string, std::string> lines;
153 for (
auto && el : params.items())
155 auto &
name = el.key();
156 auto & param = el.value();
158 param.contains(
"default") ?
MooseUtils::trim(nlohmann::to_string(param[
"default"])) :
"";
160 def = def.substr(1, def.size() - 2);
161 if (def.find(
' ') != std::string::npos)
162 def =
"'" + def +
"'";
163 std::string
indent(max_name -
name.size(),
' ');
164 std::string required;
165 if (param[
"required"])
166 required =
"(required)";
167 if (def.size() == 0 && required.size() == 0)
168 def =
"(no_default)";
169 std::string l =
name +
indent +
" = " + def + required;
170 if (l.size() > max_len)
174 for (
auto & el : params.items())
176 auto &
name = el.key();
177 auto & param = el.value();
178 auto & l = lines[
name];
179 auto desc = nlohmann::to_string(param[
"description"]);
182 const auto doc_unit = nlohmann::to_string(param[
"doc_unit"]);
183 if (!doc_unit.empty())
185 "Unit: " + doc_unit);
187 const auto group = nlohmann::to_string(param[
"group_name"]);
std::string name(const ElemQuality q)
std::string indent(unsigned int spaces)
Create empty string for indenting.
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 ...
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.