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:
parent
583dae2e27
commit
b169292743
14 changed files with 737 additions and 25 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue