Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions docs/library/dynamic-rendering/cond.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
components:
- rx.components.core.Cond
---

```python exec
import reflex as rx
```
Expand Down Expand Up @@ -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!")
```
```
6 changes: 1 addition & 5 deletions docs/library/dynamic-rendering/foreach.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
components:
- rx.foreach
---

```python exec
import reflex as rx
```
Expand All @@ -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.
```

Expand Down
5 changes: 0 additions & 5 deletions docs/library/dynamic-rendering/match.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
components:
- rx.match
---

```python exec
import reflex as rx
```
Expand Down
44 changes: 26 additions & 18 deletions pcweb/pages/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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():
Expand Down
Loading