feat(argtype): :alone - the value of an option written without one

An optional argument has three values: the default (the name is absent),
the argument type's :alone value (the name is written alone), and a
written value.

:alone is declared by the argument type only, never by a klammer's
parameter declaration -- a default is what one klammer means by silence,
but a bare option name must read the same way in every klammer.  The bool
type declares :alone true, which is the whole of the convention that a
bare boolean option means true; there is no boolean special case in the
engine.  A type whose pattern matches running text cannot declare :alone,
since an option's value runs to the next bar or option name and would
swallow the following text.

kdesc and `ktext -m` now show [default: X] and [alone: Y] per argument
type.

In the Standard Klammer Set: @code :number becomes a bool (it was an
untyped string tested only for truthiness, so a bare :number was a
no-op); decimal_mark declares :alone comma; table_hline and table_vline
declare :alone all.  The 35 bools that default false gained the bare form
for free.

Tests: tst/alone_test.sh (21 cases) joins the shipped suite.

(from dev 6024f49c2859)
This commit is contained in:
2026-07-28 22:24:32 +02:00
parent 61b21d1397
commit cacff229a1
11 changed files with 335 additions and 12 deletions

View File

@@ -26,7 +26,8 @@ public:
{};
Argtype(std::string name, std::string desc, std::string symbolic_pattern, std::string pattern,
std::string default_value, std::string python_cast, modify_string_f python_format,
std::string default_value, std::string alone_value,
std::string python_cast, modify_string_f python_format,
const Locator& loc);
std::string python_value(const std::string& var_name, std::vector<std::string> value, size_t name_size);
@@ -48,6 +49,18 @@ public:
// (cell_hpos, column_width); general types (bool, float) have no
// sensible universal default and leave it empty.
std::string m_default {};
// Value for an optional argument whose name is written alone, with no
// value after it (:number rather than :number 10). Declared by the
// argument type, never by a klammer's parameter declaration: the
// default is what a klammer means by silence and is properly
// per-klammer, but a bare option name must read the same way in every
// klammer or the writer cannot know what it means without consulting
// each signature. bool declares "true", which is where the
// presence-means-true convention comes from; a type whose pattern
// matches everything cannot declare it (the value would swallow the
// following text instead). Empty means the type has no alone value,
// and a bare option name yields the empty string as before.
std::string m_alone {};
// Type parameter for parameterized types like rest(2): the value N
// is bound around the python cast as (lambda N: <cast>)(2)(...).
// Empty means unparameterized; a type with a default parameter