Added incompatibilities to the auto-generated documentation
This commit is contained in:
parent
a9706267db
commit
19560b538f
@ -439,6 +439,7 @@ std::string CmdArgsInterface::GenerateDocumentation() const
|
|||||||
bool required = false;
|
bool required = false;
|
||||||
bool typeIsForced = false;
|
bool typeIsForced = false;
|
||||||
std::string defaultVal;
|
std::string defaultVal;
|
||||||
|
std::string incompatibilities;
|
||||||
};
|
};
|
||||||
std::unordered_map<std::string, ParamDocEntry> paramInfos;
|
std::unordered_map<std::string, ParamDocEntry> paramInfos;
|
||||||
|
|
||||||
@ -478,19 +479,33 @@ std::string CmdArgsInterface::GenerateDocumentation() const
|
|||||||
cached.typeIsForced = it.second.constrainType;
|
cached.typeIsForced = it.second.constrainType;
|
||||||
cached.type = DataTypeToString(it.second.requiredType);
|
cached.type = DataTypeToString(it.second.requiredType);
|
||||||
|
|
||||||
std::stringstream defaultValueSs;
|
// Build default-value string
|
||||||
|
std::stringstream vec2str_ss;
|
||||||
for (const std::string& s : it.second.defaultValue)
|
for (const std::string& s : it.second.defaultValue)
|
||||||
{
|
{
|
||||||
defaultValueSs << '\'' << s << '\'';
|
vec2str_ss << '\'' << s << '\'';
|
||||||
|
|
||||||
// Add a space if we are not at the last entry
|
// Add a space if we are not at the last entry
|
||||||
if ((void*)&s != (void*)&it.second.defaultValue.back())
|
if ((void*)&s != (void*)&it.second.defaultValue.back())
|
||||||
defaultValueSs << " ";
|
vec2str_ss << " ";
|
||||||
}
|
}
|
||||||
cached.defaultVal = defaultValueSs.str();
|
cached.defaultVal = vec2str_ss.str();
|
||||||
|
|
||||||
|
|
||||||
|
// Build incompatibilities string
|
||||||
|
vec2str_ss.str("");
|
||||||
|
for (const std::string& s : it.second.incompatibleParameters)
|
||||||
|
{
|
||||||
|
vec2str_ss << s;
|
||||||
|
|
||||||
|
// Add a comma-space if we are not at the last entry
|
||||||
|
if ((void*)&s != (void*)&it.second.incompatibleParameters.back())
|
||||||
|
vec2str_ss << ", ";
|
||||||
|
}
|
||||||
|
cached.incompatibilities = vec2str_ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now generate the documentatino body
|
// Now generate the documentation body
|
||||||
if (paramInfos.size() > 0)
|
if (paramInfos.size() > 0)
|
||||||
{
|
{
|
||||||
ss << std::endl
|
ss << std::endl
|
||||||
@ -517,6 +532,10 @@ std::string CmdArgsInterface::GenerateDocumentation() const
|
|||||||
if (pde.defaultVal.length() > 0)
|
if (pde.defaultVal.length() > 0)
|
||||||
ss << "default=[" << pde.defaultVal << "] ";
|
ss << "default=[" << pde.defaultVal << "] ";
|
||||||
|
|
||||||
|
// Put incompatibilities
|
||||||
|
if (pde.incompatibilities.length() > 0)
|
||||||
|
ss << "incompatibilities=[" << pde.incompatibilities << "] ";
|
||||||
|
|
||||||
// Put required tag, but only if no default value
|
// Put required tag, but only if no default value
|
||||||
if ((pde.required) && (pde.defaultVal.length() == 0))
|
if ((pde.required) && (pde.defaultVal.length() == 0))
|
||||||
ss << "[[REQUIRED]] ";
|
ss << "[[REQUIRED]] ";
|
||||||
|
@ -162,6 +162,7 @@
|
|||||||
<ClInclude Include="StringTools.h" />
|
<ClInclude Include="StringTools.h" />
|
||||||
<ClInclude Include="StringValue.h" />
|
<ClInclude Include="StringValue.h" />
|
||||||
<ClInclude Include="Value.h" />
|
<ClInclude Include="Value.h" />
|
||||||
|
<ClInclude Include="Version.h" />
|
||||||
<ClInclude Include="VoidValue.h" />
|
<ClInclude Include="VoidValue.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
@ -83,5 +83,8 @@
|
|||||||
<ClInclude Include="CmdArgsInterface.h">
|
<ClInclude Include="CmdArgsInterface.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Version.h">
|
||||||
|
<Filter>Headerdateien</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,2 +1,2 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#define HAZELNUPP_VERSION (1.1)
|
#define HAZELNUPP_VERSION (1.11)
|
||||||
|
@ -25,7 +25,7 @@ int main(int argc, char** argv)
|
|||||||
args.RegisterConstraint("--name", ParamConstraint(true, DATA_TYPE::LIST, { "peter", "hannes" }, true, {}));
|
args.RegisterConstraint("--name", ParamConstraint(true, DATA_TYPE::LIST, { "peter", "hannes" }, true, {}));
|
||||||
args.RegisterConstraint("--fruit", ParamConstraint(true, DATA_TYPE::STRING, {}, true, {}));
|
args.RegisterConstraint("--fruit", ParamConstraint(true, DATA_TYPE::STRING, {}, true, {}));
|
||||||
|
|
||||||
args.RegisterConstraint("--make-food-delicious", ParamConstraint::Incompatibility("--make-food-disgusting"));
|
args.RegisterConstraint("--make-food-delicious", ParamConstraint::Incompatibility({ "--make-food-disgusting" , "--foo"}));
|
||||||
|
|
||||||
args.Parse(argc, argv);
|
args.Parse(argc, argv);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user