Skip to content

Commit d39fac9

Browse files
committed
fix autosetters
1 parent 837690a commit d39fac9

5 files changed

Lines changed: 46 additions & 12 deletions

File tree

docs/app/reflex_docs/pages/docs/component.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
101101
name = get_id(f"{component.__qualname__}_{prop.name}")
102102
PropDocsState.add_var(name, bool, False)
103103
var = getattr(PropDocsState, name)
104+
PropDocsState._create_setter(name, var)
104105
setter = getattr(PropDocsState, f"set_{name}")
105106
prop_dict[prop.name] = var
106107
return rx.checkbox(
@@ -133,6 +134,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
133134
name = get_id(f"{component.__qualname__}_{prop.name}")
134135
PropDocsState.add_var(name, str, option)
135136
var = getattr(PropDocsState, name)
137+
PropDocsState._create_setter(name, var)
136138
setter = getattr(PropDocsState, f"set_{name}")
137139
prop_dict[prop.name] = var
138140
return rx.select.root(
@@ -154,6 +156,7 @@ def render_select(prop: PropDocumentation, component: type[Component], prop_dict
154156
name = get_id(f"{component.__qualname__}_{prop.name}")
155157
PropDocsState.add_var(name, str, option)
156158
var = getattr(PropDocsState, name)
159+
PropDocsState._create_setter(name, var)
157160
setter = getattr(PropDocsState, f"set_{name}")
158161
prop_dict[prop.name] = var
159162

docs/app/rxconfig.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import reflex as rx
22

33
config = rx.Config(
4-
state_auto_setters=True,
5-
port=3000,
64
app_name="reflex_docs",
75
deploy_url="https://reflex.dev",
86
frontend_packages=[
97
"tailwindcss-animated",
108
],
11-
show_build_with_reflex=True,
129
telemetry_enabled=False,
1310
plugins=[rx.plugins.TailwindV4Plugin(), rx.plugins.SitemapPlugin()],
1411
)

docs/app/tests/test_docgen_double_eval.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,34 @@ def test_double_eval_browser_javascript():
8383
vpath = "docs/api-reference/browser-javascript"
8484
render_docgen_document(vpath, filepath)
8585
render_docgen_document(vpath, filepath)
86+
87+
88+
# ---------------------------------------------------------------------------
89+
# Parametrized test: evaluate every markdown doc file twice
90+
# ---------------------------------------------------------------------------
91+
92+
_app_root = Path(__file__).resolve().parent.parent # …/app/
93+
_docs_dir = _app_root.parent # …/docs/ (parent of app/)
94+
95+
_all_docs: dict[str, str] = {} # virtual_path → actual_path
96+
for _md_file in sorted(_docs_dir.rglob("*.md")):
97+
if _md_file.is_relative_to(_app_root):
98+
continue
99+
_virtual = "docs/" + str(_md_file.relative_to(_docs_dir)).replace("\\", "/")
100+
_all_docs[_virtual] = str(_md_file)
101+
102+
103+
@pytest.fixture(params=list(_all_docs.keys()))
104+
def doc_file(request) -> tuple[str, str]:
105+
"""Yield (virtual_path, actual_path) for each discovered markdown doc."""
106+
virtual_path = request.param
107+
return virtual_path, _all_docs[virtual_path]
108+
109+
110+
def test_double_eval_all_docs(doc_file: tuple[str, str]):
111+
"""Every markdown doc must survive two evaluations without error."""
112+
from reflex_docs.docgen_pipeline import render_docgen_document
113+
114+
virtual_path, actual_path = doc_file
115+
render_docgen_document(virtual_path, actual_path)
116+
render_docgen_document(virtual_path, actual_path)

docs/library/graphing/general/axis.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,14 @@ class AxisState(rx.State):
120120

121121
label_offsets: list[str] = ["-30", "-20", "-10", "0", "10", "20", "30"]
122122

123-
x_axis_postion: str = "bottom"
123+
x_axis_position: str = "bottom"
124124

125125
x_axis_offset: int
126126

127-
y_axis_postion: str = "left"
127+
y_axis_position: str = "left"
128128

129129
y_axis_offset: int
130130

131-
@rx.event
132131
@rx.event
133132
def set_y_axis_position(self, position: str):
134133
self.y_axis_position = position
@@ -169,7 +168,7 @@ def axis_labels():
169168
data_key="name",
170169
label={
171170
"value": "Pages",
172-
"position": AxisState.x_axis_postion,
171+
"position": AxisState.x_axis_position,
173172
"offset": AxisState.x_axis_offset,
174173
},
175174
),
@@ -178,7 +177,7 @@ def axis_labels():
178177
label={
179178
"value": "Views",
180179
"angle": -90,
181-
"position": AxisState.y_axis_postion,
180+
"position": AxisState.y_axis_position,
182181
"offset": AxisState.y_axis_offset,
183182
},
184183
),
@@ -195,8 +194,8 @@ def axis_labels():
195194
rx.text("X Label Position: "),
196195
rx.select(
197196
AxisState.label_positions,
198-
value=AxisState.x_axis_postion,
199-
on_change=AxisState.set_x_axis_postion,
197+
value=AxisState.x_axis_position,
198+
on_change=AxisState.set_x_axis_position,
200199
),
201200
rx.text("X Label Offset: "),
202201
rx.select(
@@ -207,8 +206,8 @@ def axis_labels():
207206
rx.text("Y Label Position: "),
208207
rx.select(
209208
AxisState.label_positions,
210-
value=AxisState.y_axis_postion,
211-
on_change=AxisState.set_y_axis_postion,
209+
value=AxisState.y_axis_position,
210+
on_change=AxisState.set_y_axis_position,
212211
),
213212
rx.text("Y Label Offset: "),
214213
rx.select(

docs/state_structure/shared_state.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class CollaborativeCounter(rx.SharedState):
4444
linked_state = await self._link_to("shared-global-counter")
4545
linked_state.count += 1 # Increment count on link
4646

47+
@rx.event
48+
def set_count(self, count: int):
49+
self.count = count
50+
4751
@rx.var
4852
def is_linked(self) -> bool:
4953
return bool(self._linked_to)

0 commit comments

Comments
 (0)