kdesc --coverage <target>: one target's view (from dev 931ea5490a5d)

For the designer building a target: the klammers that cover it, those
that do so with an empty definition (a decision that the klammer has no
meaning there), and the undecided ones (no definition). One klammer per
line, alphabetical; "all" adds the explanations; an unknown word names
the missing target.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
ackandClaude Fable 5.1 committed 2026-09-26 23:00:57 +02:00
1 parent 39edac9c94
commit d14da90bbf
6 files changed
+152 -15

No files matched your search

+33 -13
View File
@@ -43,6 +43,12 @@ static void coverage_usage()
" --coverage all Also name the file each klammer is written\n"
" in, and show every \"needs attention\"\n"
" category, including the empty ones\n"
" --coverage <target>\n"
" One target's view: the klammers that cover it,\n"
" those that do so with an EMPTY definition (a\n"
" decision: no meaning there), and the undecided\n"
" ones (no definition: nothing decided). \"all\"\n"
" may be added for the explanations.\n"
" --coverage help This description\n"
"\n"
"Coverage is a fact about a klammer: the targets it can render to. It is\n"
@@ -336,21 +342,26 @@ int main(int argc, char* argv[])
// --coverage is validated here, before a klammer set is read, so a
// mistyped word or "help" is answered at once. The report itself
// needs the loaded registry, so it runs at the end.
// The words are "help", "all", and at most one target name, which
// can only be checked once the klammersets are loaded (below).
bool coverage_all = false;
std::string coverage_target {};
if (args.given("coverage")) {
strings_t words = option_words(args, "coverage");
std::string verb = words.empty() ? "" : words[0];
if (verb == "help") {
coverage_usage();
return 0;
}
if (verb == "all") {
coverage_all = true;
} else if (!verb.empty()) {
std::cout << "Unrecognized coverage command: --coverage "
<< join(words, " ") << "\n\n";
coverage_usage();
return 1;
for (const std::string& word : words) {
if (word == "help") {
coverage_usage();
return 0;
} else if (word == "all") {
coverage_all = true;
} else if (coverage_target.empty()) {
coverage_target = word;
} else {
std::cout << "Unrecognized coverage command: --coverage "
<< join(words, " ") << "\n\n";
coverage_usage();
return 1;
}
}
}
@@ -400,7 +411,16 @@ int main(int argc, char* argv[])
// Analysis only: klammer_coverage() reads the registry and modifies
// nothing, so what a document renders to is unaffected by asking.
if (args.given("coverage")) {
report_coverage(M, klammer_coverage(M, own_klammers_only), coverage_all, std::cout);
if (!coverage_target.empty()) {
if (!is_in(coverage_target, M.m_targets.user_defined())) {
std::cout << "No target \"" << coverage_target << "\" is defined. Enter \"kdesc -t\" to see the\n"
<< "targets the loaded klammersets define, or \"--coverage help\".\n";
return 1;
}
report_target_coverage(klammer_coverage(M, own_klammers_only), coverage_target, coverage_all, std::cout);
} else {
report_coverage(M, klammer_coverage(M, own_klammers_only), coverage_all, std::cout);
}
}
}
catch (Error& e) {