diff --git a/docs/library/dynamic-rendering/cond.md b/docs/library/dynamic-rendering/cond.md index 355ac2a970..19a2c9040c 100644 --- a/docs/library/dynamic-rendering/cond.md +++ b/docs/library/dynamic-rendering/cond.md @@ -1,8 +1,3 @@ ---- -components: - - rx.components.core.Cond ---- - ```python exec import reflex as rx ``` @@ -146,4 +141,4 @@ elif((c>a and c>b) and (c != a and c != b)): print(c, " is the largest!") else: print("Some of the numbers are equal!") -``` \ No newline at end of file +``` diff --git a/docs/library/dynamic-rendering/foreach.md b/docs/library/dynamic-rendering/foreach.md index 0977fd5640..d5490c4780 100644 --- a/docs/library/dynamic-rendering/foreach.md +++ b/docs/library/dynamic-rendering/foreach.md @@ -1,8 +1,3 @@ ---- -components: - - rx.foreach ---- - ```python exec import reflex as rx ``` @@ -14,6 +9,7 @@ This is useful for dynamically rendering a list of items defined in a state. ```md alert warning # `rx.foreach` is specialized for usecases where the iterable is defined in a state var. + For an iterable where the content doesn't change at runtime, i.e a constant, using a list/dict comprehension instead of `rx.foreach` is preferred. ``` diff --git a/docs/library/dynamic-rendering/match.md b/docs/library/dynamic-rendering/match.md index 2336c6ce3e..693cc26820 100644 --- a/docs/library/dynamic-rendering/match.md +++ b/docs/library/dynamic-rendering/match.md @@ -1,8 +1,3 @@ ---- -components: - - rx.match ---- - ```python exec import reflex as rx ``` diff --git a/pcweb/pages/docs/__init__.py b/pcweb/pages/docs/__init__.py index 39ad4223ed..e58db95fca 100644 --- a/pcweb/pages/docs/__init__.py +++ b/pcweb/pages/docs/__init__.py @@ -76,7 +76,7 @@ def build_nested_namespace( def get_components_from_metadata(current_doc): components = [] - + for comp_str in current_doc.metadata.get("components", []): component = eval(comp_str) if isinstance(component, type): @@ -85,7 +85,9 @@ def get_components_from_metadata(current_doc): components.append((component.__self__, comp_str)) elif isinstance(component, SimpleNamespace) and hasattr(component, "__call__"): components.append((component.__call__.__self__, comp_str)) - + else: + raise ValueError(f"Invalid component: {component}") + return components @@ -132,6 +134,7 @@ def exec_blocks(doc, href): "docs/recipes/content/grid.md": "Grid Recipe", } + def get_component(doc: str, title: str): if doc.endswith("-style.md"): return @@ -162,13 +165,14 @@ def get_component(doc: str, title: str): return multi_docs(path=route, comp=d, component_list=clist, title=title2) if doc.startswith("docs/library"): clist = [title, *get_components_from_metadata(d)] - if issubclass( - clist[1][0], - (RadixThemesComponent, RadixPrimitiveComponent), - ): - component_list[category].append(clist) - else: - component_list[category].append(clist) + if len(clist) > 1: + if issubclass( + clist[1][0], + (RadixThemesComponent, RadixPrimitiveComponent), + ): + component_list[category].append(clist) + else: + component_list[category].append(clist) if should_skip_compile(doc): outblocks.append((d, route)) return @@ -183,12 +187,16 @@ def get_component(doc: str, title: str): ) -doc_routes = [ - library, - custom_components, - overview, - *components_previews_pages, -] + apiref_pages + cloud_cliref_pages +doc_routes = ( + [ + library, + custom_components, + overview, + *components_previews_pages, + ] + + apiref_pages + + cloud_cliref_pages +) for api_route in apiref_pages: @@ -200,7 +208,7 @@ def get_component(doc: str, title: str): build_nested_namespace(docs_ns, ["api_reference"], title, api_route) for doc in sorted(flexdown_docs): - path = doc.split("/")[1:-1] + path = doc.split("/")[1:-1] title = rx.utils.format.to_snake_case(os.path.basename(doc).replace(".md", "")) title2 = to_title_case(title) @@ -224,8 +232,8 @@ def get_component(doc: str, title: str): for doc in flexdown_docs: - if 'recipes' in doc: - category = doc.split('/')[2] + if "recipes" in doc: + category = doc.split("/")[2] recipes_list[category].append(doc) for name, ns in docs_ns.__dict__.items():