3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 17:45:32 +00:00

add parameter descriptions

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2022-08-16 08:26:53 -07:00
parent 583dae2e27
commit b169292743
14 changed files with 737 additions and 25 deletions

View file

@ -533,6 +533,22 @@ public:
out << "\n";
d->display(out, 4, false);
}
void display_module_markdown(std::ostream & out, char const* module_name) {
lock_guard lock(*gparams_mux);
param_descrs * d = nullptr;
if (!get_module_param_descr(module_name, d)) {
std::stringstream strm;
strm << "unknown module '" << module_name << "'";
throw exception(std::move(strm).str());
}
out << "## Module " << module_name << "\n\n";
char const * descr = nullptr;
if (get_module_descrs().find(module_name, descr)) {
out << "Description: " << descr;
}
out << "\n";
d->display_markdown(out);
}
param_descrs const& get_global_param_descrs() {
lock_guard lock(*gparams_mux);
@ -643,6 +659,11 @@ void gparams::display_module(std::ostream & out, char const * module_name) {
g_imp->display_module(out, module_name);
}
void gparams::display_module_markdown(std::ostream & out, char const * module_name) {
SASSERT(g_imp);
g_imp->display_module_markdown(out, module_name);
}
void gparams::display_parameter(std::ostream & out, char const * name) {
SASSERT(g_imp);
g_imp->display_parameter(out, name);

View file

@ -119,6 +119,7 @@ public:
// Auxiliary APIs for better command line support
static void display_modules(std::ostream & out);
static void display_module(std::ostream & out, char const * module_name);
static void display_module_markdown(std::ostream & out, char const * module_name);
static void display_parameter(std::ostream & out, char const * name);
static param_descrs const& get_global_param_descrs();

View file

@ -161,12 +161,16 @@ struct param_descrs::imp {
bool operator()(symbol const & s1, symbol const & s2) const { return ::lt(s1, s2); }
};
void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) const {
void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr, bool markdown) const {
svector<symbol> names;
for (auto const& kv : m_info) {
names.push_back(kv.m_key);
}
std::sort(names.begin(), names.end(), symlt());
if (markdown) {
out << " Parameter | Type | Description | Default\n";
out << " ----------------------------------------\n";
}
for (symbol const& name : names) {
for (unsigned i = 0; i < indent; i++) out << " ";
if (smt2_style)
@ -186,10 +190,20 @@ struct param_descrs::imp {
info d;
m_info.find(name, d);
SASSERT(d.m_descr);
out << " (" << d.m_kind << ")";
if (markdown)
out << " | " << d.m_kind << " ";
else
out << " (" << d.m_kind << ")";
if (markdown)
out << " | ";
if (include_descr)
out << " " << d.m_descr;
if (d.m_default != nullptr)
if (markdown) {
out << " | ";
if (d.m_default)
out << d.m_default;
}
else if (d.m_default != nullptr)
out << " (default: " << d.m_default << ")";
out << "\n";
}
@ -280,7 +294,11 @@ char const* param_descrs::get_module(symbol const& name) const {
}
void param_descrs::display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) const {
return m_imp->display(out, indent, smt2_style, include_descr);
return m_imp->display(out, indent, smt2_style, include_descr, false);
}
void param_descrs::display_markdown(std::ostream & out, bool smt2_style, bool include_descr) const {
return m_imp->display(out, 0, smt2_style, include_descr, true);
}
void insert_max_memory(param_descrs & r) {

View file

@ -130,6 +130,7 @@ public:
char const * get_default(char const * name) const;
char const * get_default(symbol const & name) const;
void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false, bool include_descr=true) const;
void display_markdown(std::ostream& out, bool smt2_style = false, bool include_descr = true) const;
unsigned size() const;
symbol get_param_name(unsigned idx) const;
char const * get_module(symbol const& name) const;