Repository: Avaiga/taipy
File: tools/gui/generate_pyi.py (Python)

Code before:
            name = element[0]
            desc = element[1]
            properties_doc = ""
            property_list: List[Dict[str, Any]] = []
            property_indices: List[int] = []
            properties = resolve_inherit(
                name,
                desc["properties"],
                desc.get("inherits", None),
                blocks.get(prefix, []),
                controls.get(prefix, []),
                undocumented.get(prefix, []),
            )
            # Remove hidden properties
            properties = [p for p in properties if not p.get("hide", False)]
            # Generate function parameters (modifies properties!)
            properties_decl = [format_as_parameter(p, name) for p in properties]
            # Generate properties doc
            for idx, property in enumerate(properties):
                if "default_property" in property and property["default_property"] is True:
                    property_list.insert(0, property)
                    property_indices.insert(0, idx)
                    continue
                property_list.append(property)
                property_indices.append(idx)
            # Append properties doc to element doc (once ordered)
            for property in property_list:
                property_doc = build_doc(name, property)
                properties_doc += property_doc
            # Sort properties by indices
            properties_decl = [properties_decl[idx] for idx in property_indices]
            if name == "text":
                properties_doc += ("inline\n  If True, the text is created next to "
                                 + "the previous element and not on a new line.\n\n")
                # Manually add the 'inline' property for the text control
                properties_decl.append("inline: bool = False")
            if len(properties_decl) > 1:
                properties_decl.insert(1, "*")
            # Append element to __init__.pyi
            with open(builder_pyi_file, "a", encoding="utf-8") as file:
                file.write(
                    element_template(
                        name,
                        base_class,
                        "n" if name[0] in ["a", "e", "i", "o"] else "",
                        ", ".join(properties_decl),
                        properties_doc,
                        indent,
                    )
                )


Review comment (suggestion):
```suggestion
            # Append properties doc to element doc
```

Code after:
            name = element[0]
            desc = element[1]
            properties_doc = ""
            property_list: List[Dict[str, Any]] = []
            property_indices: List[int] = []
            properties = resolve_inherit(
                name,
                desc["properties"],
                desc.get("inherits", None),
                blocks.get(prefix, []),
                controls.get(prefix, []),
                undocumented.get(prefix, []),
            )
            # Remove hidden properties
            properties = [p for p in properties if not p.get("hide", False)]
            # Generate function parameters (modifies properties!)
            properties_decl = [format_as_parameter(p, name) for p in properties]
            # Generate properties doc
            for idx, property in enumerate(properties):
                if "default_property" in property and property["default_property"] is True:
                    property_list.insert(0, property)
                    property_indices.insert(0, idx)
                    continue
                property_list.append(property)
                property_indices.append(idx)
            # Append properties doc to element doc
            for property in property_list:
                property_doc = build_doc(name, property)
                properties_doc += property_doc
            # Sort properties by indices
            properties_decl = [properties_decl[idx] for idx in property_indices]
            if name == "text":
                properties_doc += ("inline\n  If True, the text is created next to "
                                 + "the previous element and not on a new line.\n\n")
                # Manually add the 'inline' property for the text control
                properties_decl.append("inline: bool = False")
            if len(properties_decl) > 1:
                properties_decl.insert(1, "*")
            # Append element to __init__.pyi
            with open(builder_pyi_file, "a", encoding="utf-8") as file:
                file.write(
                    element_template(
                        name,
                        base_class,
                        "n" if name[0] in ["a", "e", "i", "o"] else "",
                        ", ".join(properties_decl),
                        properties_doc,
                        indent,
                    )
                )