Skip to content

Commit

Permalink
Revert "skip compile for backend only (#1092)" (#1106)
Browse files Browse the repository at this point in the history
This reverts commit 3ff64a5.
  • Loading branch information
picklelo authored Nov 28, 2024
1 parent ca27185 commit ce759e6
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 65 deletions.
4 changes: 0 additions & 4 deletions docs/api-reference/special_events.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Special Events Docs"
---

```python exec
import reflex as rx
```
Expand Down
4 changes: 0 additions & 4 deletions docs/api-routes/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "API Routes Overview"
---

```python exec
import reflex as rx
```
Expand Down
4 changes: 0 additions & 4 deletions docs/client_storage/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Client Storage Overview"
---

```python exec
import reflex as rx
```
Expand Down
4 changes: 0 additions & 4 deletions docs/custom-components/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Custom Components Overview"
---

# Custom Components Overview

```python exec
Expand Down
4 changes: 0 additions & 4 deletions docs/database/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: Database Overview
---

# Database

Reflex uses [sqlmodel](https://sqlmodel.tiangolo.com) to provide a built-in ORM wrapping SQLAlchemy.
Expand Down
1 change: 0 additions & 1 deletion docs/library/graphing/general/tooltip.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
title: "Graphing Tooltip"
components:
- rx.recharts.GraphingTooltip
---
Expand Down
1 change: 0 additions & 1 deletion docs/library/other/html.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
title: "HTML Elements"
components:
- rx.el.A
- rx.el.Abbr
Expand Down
4 changes: 0 additions & 4 deletions docs/recipes/content/grid.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Grid Recipe"
---

```python exec
import reflex as rx
from pcweb.pages.docs import styling
Expand Down
5 changes: 0 additions & 5 deletions docs/state/overview.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
title: "State Overview"
---


```python exec
import reflex as rx
from pcweb.templates.docpage import definition
Expand Down
4 changes: 0 additions & 4 deletions docs/styling/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Styling Overview"
---

```python exec
import reflex as rx
from pcweb.pages.docs import styling, library
Expand Down
4 changes: 0 additions & 4 deletions docs/substates/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Substates Overview"
---

```python exec
import reflex as rx
from typing import Any
Expand Down
4 changes: 0 additions & 4 deletions docs/ui/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "UI Overview"
---

```python exec
from pcweb.pages.docs import components
from pcweb.pages.docs.library import library
Expand Down
4 changes: 0 additions & 4 deletions docs/wrapping-react/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
title: "Wrapping React Overview"
---

```python exec
import reflex as rx
from typing import Any
Expand Down
27 changes: 10 additions & 17 deletions pcweb/pages/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,31 @@
from collections import defaultdict
from types import SimpleNamespace

import reflex as rx
import flexdown

# External Components
from reflex_ag_grid import ag_grid
from reflex_pyplot import pyplot

import reflex as rx
from pcweb.flexdown import xd
from pcweb.pages.docs.component import multi_docs
from pcweb.pages.library_previews import components_previews_pages
from pcweb.route import Route
from pcweb.templates.docpage import docpage, get_toc
from pcweb.whitelist import _check_whitelisted_path
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
from reflex.components.radix.themes.base import RadixThemesComponent
from reflex.config import environment

from .apiref import pages as apiref_pages
from .custom_components import custom_components
from .library import library
from .recipes_overview import overview
from .custom_components import custom_components
from .apiref import pages as apiref_pages
from pcweb.pages.library_previews import components_previews_pages


def should_skip_compile(doc: flexdown.Document):
"""Skip compilation if the markdown file has not been modified since the last compilation."""
# Always skip compilation if the backend only environment variable is set.
if environment.REFLEX_BACKEND_ONLY.get():
return True

# Never skip compilation if the web directory persistance is not set.
if not environment.REFLEX_PERSIST_WEB_DIR.get():
if not os.environ.get("REFLEX_PERSIST_WEB_DIR", False):
return False

# Check if the doc has been compiled already.
Expand Down Expand Up @@ -81,7 +75,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 @@ -90,7 +84,7 @@ 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))

return components


Expand Down Expand Up @@ -137,7 +131,6 @@ 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 @@ -202,7 +195,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 @@ -226,8 +219,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
2 changes: 1 addition & 1 deletion pcweb/pages/docs/recipes_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def card_section():
)


@docpage(set_path="/docs/recipes", right_sidebar=False, page_title="Recipes Overview")
@docpage(set_path="/docs/recipes", right_sidebar=False)
def overview():
return rx.box(
h1_comp(text="Recipes"),
Expand Down

0 comments on commit ce759e6

Please sign in to comment.