Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit b25e656

Browse files
committed
Merge branch 'main' of https://github.com/reflex-dev/reflex-web into carlos/replace-some-docs
2 parents 3bfff32 + 532e155 commit b25e656

14 files changed

Lines changed: 84 additions & 36 deletions

File tree

pcweb/docgen_pipeline.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class ReflexDocTransformer(DocumentTransformer[rx.Component]):
169169
the reflex package look identical to the locally-authored ones.
170170
"""
171171

172-
def __init__(self, filename: str = "") -> None:
172+
def __init__(self, virtual_filepath: str = "", filename: str = "") -> None:
173+
self.virtual_filepath = virtual_filepath
173174
self.filename = filename
174175
self.env: dict = {}
175176

@@ -234,7 +235,7 @@ def code_block(self, block: CodeBlock) -> rx.Component:
234235

235236
# ``python exec`` only — execute code, produce nothing visible.
236237
if language == "python" and "exec" in flags:
237-
_exec_code(block.content, self.env, self.filename)
238+
_exec_code(block.content, self.env, self.virtual_filepath)
238239
return rx.fragment()
239240

240241
# ``python eval`` (standalone) — eval and return the component directly.
@@ -378,10 +379,10 @@ def _render_demo(self, content: str, flags: set[str]) -> rx.Component:
378379

379380
try:
380381
if "exec" in flags:
381-
_exec_code(content, self.env, self.filename)
382+
_exec_code(content, self.env, self.virtual_filepath)
382383
comp = self.env[list(self.env.keys())[-1]]()
383384
elif "graphing" in flags:
384-
_exec_code(content, self.env, self.filename)
385+
_exec_code(content, self.env, self.virtual_filepath)
385386
comp = self.env[list(self.env.keys())[-1]]()
386387
parts = content.rpartition("def")
387388
data, code = parts[0], parts[1] + parts[2]
@@ -393,7 +394,7 @@ def _render_demo(self, content: str, flags: set[str]) -> rx.Component:
393394
comp = eval(content, self.env, self.env)
394395
except Exception as e:
395396
e.add_note(
396-
f"While rendering demo block in {self.filename}:\n{content[:200]}"
397+
f"While rendering demo block in {self.virtual_filepath}:\n{content[:200]}"
397398
)
398399
raise
399400

@@ -416,10 +417,10 @@ def _render_demo_only(self, content: str, flags: set[str]) -> rx.Component:
416417

417418
try:
418419
if "exec" in flags:
419-
_exec_code(content, self.env, self.filename)
420+
_exec_code(content, self.env, self.virtual_filepath)
420421
comp = self.env[list(self.env.keys())[-1]]()
421422
elif "graphing" in flags:
422-
_exec_code(content, self.env, self.filename)
423+
_exec_code(content, self.env, self.virtual_filepath)
423424
comp = self.env[list(self.env.keys())[-1]]()
424425
parts = content.rpartition("def")
425426
data, code = parts[0], parts[1] + parts[2]
@@ -430,7 +431,7 @@ def _render_demo_only(self, content: str, flags: set[str]) -> rx.Component:
430431
comp = eval(content, self.env, self.env)
431432
except Exception as e:
432433
e.add_note(
433-
f"While rendering demo-only block in {self.filename}:\n{content[:200]}"
434+
f"While rendering demo-only block in {self.virtual_filepath}:\n{content[:200]}"
434435
)
435436
raise
436437

@@ -681,10 +682,14 @@ def _parse_doc(filepath: str | Path) -> Document:
681682
return parse_document(source)
682683

683684

684-
def render_docgen_document(filepath: str | Path) -> rx.Component:
685+
def render_docgen_document(
686+
virtual_filepath: str | Path, actual_filepath: str | Path
687+
) -> rx.Component:
685688
"""Parse and render a doc file from the reflex package using reflex_docgen."""
686-
doc = _parse_doc(filepath)
687-
transformer = ReflexDocTransformer(filename=str(filepath))
689+
doc = _parse_doc(actual_filepath)
690+
transformer = ReflexDocTransformer(
691+
virtual_filepath=str(virtual_filepath), filename=str(actual_filepath)
692+
)
688693
return transformer.transform(doc)
689694

690695

pcweb/markdown_api.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Write per-doc raw Markdown files under ``.web/public`` for ``<route>.md`` URLs."""
2+
3+
from pathlib import Path
4+
5+
from reflex.constants import Dirs
6+
7+
from pcweb.pages.docs import doc_markdown_sources
8+
9+
PUBLIC_DIR = Path.cwd() / Dirs.WEB / Dirs.PUBLIC
10+
11+
12+
def generate_markdown_files() -> None:
13+
for route, source_path in doc_markdown_sources.items():
14+
resolved = Path(source_path)
15+
if not resolved.is_absolute():
16+
resolved = Path.cwd() / resolved
17+
if not resolved.is_file():
18+
continue
19+
20+
dest = PUBLIC_DIR / (route.strip("/") + ".md")
21+
dest.parent.mkdir(parents=True, exist_ok=True)
22+
dest.write_text(resolved.read_text(encoding="utf-8"), encoding="utf-8")

