diff --git a/taipy/gui/viselements.json b/taipy/gui/viselements.json index 7ccd2d331e..e2be3dad14 100644 --- a/taipy/gui/viselements.json +++ b/taipy/gui/viselements.json @@ -10,7 +10,7 @@ { "name": "value", "default_property": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "default_value": "\"\"", "doc": "The value displayed as text by this control." }, @@ -94,7 +94,7 @@ { "name": "value", "default_property": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "default_value": "None", "doc": "The value represented by this control." }, @@ -143,7 +143,7 @@ { "name": "value", "default_property": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "doc": "The numerical value represented by this control." }, { @@ -277,7 +277,7 @@ }, { "name": "unselected_value", - "type": "any", + "type": "Any", "default_value": "None", "doc": "Value assigned to value when no item is selected." }, @@ -366,7 +366,7 @@ { "name": "dates", "default_property": true, - "type": "dynamic(list(datetime))", + "type": "dynamic(list[datetime])", "doc": "The dates that this control represents and can modify.
It is typically bound to a list of two datetime object." }, { @@ -417,7 +417,7 @@ "name": "data", "default_property": true, "required": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "doc": "The data object bound to this chart control.
See the section on the data property below for details." }, { @@ -536,7 +536,7 @@ { "name": "on_range_change", "type": "Callable", - "doc": "The callback function that is invoked when the visible part of the x axis changes.
The function receives three parameters:\n", + "doc": "The callback function that is invoked when the visible part of the x axis changes.
The function receives three parameters:\n", "signature": [ [ "state", @@ -585,32 +585,32 @@ }, { "name": "marker", - "type": "indexed(dict[str, any])", + "type": "indexed(dict[str, Any])", "doc": "The type of markers used for the indicated trace.
See marker for details.
Color, opacity, size and symbol can be column name." }, { "name": "line", - "type": "indexed(Union[str,dict[str,any]])", + "type": "indexed(Union[str,dict[str,Any]])", "doc": "The configuration of the line used for the indicated trace.
See line for details.
If the value is a string, it must be a dash type or pattern (see dash style of lines for details)." }, { "name": "selected_marker", - "type": "indexed(dict[str, any])", + "type": "indexed(dict[str, Any])", "doc": "The type of markers used for selected points in the indicated trace.
See selected marker for details." }, { "name": "layout", - "type": "dynamic(dict[str, any])", + "type": "dynamic(dict[str, Any])", "doc": "The plotly.js compatible layout object." }, { "name": "plot_config", - "type": "dict[str, any]", + "type": "dict[str, Any]", "doc": "The plotly.js compatible configuration options object." }, { "name": "options", - "type": "indexed(dict[str, any])", + "type": "indexed(dict[str, Any])", "doc": "The plotly.js compatible data object where dynamic data will be overridden.." }, { @@ -678,7 +678,7 @@ { "name": "on_click", "type": "Callable", - "doc": "The callback that is invoked when the user clicks in the chart background.
The function receives three parameters:\n", + "doc": "The callback that is invoked when the user clicks in the chart background.
The function receives three parameters:\n", "signature": [ [ "state", @@ -709,7 +709,7 @@ "name": "data", "default_property": true, "required": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "doc": "The data to be represented in this table. This property can be indexed to define other data for comparison." }, { @@ -749,7 +749,7 @@ { "name": "page_size_options", "type": "Union[list[int],str]", - "default_value": "(50, 100, 500)", + "default_value": "[50, 100, 500]", "doc": "The list of available page sizes that users can choose from." }, { @@ -852,7 +852,7 @@ { "name": "on_edit", "type": "Callable", - "doc": "TODO: Default implementation and False value. The name of a function that is triggered when a cell edition is validated.
All parameters of that function are optional:\n
If this property is not set, the user cannot edit cells.", + "doc": "TODO: Default implementation and False value. The name of a function that is triggered when a cell edition is validated.
All parameters of that function are optional:\n
If this property is not set, the user cannot edit cells.", "signature": [ [ "state", @@ -1310,7 +1310,7 @@ }, { "name": "layout", - "type": "dynamic(dict[str, any])", + "type": "dynamic(dict[str, Any])", "doc": "The plotly.js compatible layout object." }, { @@ -1372,7 +1372,7 @@ { "name": "display", "default_property": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "doc": "The label to be displayed.
This can be formatted if it is a numerical value." }, { @@ -1433,7 +1433,7 @@ { "name": "lov", "default_property": true, - "type": "dynamic(Union[str,list[Union[str,Icon,any]]])", + "type": "dynamic(Union[str,list[Union[str,Icon,Any]]])", "doc": "The list of menu option values." }, { @@ -1503,7 +1503,7 @@ { "name": "lov", "default_property": true, - "type": "dict[str, any]", + "type": "dict[str, Any]", "doc": "The list of pages. The keys should be:\n\nThe values are labels. See the section on List of Values for details." } ] @@ -1710,7 +1710,7 @@ }, { "name": "content", - "type": "dynamic(any)", + "type": "dynamic(Any)", "doc": "The content provided to the part. See the documentation section on content providers." } ] @@ -1918,12 +1918,12 @@ { "name": "value", "default_property": true, - "type": "dynamic(any)", + "type": "dynamic(Any)", "doc": "Bound to the selection value." }, { "name": "lov", - "type": "dict[str, any]", + "type": "dict[str, Any]", "doc": "The list of values. See the section on List of Values for details." }, { @@ -1954,7 +1954,7 @@ { "name": "on_change", "type": "Callable", - "doc": "The name of a function that is triggered when the value is updated.
The parameters of that function are all optional:\n", + "doc": "The name of a function that is triggered when the value is updated.
The parameters of that function are all optional:\n", "signature": [ [ "state", @@ -2062,7 +2062,7 @@ }, { "name": "properties", - "type": "dict[str, any]", + "type": "dict[str, Any]", "doc": "Bound to a dictionary that contains additional properties for this element." }, { diff --git a/tools/gui/generate_pyi.py b/tools/gui/generate_pyi.py index 5790a54bfd..f345d57c2f 100644 --- a/tools/gui/generate_pyi.py +++ b/tools/gui/generate_pyi.py @@ -17,6 +17,8 @@ from markdownify import markdownify +__RE_INDEXED_PROPERTY = re.compile(r"^([\w_]+)\[(<\w+>)?([\w]+)()?\]$") + # Make sure we can import the mandatory packages script_dir = os.path.dirname(os.path.realpath(__file__)) if not os.path.isdir(os.path.abspath(os.path.join(script_dir, "taipy"))): @@ -74,9 +76,11 @@ os.system(f"pipenv run stubgen {builder_py_file} --no-import --parse-only --export-less -o ./") with open(builder_pyi_file, "a") as file: - file.write("from typing import Union\n") + file.write("from datetime import datetime\n") + file.write("from typing import Any, Callable, Union\n") file.write("\n") - file.write("from ._element import _Block, _Control, _Element\n") + file.write("from .. import Icon\n") + file.write("from ._element import _Block, _Control\n") def resolve_inherit(name: str, properties, inherits, viselements) -> List[Dict[str, Any]]: @@ -121,6 +125,9 @@ def format_as_parameter(property): property["dynamic"] = " (dynamic)" else: property["dynamic"] = "" + name = property["name"] + if match := __RE_INDEXED_PROPERTY.match(name): + name = f"{match.group(1)}__{match.group(3)}" if type == "Callback" or type == "Function": type = "" else: @@ -134,7 +141,7 @@ def format_as_parameter(property): default_value = "" else: default_value = "" - return f"{property['name']}{type}{default_value}" + return f"{name}{type}{default_value}" def build_doc(name: str, desc: Dict[str, Any]): @@ -143,7 +150,7 @@ def build_doc(name: str, desc: Dict[str, Any]): doc = str(desc["doc"]) if desc["name"] == "class_name": doc = doc.replace("", name) - # This won't work for Scenartio Management and Block elements + # This won't work for Scenario Management and Block elements doc = re.sub(r"(href=\")\.\.((?:.*?)\")", r"\1" + taipy_doc_url + name + r"/../..\2", doc) doc = "\n ".join(markdownify(doc).split("\n")) doc = doc.replace(" \n", " \\n") @@ -169,8 +176,8 @@ def generate_elements(category: str, base_class: str): property_list: List[Dict[str, Any]] = [] property_names: List[str] = [] properties = resolve_inherit(name, desc["properties"], desc.get("inherits", None), viselements) - # Remove hidden properties and indexed properties (TODO?) - properties = [p for p in properties if not p.get("hide", False) and "[" not in p["name"]] + # Remove hidden properties + properties = [p for p in properties if not p.get("hide", False)] # Generate function parameters properties_decl = [format_as_parameter(p) for p in properties] # Generate properties doc