Skip to content

Commit

Permalink
Regenerate tags to improve type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed May 3, 2024
1 parent e9117a8 commit 8a23a05
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 20 deletions.
11 changes: 8 additions & 3 deletions meta/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ textarea:
placeholder: Placeholder text to use when the field is empty.
disabled:
doc: "Whether this option is disabled, meaning it cannot be selected, and will not be submitted with the form."
type: "Optional[Literal['disabled']]"
type: "Optional[bool]"
maxlength: The maximum number of characters permitted in the textarea
wrap:
doc: How to perform word wrapping ("hard" or "soft")
Expand All @@ -172,7 +172,7 @@ option:
doc: "Whether this option is the default selection within the `select` element"
type: "Optional[bool]"
disabled:
doc: "Whether this option is disabled, meaning it cannot be selected, and will not be submitted with the form."
doc: "Whether this option is disabled, meaning it cannot be selected."
type: "Optional[bool]"
value:
doc: "The value to use if this option is selected when submitting the form"
Expand All @@ -184,4 +184,9 @@ select:
doc: Whether the input is required to submit the form it is contained within.
type: "Optional[bool]"
name: The name to use for this value when submitting the form.

disabled:
doc: "Whether this form element is disabled, meaning it cannot be selected, and will not be submitted with the form."
type: "Optional[bool]"
multiple:
doc: "Whether multiple options can be simultaneously selected."
type: "Optional[bool]"
137 changes: 120 additions & 17 deletions pyhtml/__tags/generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -5209,48 +5209,62 @@ class option(Tag):
"""
Used to define an item contained in a select, an [<optgroup>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup), or a [<datalist>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) element. As such, `<option>` can represent menu items in popups and other lists of items in an HTML document.
* `selected`: Whether this option is the default selection within the `select` element
* `disabled`: Whether this option is disabled, meaning it cannot be selected.
* `value`: The value to use if this option is selected when submitting the form
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option)
"""
def __init__(
self,
*children: ChildrenType,

selected: Optional[bool] = None,
disabled: Optional[bool] = None,
value: AttributeType = None,
**attributes: AttributeType,
) -> None:
"""
Used to define an item contained in a select, an [<optgroup>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup), or a [<datalist>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) element. As such, `<option>` can represent menu items in popups and other lists of items in an HTML document.
* `selected`: Whether this option is the default selection within the `select` element
* `disabled`: Whether this option is disabled, meaning it cannot be selected.
* `value`: The value to use if this option is selected when submitting the form
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option)
"""
attributes |= {

'selected': selected,
'disabled': disabled,
'value': value,
}
super().__init__(*children, **attributes)

def __call__( # type: ignore
self,
*children: ChildrenType,

selected: Optional[bool] = None,
disabled: Optional[bool] = None,
value: AttributeType = None,
**attributes: AttributeType,
):
"""
Used to define an item contained in a select, an [<optgroup>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup), or a [<datalist>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) element. As such, `<option>` can represent menu items in popups and other lists of items in an HTML document.
* `selected`: Whether this option is the default selection within the `select` element
* `disabled`: Whether this option is disabled, meaning it cannot be selected.
* `value`: The value to use if this option is selected when submitting the form
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option)
"""
attributes |= {

'selected': selected,
'disabled': disabled,
'value': value,
}
return super().__call__(*children, **attributes)

def _get_default_attributes(self, given: dict[str, AttributeType]) -> dict[str, AttributeType]:
return {}
return {'selected': None, 'disabled': None, 'value': None}


class output(Tag):
Expand Down Expand Up @@ -5353,62 +5367,111 @@ class select(Tag):
"""
Represents a control that provides a menu of options.
* `required`: Whether the input is required to submit the form it is contained within.
* `name`: The name to use for this value when submitting the form.
* `disabled`: Whether this form element is disabled, meaning it cannot be selected, and will not be submitted with the form.
* `multiple`: Whether multiple options can be simultaneously selected.
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select)
"""
def __init__(
self,
*children: ChildrenType,

required: Optional[bool] = None,
name: AttributeType = None,
disabled: Optional[bool] = None,
multiple: Optional[bool] = None,
id: Optional[str] = None,
_class: Optional[str] = None,
style: Optional[str] = None,
**attributes: AttributeType,
) -> None:
"""
Represents a control that provides a menu of options.
* `required`: Whether the input is required to submit the form it is contained within.
* `name`: The name to use for this value when submitting the form.
* `disabled`: Whether this form element is disabled, meaning it cannot be selected, and will not be submitted with the form.
* `multiple`: Whether multiple options can be simultaneously selected.
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select)
"""
attributes |= {

'_class': _class,
'id': id,
'style': style,
'required': required,
'name': name,
'disabled': disabled,
'multiple': multiple,
}
super().__init__(*children, **attributes)