pcweb/pages/docs/__init__.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def get_components_from_metadata(current_doc):
132132
recipes_list = defaultdict(list)
133133
docs_ns = SimpleNamespace()
134134

135+
doc_markdown_sources: dict[str, str] = {}
136+
135137

136138
def exec_blocks(doc, href):
137139
"""Execute the exec and demo blocks in the document."""
@@ -273,15 +275,32 @@ def get_component_docgen(virtual_doc: str, actual_path: str, title: str):
273275
if virtual_doc.startswith("docs/library"):
274276
return handle_library_doc(virtual_doc, actual_path, title, resolved)
275277

276-
def comp(_actual=actual_path):
278+
def comp(_actual=actual_path, _virtual=virtual_doc):
277279
toc = get_docgen_toc(_actual)
278280
doc_content = Path(_actual).read_text(encoding="utf-8")
279-
rendered = render_docgen_document(_actual)
281+
rendered = render_docgen_document(
282+
virtual_filepath=_virtual, actual_filepath=_actual
283+
)
280284
return ((toc, doc_content), rendered)
281285

282286
return make_docpage(resolved.route, resolved.display_title, virtual_doc, comp)
283287

284288

289+
for fd in flexdown_docs:
290+
if fd.endswith("-style.md") or fd.endswith("-ll.md"):
291+
continue
292+
route = doc_route_from_path(fd)
293+
if not _check_whitelisted_path(route):
294+
continue
295+
doc_markdown_sources[route] = doc_path_mapping.get(fd, fd)
296+
for virtual_doc, actual_path in docgen_docs.items():
297+
if virtual_doc.endswith("-style.md") or virtual_doc.endswith("-ll.md"):
298+
continue
299+
route = doc_route_from_path(virtual_doc)
300+
if not _check_whitelisted_path(route):
301+
continue
302+
doc_markdown_sources[route] = actual_path
303+
285304
doc_routes = [
286305
library,
287306
custom_components,

pcweb/pages/use_cases/common/features_1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ def feature_card(
1212
rx.el.span(title, class_name="font-semibold text-slate-12 text-lg mt-2"),
1313
rx.el.p(
1414
description,
15-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium",
15+
class_name="text-secondary-11 text-sm font-medium",
1616
)
1717
if description
1818
else None,
1919
rx.el.ul(
2020
*[
2121
rx.el.li(
2222
item,
23-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium mt-1",
23+
class_name="text-secondary-11 text-sm font-medium mt-1",
2424
)
2525
for item in items
2626
],
27-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium list-disc list-inside",
27+
class_name="text-secondary-11 text-sm font-medium list-disc list-inside",
2828
)
2929
if items
3030
else None,

pcweb/pages/use_cases/common/features_2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ def feature_card(
2121
rx.el.span(title, class_name="font-semibold text-slate-12 text-lg mt-4"),
2222
rx.el.p(
2323
description,
24-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium mt-2",
24+
class_name="text-secondary-11 text-sm font-medium mt-2",
2525
),
2626
rx.el.ul(
2727
*[
2828
rx.el.li(
2929
item,
30-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium mt-1",
30+
class_name="text-secondary-11 text-sm font-medium mt-1",
3131
)
3232
for item in items
3333
],
34-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium list-disc list-inside mt-2",
34+
class_name="text-secondary-11 text-sm font-medium list-disc list-inside mt-2",
3535
)
3636
if items
3737
else None,

pcweb/pages/use_cases/common/final_section.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def right_content(h1: str, description: str) -> rx.Component:
1414
),
1515
rx.el.p(
1616
description,
17-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium mt-2",
17+
class_name="text-secondary-11 text-sm font-medium mt-2",
1818
),
1919
ui.link(
2020
render_=ui.button(
2121
"Go to the builder",
2222
size="lg",
2323
variant="outline",
24-
class_name="w-fit font-semibold lg:mt-auto mt-8 text-m-slate-11 dark:text-m-slate-9 border-m-slate-5 dark:border-m-slate-12",
24+
class_name="w-fit font-semibold lg:mt-auto mt-8 text-secondary-11 border-m-slate-5 dark:border-m-slate-12",
2525
),
2626
to=REFLEX_BUILD_URL,
2727
target="_blank",
@@ -39,7 +39,7 @@ def left_content(h1: str, description: str) -> rx.Component:
3939
),
4040
rx.el.p(
4141
description,
42-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium",
42+
class_name="text-secondary-11 text-sm font-medium",
4343
),
4444
demo_form_dialog(
4545
trigger=ui.button(

pcweb/pages/use_cases/common/quote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ def quote_card(
1616
),
1717
rx.el.p(
1818
description,
19-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium",
19+
class_name="text-secondary-11 text-sm font-medium",
2020
),
2121
class_name="flex flex-col gap-6 border-b border-m-slate-4 dark:border-m-slate-12 p-10",
2222
),
2323
rx.el.div(
2424
rx.el.p(quote, class_name="text-slate-12 text-lg font-semibold"),
2525
rx.el.p(
2626
name,
27-
class_name="text-m-slate-11 dark:text-m-slate-9 text-base font-medium",
27+
class_name="text-secondary-11 text-base font-medium",
2828
),
2929
class_name="flex flex-col gap-2 p-10",
3030
),

pcweb/pages/use_cases/common/social_proof.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def first_card(title: str) -> rx.Component:
88
return rx.el.div(
99
ui.icon(
1010
"CheckmarkBadge02Icon",
11-
class_name="text-m-slate-11 dark:text-m-slate-9 shrink-0",
11+
class_name="text-secondary-11 shrink-0",
1212
),
1313
rx.el.span(
1414
title,
15-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium text-wrap",
15+
class_name="text-secondary-11 text-sm font-medium text-wrap",
1616
),
1717
class_name="flex flex-row gap-2.5 items-center max-lg:justify-center lg:col-span-2 px-10 h-full max-lg:h-[10.75rem] max-lg:w-full lg:border-r border-b w-full",
1818
)

pcweb/pages/use_cases/common/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def stat_card(
1919
),
2020
rx.el.p(
2121
description,
22-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium",
22+
class_name="text-secondary-11 text-sm font-medium",
2323
),
2424
class_name="flex flex-col items-start p-10 gap-2 border-slate-3 lg:border-b lg:border-r",
2525
)

pcweb/pages/use_cases/consulting/views/social_proof.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def first_card(title: str) -> rx.Component:
1919
return rx.el.div(
2020
ui.icon(
2121
"CheckmarkBadge02Icon",
22-
class_name="text-m-slate-11 dark:text-m-slate-9 shrink-0",
22+
class_name="text-secondary-11 shrink-0",
2323
),
2424
rx.el.span(
2525
title,
26-
class_name="text-m-slate-11 dark:text-m-slate-9 text-sm font-medium text-wrap",
26+
class_name="text-secondary-11 text-sm font-medium text-wrap",
2727
),
2828
class_name="flex flex-row gap-2.5 items-center max-lg:justify-center lg:col-span-2 px-10 h-full max-lg:h-[10.75rem] max-lg:w-full w-full lg:border-r",
2929
)

0 commit comments

Comments
 (0)