instruction
stringlengths
0
1k
input
stringlengths
1
1k
output
stringlengths
10
6.51k
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment
from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lin
from reflex.components.component import Component
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component
from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of
from reflex.components.el.elements.base import BaseHTML
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML
from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent
from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop c
from reflex.components.radix.themes.base import RadixThemesComponent
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent
from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update t
from pcweb.flexdown import markdown, xd
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd
def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0:
from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp
"""Utility functions for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp
class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_va
def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), }
ns for the component docs page.""" import hashlib import inspect import os import re import textwrap from types import UnionType from typing import ( Any, Literal, Sequence, Type, Union, _GenericAlias, get_args, get_origin, ) import reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), }
def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is com
class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str
reflex as rx from flexdown.document import Document from reflex.base import Base from reflex.components.base.fragment import Fragment from reflex.components.component import Component from reflex.components.el.elements.base import BaseHTML from reflex.components.radix.primitives.base import RadixPrimitiveComponent from reflex.components.radix.themes.base import RadixThemesComponent from pcweb.flexdown import markdown, xd from pcweb.templates.docpage import docdemobox, docpage, get_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str
class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Comp
def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip()
_toc, h1_comp, h2_comp def get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value
# Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argu
if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value
get_code_style(color: str): return { "color": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0:
if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1
comment_line = lines[start_index - 1].strip()
or": rx.color(color, 11), "border_radius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip()
# Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argu
if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value
ius": "0.25rem", "border": f"1px solid {rx.color(color, 5)}", "background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"):
if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_saf
default_match = re.search(r"Default:\s*(.+)$", comment_line)
"background": rx.color(color, 3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line)
# Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argu
if default_match: default_value = default_match.group(1).strip() return default_value
3), } class Prop(Base): """Hold information about a prop.""" # The name of the prop. name: str # The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match:
return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1)
default_value = default_match.group(1).strip()
# The type of the prop. type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line
parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip(
line = lines[start_index]
type_: Any # The description of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index]
if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg
parts = line.split("=", 1)
tion of the prop. description: str # The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1)
value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\
if len(parts) != 2: return ""
# The default value of the prop. default_value: str def get_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return ""
# Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe,
value = parts[1].strip()
_default_value(lines: list[str], start_index: int) -> str: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete
open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() cla
open_brackets = value.count("{") - value.count("}")
r: """Process lines of code to get the value of a prop, handling multi-line values. Args: lines: The lines of code to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}")
# If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a componen
open_parentheses = value.count("(") - value.count(")")
e to process. start_index: The index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines
while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[
current_index = start_index + 1
he index of the line where the prop is defined. Returns: The default value of the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1
# Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get
while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1
the prop. """ # Check for the default value in the prop comment (Default: ) # Need to update the components comments in order to get the default value if start_index > 0: comment_line = lines[start_index - 1].strip() if comment_line.startswith("#"): default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines):
value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **
next_line = lines[current_index].strip()
default_match = re.search(r"Default:\s*(.+)$", comment_line) if default_match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments
# Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns:
value = re.split(r"\s+#", value)[0].strip()
match: default_value = default_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary
value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary o
def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg
lt_match.group(1).strip() return default_value # Get the initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match):
# Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) ->
content = match.group(1)
he initial line line = lines[start_index] parts = line.split("=", 1) if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument
return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns:
first_arg = re.split(r",", content)[0].strip()
if len(parts) != 2: return "" value = parts[1].strip() # Check if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg
value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props()
value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value)
ck if the value is complete open_brackets = value.count("{") - value.count("}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value)
return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0]
value = re.sub(r"\bColor\s*\(", "rx.color(", value)
}") open_parentheses = value.count("(") - value.count(")") # If brackets or parentheses are not balanced, collect more lines current_index = start_index + 1 while (open_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip()
# Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPO
class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments])
n_brackets > 0 or open_parentheses > 0) and current_index < len(lines): next_line = lines[current_index].strip() value += " " + next_line open_brackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = []
def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns:
def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ]
rackets += next_line.count("{") - next_line.count("}") open_parentheses += next_line.count("(") - next_line.count(")") current_index += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code.
def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns:
self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ]
ex += 1 # Remove any trailing comments value = re.split(r"\s+#", value)[0].strip() # Process Var.create_safe within dictionary def process_var_create_safe(match): content = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ]
def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.co
def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__
ntent = match.group(1) # Extract only the first argument first_arg = re.split(r",", content)[0].strip() return first_arg value = re.sub(r"Var\.create_safe\((.*?)\)", process_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__
def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}"
def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props
ss_var_create_safe, value) value = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """
parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = r
props = self._get_props()
e = re.sub(r"\bColor\s*\(", "rx.color(", value) return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props()
if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is No
parent_cls = self.component.__bases__[0]
return value.strip() class Source(Base): """Parse the source code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0]
return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got
if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ]
code of a component.""" # The component to parse. component: Type[Component] # The source code. code: list[str] = [] def __init__(self, *args, **kwargs): """Initialize the source code parser.""" super().__init__(*args, **kwargs) # Get the source code. self.code = [ line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML:
# filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue
parent_props = Source(component=parent_cls).get_props()
line for line in inspect.getsource(self.component).splitlines() if len(line) > 0 ] def get_docs(self) -> str: """Get the docstring of the component. Returns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props
@staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._is
def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out
rns: The docstring of the component. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = []
comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop,
props = self.component.get_props()
nent. """ return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props()
for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_,
comments = []
return self.component.__doc__ def get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = []
return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( no
for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) )
ps(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code):
if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comme
line = self.code[i]
""Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i]
if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @s
if re.search("def ", line): break
Returns: A dictionary of the props and their descriptions. """ props = self._get_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break
match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for
if line.strip().startswith("#"): comments.append(line) continue
t_props() parent_cls = self.component.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue
if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types t
match = re.search(r"\w+:", line)
t.__bases__[0] if parent_cls != rx.Component and parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line)
prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float"
if match is None: continue
parent_cls != BaseHTML: parent_props = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue
if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "
prop = match.group(0).strip(":")
rops = Source(component=parent_cls).get_props() # filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":")
default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "
if prop not in props: continue
# filter out the props that have been overridden in the parent class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue
if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "
default_value = get_default_value(self.code, i)
t class. props += [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i)
comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.h
if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" )
+= [ prop for prop in parent_props if prop.name not in {p.name for p in props} ] return props def _get_props(self) -> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0:
assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def
comment_above = self.code[i - 1].strip()
-> list[Prop]: """Get a dictionary of the props and their descriptions. Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" )
comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class Pro
comment = Source.get_comment(comments)
Returns: A dictionary of the props and their descriptions. """ out = [] props = self.component.get_props() comments = [] for i, line in enumerate(self.code): line = self.code[i] if re.search("def ", line): break if line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear()
out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COM
type_ = self.component.get_fields()[prop].outer_type_
line.strip().startswith("#"): comments.append(line) continue match = re.search(r"\w+:", line) if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod
# Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPO
def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments])
if match is None: continue prop = match.group(0).strip(":") if prop not in props: continue default_value = get_default_value(self.code, i) if i > 0: comment_above = self.code[i - 1].strip() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors.
count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "defa
TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", }
p() assert comment_above.startswith("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0
class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = g
def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8]
("#"), ( f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1
hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(
s = str(count)
f"Expected comment, got {comment_above}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count)
hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}")
hash_object = hashlib.sha256(s.encode())
ove}" ) comment = Source.get_comment(comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode())
return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bo
hex_dig = hash_object.hexdigest()
comments) comments.clear() type_ = self.component.get_fields()[prop].outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8]
EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}")
class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs."""
.outer_type_ out.append( Prop( name=prop, type_=type_, default_value=default_value, description=comment, ) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs."""
def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if no
EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ]
) ) return out @staticmethod def get_comment(comments: list[str]): return "".join([comment.strip().strip("#") for comment in comments]) # Mapping from types to colors. TYPE_COLORS = { "int": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict):
try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "B
if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment()
": "red", "float": "orange", "str": "yellow", "bool": "teal", "Component": "purple", "List": "blue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try:
except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): re
type_ = rx.utils.types.get_args(prop.type_)[0]
ue", "Dict": "blue", "Tuple": "blue", "None": "gray", "Figure": "green", "Literal": "gray", "Union": "gray", } count = 0 def get_id(s): global count count += 1 s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try:
except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root(
if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, )
s = str(count) hash_object = hashlib.sha256(s.encode()) hex_dig = hash_object.hexdigest() return "a_" + hex_dig[:8] class PropDocsState(rx.State): """Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]:
PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0]
name = get_id(f"{component.__qualname__}_{prop.name}")
"Container for dynamic vars used by the prop docs.""" EXCLUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name)
prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name)
setter = getattr(PropDocsState, f"set_{name}")
LUDED_COMPONENTS = [ "Theme", "ThemePanel", "DrawerRoot", "DrawerTrigger", "DrawerOverlay", "DrawerPortal", "DrawerContent", "DrawerClose", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}")
return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsSt
prop_dict[prop.name] = var
e", ] def render_select(prop, component, prop_dict): if ( not rx.utils.types._issubclass( component, (RadixThemesComponent, RadixPrimitiveComponent) ) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass
# For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[
if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment()
) or component.__name__ in EXCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type
# Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7
if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, )
XCLUDED_COMPONENTS ): return rx.fragment() try: type_ = rx.utils.types.get_args(prop.type_)[0] except Exception: return rx.fragment() try: if issubclass(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union:
# Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7
if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, )
s(type_, bool) and prop.name not in [ "open", "checked", "as_child", "default_open", "default_checked", ]: name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values
option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, nam
literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ]
mponent.__qualname__}_{prop.name}") PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ]
name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState,
option = literal_values[0]
PropDocsState.add_var(name, bool, False) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0]
PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name ==
name = get_id(f"{component.__qualname__}_{prop.name}")
tattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option)
setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.b
var = getattr(PropDocsState, name)
prop_dict[prop.name] = var return rx.checkbox( var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name)
prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button(
setter = getattr(PropDocsState, f"set_{name}")
var, on_change=setter, ) except TypeError: pass if not isinstance(type_, _GenericAlias) or ( type_.__origin__ not in (Literal, Union) ): return rx.fragment() # For the Union[Literal, Breakpoints] type if type_.__origin__ is Union: if not all( arg.__name__ in ["Literal", "Breakpoints"] for arg in type_.__args__ ): return rx.fragment() else: # Get the literal values literal_values = [ str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}")
return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"),
prop_dict[prop.name] = var
str(lit_arg) for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option.
name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0
option = type_.__args__[0]
for arg in type_.__args__ if get_origin(arg) is Literal for lit_arg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0]
PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0.0536285 3.35949 0.135232 3.15803Z"></path></svg>"""
name = get_id(f"{component.__qualname__}_{prop.name}")
rg in arg.__args__ ] option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option)
setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0.0536285 3.35949 0.135232 3.15803Z"></path></svg>""" ), color_scheme=var,
var = getattr(PropDocsState, name)
option = literal_values[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name)
prop_dict[prop.name] = var if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0.0536285 3.35949 0.135232 3.15803Z"></path></svg>""" ), color_scheme=var, variant="surface", class
setter = getattr(PropDocsState, f"set_{name}")
get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}")
if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0.0536285 3.35949 0.135232 3.15803Z"></path></svg>""" ), color_scheme=var, variant="surface", class_name="w-32 justify-between",
prop_dict[prop.name] = var
_}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var return rx.select.root( rx.select.trigger(class_name="w-32 font-small text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item(item, value=item, class_name="font-small") for item in literal_values ] ) ), value=var, on_change=setter, ) # Get the first option. option = type_.__args__[0] name = get_id(f"{component.__qualname__}_{prop.name}") PropDocsState.add_var(name, str, option) var = getattr(PropDocsState, name) setter = getattr(PropDocsState, f"set_{name}") prop_dict[prop.name] = var
return rx.select.root( rx.select.trigger(class_name="font-small w-32 text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item( item, value=item, class_name="font-small", _hover=( {"background": f"var(--{item}-9)"} if prop.name == "color_scheme" else None ), ) for item in list(map(str, type_.__args__)) ] ), ), value=var, on_change=setter, ) def hovercard(trigger: rx.Component, content: rx.Component) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger( trigger, ), rx.hover_card.content( content, side="top", align="center", class_name="font-small
if prop.name == "color_scheme": return rx.popover.root( rx.popover.trigger( rx.box( rx.button( rx.text(var, class_name="font-small"), # Match the select.trigger svg icon rx.html( """<svg width="9" height="9" viewBox="0 0 9 9" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" class="rt-SelectIcon" aria-hidden="true"><path d="M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0.0536285 3.35949 0.135232 3.15803Z"></path></svg>""" ), color_scheme=var, variant="surface", class_name="w-32 justify-between", ), ), ), rx.popover.content( rx.grid( *[ rx.box( rx.icon( "check", size=15, display=rx.cond(var == color, "block", "none"), class_name="text-gray-12 absolute top-1/2 left-1/2 translate-x-[-50%] translate-y-[-50%]", ), bg=f"var(--{color}-9)", on_click=PropDocsState.setvar(f"{name}", color), border=rx.cond( var == color, "2px solid var(--gray-12)", "" ), class_name="relative shrink-0 rounded-md size-8 cursor-pointer", ) for color in list(map(str, type_.__args__)) ], columns="6", spacing="3", ), ), )
ve shrink-0 rounded-md size-8 cursor-pointer", ) for color in list(map(str, type_.__args__)) ], columns="6", spacing="3", ), ), ) return rx.select.root( rx.select.trigger(class_name="font-small w-32 text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item( item, value=item, class_name="font-small", _hover=( {"background": f"var(--{item}-9)"} if prop.name == "color_scheme" else None ), ) for item in list(map(str, type_.__args__)) ] ), ), value=var, on_change=setter, )
def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_)
def hovercard(trigger: rx.Component, content: rx.Component) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger( trigger, ), rx.hover_card.content( content, side="top", align="center", class_name="font-small text-slate-11" ), )
rx.select.trigger(class_name="font-small w-32 text-slate-11"), rx.select.content( rx.select.group( *[ rx.select.item( item, value=item, class_name="font-small", _hover=( {"background": f"var(--{item}-9)"} if prop.name == "color_scheme" else None ), ) for item in list(map(str, type_.__args__)) ] ), ), value=var, on_change=setter, ) def hovercard(trigger: rx.Component, content: rx.Component) -> rx.Component: return rx.hover_card.root( rx.hover_card.trigger( trigger, ), rx.hover_card.content( content, side="top", align="center", class_name="font-small text-slate-11" ), )
def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't in
def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), )
ent: return rx.hover_card.root( rx.hover_card.trigger( trigger, ), rx.hover_card.content( content, side="top", align="center", class_name="font-small text-slate-11" ), ) def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop.
if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values)
type_ = prop.type_
r_card.root( rx.hover_card.trigger( trigger, ), rx.hover_card.content( content, side="top", align="center", class_name="font-small text-slate-11" ), ) def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_
origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_component
if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0]
t( content, side="top", align="center", class_name="font-small text-slate-11" ), ) def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var.
origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_component
type_ = rx.utils.types.get_args(type_)[0]
er", class_name="font-small text-slate-11" ), ) def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0]
args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_c
origin = get_origin(type_)
t-slate-11" ), ) def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_)
literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1
args = get_args(type_)
def color_scheme_hovercard(literal_values: list[str]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_)
# Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.j
literal_values = []
]) -> rx.Component: return hovercard( rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop
# List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) els
all_types = []
rx.icon(tag="palette", size=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types
short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal"
max_prop_values = 2
ze=15, class_name="!text-slate-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2
common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal" if not non_l
short_type_name = None
te-9 shrink-0"), rx.grid( *[ rx.tooltip( rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None
# Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal" if not non_literal_types
common_types = {}
rx.box( bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values
# Get the default value. default_value = prop.default_value if prop.default_value is not None else "-" # Get the color of the prop. color = TYPE_COLORS.get(short_type_name, "gray") # Return the docs for the prop. return [ rx.table.cell( rx.box( rx.code(prop.name, class_name="code-style text-nowrap leading-normal"), hovercard( rx.icon( tag="info", size=15, class_name="!text-slate-9 shrink-0", ), rx.text(prop.description, class_name="font-small text-slate-11"), ), class_name="flex flex-row items-center gap-2", ), class_name="justify-start pl-4", ), rx.table.cell( rx.box( rx.cond( (len(literal_values) > 0) & (prop.name not in common_types), rx.c
if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal" if not non_literal_types else f"Union[Literal, {', '.join(non_literal_types)}]" ) short_type_name = "Union" elif origin is dict: key_type = args[0].__name__ if args else "Any" value_type = ( getattr(args[1], "__name__", str(args[1])) if len(args) > 1 else "Any" ) type_name = f"Dict[{key_type}, {value_type}]" short_type_name = "Dict" elif origin is Literal: literal_values = list(map(str, args)) if len(literal_values) > max_prop_values and prop.name not in common_types: type_name = "Literal" else: type_name = " | ".join([f'"{value}"' for value in literal_values]) short_type_name = "Literal" else: type_name = type_.__name__ short_type_name = type_name
bg=f"var(--{color}-9)", class_name="rounded-md size-8 shrink-0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType):
# List for all the non-literal types for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__) if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal" if not non_literal_types else f"Union[Literal, {', '.join(non_literal_types)}]" ) short_type_name = "Union" elif origi
non_literal_types = []
0" ), content=color, delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types
if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal" if not non_literal_types else f"Union[Literal, {', '.join(non_literal_types)}]" ) short_type_name = "Union" elif origin is dict: key_type = args[0].__name__ if args else "Any" value_type = ( getattr(args[1], "__name__", str(args[1])) if len(args) > 1 else "Any" ) type_name = f"Dict[{key_type}, {value_type}]" short_type_name = "Dict" elif origin is Literal: literal_values = list(map(str, args)) if len(lit
for arg in args: all_types.append(arg.__name__) if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__)
delay_duration=0, ) for color in literal_values ], columns="6", spacing="3", ), ) def prop_docs( prop: Prop, prop_dict, component, is_interactive: bool ) -> list[rx.Component]: """Generate the docs for a prop.""" # Get the type of the prop. type_ = prop.type_ if rx.utils.types._issubclass(prop.type_, rx.Var): # For vars, get the type of the var. type_ = rx.utils.types.get_args(type_)[0] origin = get_origin(type_) args = get_args(type_) literal_values = [] # Literal values of the prop all_types = [] # List for all the prop types max_prop_values = 2 short_type_name = None common_types = {} # Used to exclude common types from the max_prop_values if origin in (Union, UnionType): non_literal_types = [] # List for all the non-literal types for arg in args: all_types.append(arg.__name__)
if len(literal_values) < 10: literal_str = " | ".join(f'"{value}"' for value in literal_values) type_components = ([literal_str] if literal_str else []) + non_literal_types type_name = ( " | ".join(type_components) if len(type_components) == 1 else f"Union[{', '.join(type_components)}]" ) else: type_name = ( "Literal" if not non_literal_types else f"Union[Literal, {', '.join(non_literal_types)}]" ) short_type_name = "Union" elif origin is dict: key_type = args[0].__name__ if args else "Any" value_type = ( getattr(args[1], "__name__", str(args[1])) if len(args) > 1 else "Any" ) type_name = f"Dict[{key_type}, {value_type}]" short_type_name = "Dict" elif origin is Literal: literal_values = list(map(str, args)) if len(lit
if get_origin(arg) is Literal: literal_values.extend(str(lit_arg) for lit_arg in arg.__args__) elif arg.__name__ != "Breakpoints": # Don't include Breakpoints non_literal_types.append(arg.__name__)