Skip to content

Commit

Permalink
Add support for hiding a property's doc, potentially using the new 'h…
Browse files Browse the repository at this point in the history
…ide' attribute
  • Loading branch information
Fabien Lelaquais committed Jun 11, 2024
1 parent fe13cb7 commit f525379
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/_setup_generation/step_viselements.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def load_elements(
new_elements[element_type] = element_desc
self.elements.update(new_elements)
# Find default property for all element types
# and remove hidden properties.
for element_type, element_desc in new_elements.items():
default_property = None
if properties := element_desc.get(__class__.PROPERTIES, None):
Expand All @@ -97,6 +98,8 @@ def load_elements(
if property[__class__.DEFAULT_PROPERTY]:
default_property = property[__class__.NAME]
del property[__class__.DEFAULT_PROPERTY]
if property.get("hide", False):
property["doc"] = "UNDOCUMENTED"
element_desc[__class__.DEFAULT_PROPERTY] = default_property

# Resolve inheritance
Expand Down Expand Up @@ -246,6 +249,9 @@ def generate_element_doc(element_type: str, element_desc: Dict, prefix: str):
):
property_desc = property_descs[property_name]
name = property_desc[__class__.NAME]
doc = property_desc.get("doc", None)
if doc.startswith("UNDOCUMENTED"):
continue
type = property_desc["type"]
if m := re.match(r"dynamic\((.*?)\)", type):
type = f"<code>{m[1]}</code><br/><i>dynamic</i>"
Expand All @@ -254,7 +260,6 @@ def generate_element_doc(element_type: str, element_desc: Dict, prefix: str):
else:
type = f"<code>{type}</code>"
default_value = property_desc.get("default_value", None)
doc = property_desc.get("doc", None)
if not default_value:
default_value = (
"<i>Required</i>"
Expand Down

0 comments on commit f525379

Please sign in to comment.