validate_argspecfunction#
validate_argspec(spec: str) -> ValidateArgspecResultValidate an xparse-style argspec string and report its parsed slots.
Use it to self-check an argspec before injecting a custom command into a
Parser. It never raises on a malformed spec; instead the result's
valid is False and error carries the reason.
| Parameter | Type | Description |
|---|---|---|
spec | str | The argspec string, such as |
ValidateArgspecResult — A ValidateArgspecResult dict: valid, error, arg_count, and parsed (the per-slot breakdown when valid).
texform.validate_argspec("o m") # {'valid': True, 'error': None, 'arg_count': 2, 'parsed': [...]}ValidateArgspecResultdict type#
The outcome of validating an argspec string with validate_argspec.
On success, valid is True and arg_count / parsed describe the
slots; on failure, valid is False and error carries the reason
while arg_count and parsed are None.
| Field | Type | Description |
|---|---|---|
valid | bool | Whether the specification string parsed. |
error | str | | The error message when invalid, otherwise |
arg_count | int | | The number of argument slots when valid, otherwise |
parsed | list[ | The per-slot breakdown when valid, otherwise |
ParsedArgSpecSlotdict type#
One parsed argument slot of an xparse-style specification.
A presentation-oriented view of the internal argspec model, so tooling can consume argspecs without depending on internal crates.
| Field | Type | Description |
|---|---|---|
required | bool | Whether the argument is mandatory ( |
no_leading_space | bool | Whether leading whitespace before the argument is disallowed. |
nullable | bool | Whether an absent optional argument yields a null value. |
kind | dict[ | The value kind the slot accepts; a dict with a |
form | dict[ | The syntactic form the slot takes; a dict with a |
ArgSpecKindTypetype#
Literal['content', 'operatorname', 'delimiter', 'csname', 'dimension', 'integer', 'keyval', 'column', 'star']Value kind of one parsed argspec slot (content, delimiter, star, ...).
ArgSpecFormTypetype#
Literal['standard', 'star', 'group', 'until', 'delimited', 'paired']Surface form of one parsed argspec slot (mandatory, optional group, paired, ...).