From 10e6b0959159cc2da0cda44d9bc93678f169500c Mon Sep 17 00:00:00 2001 From: Lendemor Date: Wed, 13 Nov 2024 19:26:10 +0100 Subject: [PATCH 1/2] move 'manual titles' to their respective files --- docs/api-reference/special_events.md | 4 ++++ docs/api-routes/overview.md | 4 ++++ docs/client_storage/overview.md | 4 ++++ docs/custom-components/overview.md | 4 ++++ docs/database/overview.md | 4 ++++ docs/library/graphing/general/tooltip.md | 1 + docs/library/other/html.md | 1 + docs/recipes/content/grid.md | 4 ++++ docs/state/overview.md | 5 +++++ docs/styling/overview.md | 4 ++++ docs/substates/overview.md | 4 ++++ docs/ui/overview.md | 4 ++++ docs/wrapping-react/overview.md | 4 ++++ pcweb/pages/docs/recipes_overview.py | 2 +- 14 files changed, 48 insertions(+), 1 deletion(-) diff --git a/docs/api-reference/special_events.md b/docs/api-reference/special_events.md index f76eaffda..f9bbf1d8b 100644 --- a/docs/api-reference/special_events.md +++ b/docs/api-reference/special_events.md @@ -1,3 +1,7 @@ +--- +title: "Special Events Docs" +--- + ```python exec import reflex as rx ``` diff --git a/docs/api-routes/overview.md b/docs/api-routes/overview.md index 24834ea9c..fa01a52f5 100644 --- a/docs/api-routes/overview.md +++ b/docs/api-routes/overview.md @@ -1,3 +1,7 @@ +--- +title: "API Routes Overview" +--- + ```python exec import reflex as rx ``` diff --git a/docs/client_storage/overview.md b/docs/client_storage/overview.md index d57c7436c..1248570e2 100644 --- a/docs/client_storage/overview.md +++ b/docs/client_storage/overview.md @@ -1,3 +1,7 @@ +--- +title: "Client Storage Overview" +--- + ```python exec import reflex as rx ``` diff --git a/docs/custom-components/overview.md b/docs/custom-components/overview.md index d9d0376f1..476131b60 100644 --- a/docs/custom-components/overview.md +++ b/docs/custom-components/overview.md @@ -1,3 +1,7 @@ +--- +title: "Custom Components Overview" +--- + # Custom Components Overview ```python exec diff --git a/docs/database/overview.md b/docs/database/overview.md index 9abc9c4a8..222531fad 100644 --- a/docs/database/overview.md +++ b/docs/database/overview.md @@ -1,3 +1,7 @@ +--- +title: Database Overview +--- + # Database Reflex uses [sqlmodel](https://sqlmodel.tiangolo.com) to provide a built-in ORM wrapping SQLAlchemy. diff --git a/docs/library/graphing/general/tooltip.md b/docs/library/graphing/general/tooltip.md index 33025831c..d77529090 100644 --- a/docs/library/graphing/general/tooltip.md +++ b/docs/library/graphing/general/tooltip.md @@ -1,4 +1,5 @@ --- +title: "Graphing Tooltip" components: - rx.recharts.GraphingTooltip --- diff --git a/docs/library/other/html.md b/docs/library/other/html.md index 1e6a3116b..d2f5c3a1b 100644 --- a/docs/library/other/html.md +++ b/docs/library/other/html.md @@ -1,4 +1,5 @@ --- +title: "HTML Elements" components: - rx.el.A - rx.el.Abbr diff --git a/docs/recipes/content/grid.md b/docs/recipes/content/grid.md index e6ce357a6..923116460 100644 --- a/docs/recipes/content/grid.md +++ b/docs/recipes/content/grid.md @@ -1,3 +1,7 @@ +--- +title: "Grid Recipe" +--- + ```python exec import reflex as rx from pcweb.pages.docs import styling diff --git a/docs/state/overview.md b/docs/state/overview.md index a9397a3da..2cd096bfd 100644 --- a/docs/state/overview.md +++ b/docs/state/overview.md @@ -1,3 +1,8 @@ +--- +title: "State Overview" +--- + + ```python exec import reflex as rx from pcweb.templates.docpage import definition diff --git a/docs/styling/overview.md b/docs/styling/overview.md index 1530a5cde..2f51dadd4 100644 --- a/docs/styling/overview.md +++ b/docs/styling/overview.md @@ -1,3 +1,7 @@ +--- +title: "Styling Overview" +--- + ```python exec import reflex as rx from pcweb.pages.docs import styling, library diff --git a/docs/substates/overview.md b/docs/substates/overview.md index 6d7b515a4..69d81fefa 100644 --- a/docs/substates/overview.md +++ b/docs/substates/overview.md @@ -1,3 +1,7 @@ +--- +title: "Substates Overview" +--- + ```python exec import reflex as rx from typing import Any diff --git a/docs/ui/overview.md b/docs/ui/overview.md index acacf9cd1..dd0736a3d 100644 --- a/docs/ui/overview.md +++ b/docs/ui/overview.md @@ -1,3 +1,7 @@ +--- +title: "UI Overview" +--- + ```python exec from pcweb.pages.docs import components from pcweb.pages.docs.library import library diff --git a/docs/wrapping-react/overview.md b/docs/wrapping-react/overview.md index 5a9968cf4..f357d2e04 100644 --- a/docs/wrapping-react/overview.md +++ b/docs/wrapping-react/overview.md @@ -1,3 +1,7 @@ +--- +title: "Wrapping React Overview" +--- + ```python exec import reflex as rx from typing import Any diff --git a/pcweb/pages/docs/recipes_overview.py b/pcweb/pages/docs/recipes_overview.py index cbd5c0098..526cd5a72 100644 --- a/pcweb/pages/docs/recipes_overview.py +++ b/pcweb/pages/docs/recipes_overview.py @@ -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"), From 5ffca248e48dd6fad385bcd5120916246d6b1210 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Thu, 14 Nov 2024 22:32:24 +0100 Subject: [PATCH 2/2] improve skip compile check --- pcweb/pages/docs/__init__.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pcweb/pages/docs/__init__.py b/pcweb/pages/docs/__init__.py index 1f13fa4e8..fcc87b4c2 100644 --- a/pcweb/pages/docs/__init__.py +++ b/pcweb/pages/docs/__init__.py @@ -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. @@ -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): @@ -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 @@ -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 @@ -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) @@ -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():