Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip compile for backend only #1092

Merged
merged 2 commits into from
Nov 21, 2024
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
4 changes: 4 additions & 0 deletions docs/api-reference/special_events.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: "Special Events Docs"
---

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

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

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

# Custom Components Overview

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

# Database

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

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


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

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

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

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

```python exec
import reflex as rx
from typing import Any
Expand Down
27 changes: 17 additions & 10 deletions pcweb/pages/docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@
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."""
if not os.environ.get("REFLEX_PERSIST_WEB_DIR", False):
# 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():
return False

# Check if the doc has been compiled already.
Expand Down Expand Up @@ -75,7 +81,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 @@ -84,7 +90,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 @@ -131,6 +137,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 @@ -195,7 +202,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 @@ -219,8 +226,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)
@docpage(set_path="/docs/recipes", right_sidebar=False, page_title="Recipes Overview")
def overview():
return rx.box(
h1_comp(text="Recipes"),
Expand Down
Loading