Schema stubs¶
Generate a typed schema class from a usage message. See the Schema stubs guide.
generate_stub ¶
Generate a typed schema class from a usage message, to pass as docopt(doc, schema=...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
str
|
The usage message (the same string given to |
required |
name
|
str
|
Class name for the generated schema. |
'Args'
|
style
|
StubStyle
|
|
'dataclass'
|
Returns:
| Type | Description |
|---|---|
str
|
Python source for the schema class. Every field is typed from the grammar ( |
str
|
|
str
|
the value is coerced for free. |
str
|
A key the typed API cannot represent - two usage names collapsing to one field |
str
|
( |
str
|
leading |
str
|
note names is not usable as a schema: |
str
|
outright. Fix the usage, as the note says, and regenerate. |
Raises:
| Type | Description |
|---|---|
DocoptLanguageError
|
The usage message is malformed (the same error |
ValueError
|
|