User-facing docs: --commands-md flag, doc/user/ tree, anonymised script.
- `essim --commands-md [file]` instantiates the Tui, calls
`Tui::DumpCommandsMd(ostream&)` which iterates the live registry and
emits Markdown grouped by interactive/other, then exits. Single
source of truth: a new `CommandSpec` field surfaces automatically.
- CMake `doc` target now `DEPENDS essim` and chains:
doxygen → gen_api_md.py → doc/api/
essim --commands-md → doc/user/commands.md
- `doc/user/` adds:
- index.md (hand-written) — first session, interactive-screen
conventions, save/restore/replay overview.
- scripting.md (hand-written) — `set`/`$var` expansion semantics,
`source` event-paced execution, script-save denylist, worked
example pointing at test/system.essim.
- commands.md (auto-generated, regenerated by the `doc` target).
- Top-level README refocused on quick start; pointers to the new
doc tree (user/, api/, DESIGN.md) instead of an inline command table.
- doc/README.md and DESIGN.md document the two-pipeline doc workflow.
- `test/system.essim` and user docs anonymised: bkp → backplane,
vdn1/2/3 → payload1/2/3, cb3p → payload4, bpb/cob/ssu →
peripheral1/2/3; netlist file names + variable names + paths all
replaced with generic equivalents.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
@@ -289,6 +290,76 @@ void Tui::ProcessNextSourceLine() {
|
||||
in_source = loading_prev_in_source;
|
||||
}
|
||||
|
||||
void Tui::DumpCommandsMd(std::ostream &out) const {
|
||||
out << "# essim — command reference\n\n"
|
||||
"Auto-generated from the live command registry. Regenerate with\n"
|
||||
"`cmake --build build --target doc` after adding or changing\n"
|
||||
"commands; the binary itself is the single source of truth.\n\n"
|
||||
"Keys global to the shell: `Esc` cancels a multi-step prompt or\n"
|
||||
"leaves an interactive screen; `Tab` completes commands/paths\n"
|
||||
"(top-level prompt) or cycles focus inside an interactive\n"
|
||||
"screen; `PageUp` / `PageDown` scroll output by 10 lines,\n"
|
||||
"`Home` / `End` jump to top / bottom; ↑ / ↓ walk command\n"
|
||||
"history.\n";
|
||||
|
||||
auto emit_group = [&](const std::string &title, bool want_interactive) {
|
||||
bool printed_title = false;
|
||||
for (const auto &kv : commands) {
|
||||
const CommandSpec &spec = kv.second;
|
||||
if (spec.interactive != want_interactive) continue;
|
||||
if (!printed_title) {
|
||||
out << "\n## " << title << "\n\n";
|
||||
printed_title = true;
|
||||
}
|
||||
out << "### `" << kv.first << "`";
|
||||
if (spec.interactive) out << " *(interactive)*";
|
||||
out << "\n\n" << spec.description << "\n\n";
|
||||
|
||||
if (spec.params.empty()) {
|
||||
out << "**No arguments.**";
|
||||
} else {
|
||||
out << "**Arguments**\n\n";
|
||||
int i = 1;
|
||||
for (const auto &p : spec.params) {
|
||||
out << i << ". `" << p.name << "`";
|
||||
switch (p.completion) {
|
||||
case Completion::Path: out << " *(Tab → path completion)*"; break;
|
||||
case Completion::Command: out << " *(Tab → command completion)*"; break;
|
||||
case Completion::None: break;
|
||||
}
|
||||
out << "\n";
|
||||
++i;
|
||||
}
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
std::vector<std::string> notes;
|
||||
if (spec.interactive) {
|
||||
notes.emplace_back("bare form opens an interactive screen; "
|
||||
"inline form (all args) is scriptable");
|
||||
} else if (!spec.prompt_for_missing) {
|
||||
notes.emplace_back("no per-arg prompt: pass all args inline "
|
||||
"(or run bare for an empty-args path)");
|
||||
} else if (!spec.params.empty()) {
|
||||
notes.emplace_back("missing args trigger one prompt each");
|
||||
}
|
||||
if (!spec.scriptable) {
|
||||
notes.emplace_back("not recorded by `script-save` and "
|
||||
"rejected by `source`");
|
||||
}
|
||||
if (!notes.empty()) {
|
||||
out << "**Notes**\n\n";
|
||||
for (const auto &n : notes) out << "- " << n << "\n";
|
||||
out << "\n";
|
||||
}
|
||||
out << "---\n";
|
||||
}
|
||||
};
|
||||
|
||||
emit_group("Interactive commands", true);
|
||||
emit_group("Other commands", false);
|
||||
}
|
||||
|
||||
void Tui::AppendHistory(const std::string &cmd) {
|
||||
auto p = HistoryPath();
|
||||
if (p.empty()) return;
|
||||
|
||||
Reference in New Issue
Block a user