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:
1 parent
93d649e23c
commit
c016b3e5f3
15 files changed
+101
-86
No files matched your search
@@ -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";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user