kdesc --rewrite from the reflection klammerset; txt caption rules the block's width

Assembled from klammertext-dev e99530408517. The katom rewrite patterns
are rendered from ref/ (a table in dispatch order, patterns through @c),
the procedural listing having left mac/; a plain-text caption's rule is
as long as the table or listing it captions; the editor-support comments
name the tools' new dev/ location.
This commit is contained in:
ack committed 2026-09-22 22:53:13 +02:00
1 parent 93d649e23c
commit c016b3e5f3
15 files changed
+101 -86

No files matched your search

+1 -1
View File
@@ -261,7 +261,7 @@ std::string Eval_python::eval(std::string code)
(void)K::log(3, code);
code = m_machine.m_state.subst(code, true);
// Kept as a record of a value worth watching; line comments rather than a
// block, so the msg() guard can see it is inert (doc/check_output_policy.sh
// block, so the msg() guard can see it is inert (dev/check_output_policy.sh
// is line-based and cannot tell it is inside a /* */).
// msg() << "\n"
// << std::string(80, '-') << "\n"
-58
View File
@@ -321,61 +321,3 @@ bool category_order_holds(const std::string& word, std::string& why, rewrite_ord
}
return true;
}
void describe_rewrite_patterns()
{
if (verbose_level > 0) {
std::string desc_text = "doc/katom_patterns.desc";
std::cout << "\n"
<< justify(string_from_file(klammertext_filename(desc_text)))
<< "\n\n";
}
size_t width0 = 0;
size_t width1 = 0;
size_t width2 = 0;
for (const Rewrite_rule& rule : rewrite_rules) {
width0 = std::max(width0, category_name(rule.category).size());
width1 = std::max(width1, rule.description.size());
width2 = std::max(width2, rule.pattern.m_pattern.size());
}
width0 += 2;
width1 += 2;
width2 += 2;
std::cout << boldblack << std::setfill(' ')
<< std::setw(width0) << std::left << " Category"
<< std::setw(width1) << std::left << "Description"
<< std::setw(width2) << std::left << "Pattern"
<< "Replacement" << black << "\n";
// Dispatch order, not declaration order: what a reader needs is the
// sequence the rules are actually TRIED in, since that is what decides
// which one fires.
rule_category shown {};
bool first = true;
for (size_t i : rule_order(rewrite_order::by_category)) {
const Rewrite_rule& rule = rewrite_rules[i];
std::string category = category_name(rule.category);
if (first || rule.category != shown) {
shown = rule.category;
first = false;
} else {
category = ""; // name a category once, at its head
}
std::string desc = rule.description;
desc[0] = static_cast<char>(toupper(desc[0]));
std::cout << " "
<< std::left
<< std::setw(width0) << category
<< std::setw(width1) << desc
<< std::setw(width2) << rule.pattern.m_pattern
<< (rule.special ? "(not a pattern replacement)" : rule.replacement)
<< "\n";
}
if (verbose_level > 0) {
std::string notes_text = "doc/katom_patterns.notes";
std::cout << "\n\n"
<< justify(string_from_file(klammertext_filename(notes_text)))
<< "\n\n";
}
}
-6
View File
@@ -142,9 +142,3 @@ std::vector<size_t> matching_rules(const std::string& word, rewrite_order order
// state an invariant across.
bool category_order_holds(const std::string& word, std::string& why,
rewrite_order order = rewrite_order::by_category);
// The "kdesc --rewrite" listing. It moved here with the table it reads,
// and gained the CATEGORY column -- which is the point of the categories
// reaching the user rather than only the maintainer: a reader sees the nine
// groups and their order instead of thirty positions.
void describe_rewrite_patterns();