def __call__( # type: ignore
self,
*children: ChildrenType,

required: Optional[bool] = None,
name: AttributeType = None,
disabled: Optional[bool] = None,
multiple: Optional[bool] = None,
id: Optional[str] = None,
_class: Optional[str] = None,
style: Optional[str] = None,
**attributes: AttributeType,
):
"""
Represents a control that provides a menu of options.
* `required`: Whether the input is required to submit the form it is contained within.
* `name`: The name to use for this value when submitting the form.
* `disabled`: Whether this form element is disabled, meaning it cannot be selected, and will not be submitted with the form.
* `multiple`: Whether multiple options can be simultaneously selected.
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select)
"""
attributes |= {

'_class': _class,
'id': id,
'style': style,
'required': required,
'name': name,
'disabled': disabled,
'multiple': multiple,
}
return super().__call__(*children, **attributes)

def _get_default_attributes(self, given: dict[str, AttributeType]) -> dict[str, AttributeType]:
return {}
return {'required': None, 'name': None, 'disabled': None, 'multiple': None}


class textarea(Tag):
"""
Represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example, a comment on a review or feedback form.
* `required`: Whether the input is required to submit the form it is contained within.
* `name`: The name to use for this value when submitting the form.
* `rows`: The number of rows (lines) to use in the text area. Value should be an integer, but given as type `str`.
* `cols`: The number of columns (length of each line) to use in the text area. Value should be an integer, but given as type `str`.
* `placeholder`: Placeholder text to use when the field is empty.
* `disabled`: Whether this option is disabled, meaning it cannot be selected, and will not be submitted with the form.
* `maxlength`: The maximum number of characters permitted in the textarea
* `wrap`: How to perform word wrapping ("hard" or "soft")
* `readonly`: Whether this option is read-only, meaning it cannot be modified
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea)
"""
def __init__(
self,
*children: ChildrenType,
required: Optional[bool] = None,
name: AttributeType = None,
rows: Optional[str] = None,
cols: Optional[str] = None,
placeholder: AttributeType = None,
disabled: Optional[bool] = None,
maxlength: AttributeType = None,
wrap: Union[Literal['hard', 'soft'], None] = None,
readonly: Optional[bool] = None,
id: Optional[str] = None,
_class: Optional[str] = None,
style: Optional[str] = None,
Expand All @@ -5418,6 +5481,14 @@ def __init__(
Represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example, a comment on a review or feedback form.
* `required`: Whether the input is required to submit the form it is contained within.
* `name`: The name to use for this value when submitting the form.
* `rows`: The number of rows (lines) to use in the text area. Value should be an integer, but given as type `str`.
* `cols`: The number of columns (length of each line) to use in the text area. Value should be an integer, but given as type `str`.
* `placeholder`: Placeholder text to use when the field is empty.
* `disabled`: Whether this option is disabled, meaning it cannot be selected, and will not be submitted with the form.
* `maxlength`: The maximum number of characters permitted in the textarea
* `wrap`: How to perform word wrapping ("hard" or "soft")
* `readonly`: Whether this option is read-only, meaning it cannot be modified
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea)
"""
Expand All @@ -5426,13 +5497,29 @@ def __init__(
'id': id,
'style': style,
'required': required,
'name': name,
'rows': rows,
'cols': cols,
'placeholder': placeholder,
'disabled': disabled,
'maxlength': maxlength,
'wrap': wrap,
'readonly': readonly,
}
super().__init__(*children, **attributes)

def __call__( # type: ignore
self,
*children: ChildrenType,
required: Optional[bool] = None,
name: AttributeType = None,
rows: Optional[str] = None,
cols: Optional[str] = None,
placeholder: AttributeType = None,
disabled: Optional[bool] = None,
maxlength: AttributeType = None,
wrap: Union[Literal['hard', 'soft'], None] = None,
readonly: Optional[bool] = None,
id: Optional[str] = None,
_class: Optional[str] = None,
style: Optional[str] = None,
Expand All @@ -5442,6 +5529,14 @@ def __call__( # type: ignore
Represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example, a comment on a review or feedback form.
* `required`: Whether the input is required to submit the form it is contained within.
* `name`: The name to use for this value when submitting the form.
* `rows`: The number of rows (lines) to use in the text area. Value should be an integer, but given as type `str`.
* `cols`: The number of columns (length of each line) to use in the text area. Value should be an integer, but given as type `str`.
* `placeholder`: Placeholder text to use when the field is empty.
* `disabled`: Whether this option is disabled, meaning it cannot be selected, and will not be submitted with the form.
* `maxlength`: The maximum number of characters permitted in the textarea
* `wrap`: How to perform word wrapping ("hard" or "soft")
* `readonly`: Whether this option is read-only, meaning it cannot be modified
[View full documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea)
"""
Expand All @@ -5450,11 +5545,19 @@ def __call__( # type: ignore
'id': id,
'style': style,
'required': required,
'name': name,
'rows': rows,
'cols': cols,
'placeholder': placeholder,
'disabled': disabled,
'maxlength': maxlength,
'wrap': wrap,
'readonly': readonly,
}
return super().__call__(*children, **attributes)

def _get_default_attributes(self, given: dict[str, AttributeType]) -> dict[str, AttributeType]:
return {'required': None}
return {'required': None, 'name': None, 'rows': None, 'cols': None, 'placeholder': None, 'disabled': None, 'maxlength': None, 'wrap': None, 'readonly': None}


class details(Tag):
Expand Down

0 comments on commit 8a23a05

Please sign in to comment.