Skip to content

Commit b60a14a

Browse files
authored
add functools wraps to content for docpage (#1294)
* add functools wraps to content for docpage * fix lots of wrong routes
1 parent a7f234d commit b60a14a

File tree

9 files changed

+23
-276
lines changed

9 files changed

+23
-276
lines changed

docs/components/conditional_props.md

Whitespace-only changes.

docs/tutorial/frontend.md

Lines changed: 0 additions & 267 deletions
This file was deleted.

pcweb/pages/docs/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from collections import defaultdict
3+
from pathlib import Path
34
from types import SimpleNamespace
45

56
import reflex as rx
@@ -14,8 +15,6 @@
1415
from pcweb.route import Route
1516
from pcweb.templates.docpage import docpage, get_toc
1617
from pcweb.whitelist import _check_whitelisted_path
17-
from reflex.components.radix.primitives.base import RadixPrimitiveComponent
18-
from reflex.components.radix.themes.base import RadixThemesComponent
1918

2019
from .library import library
2120
from .recipes_overview import overview
@@ -177,9 +176,18 @@ def get_component(doc: str, title: str):
177176
outblocks.append((d, route))
178177
return
179178

180-
return docpage(set_path=route, t=title2)(
181-
lambda d=d, doc=doc: (get_toc(d, doc), xd.render(d, doc))
182-
)
179+
def comp():
180+
return (get_toc(d, doc), xd.render(d, doc))
181+
182+
doc_path = Path(doc)
183+
doc_module = ".".join(doc_path.parts[:-1])
184+
doc_file = doc_path.stem
185+
186+
comp.__module__ = doc_module
187+
comp.__name__ = doc_file
188+
comp.__qualname__ = doc_file
189+
190+
return docpage(set_path=route, t=title2)(comp)
183191

184192

185193
doc_routes = (

pcweb/pages/docs/cloud_cliref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ def generate_docs(source: str):
145145
for module_name, module_value in modules.items():
146146
docs = generate_docs(module_value)
147147
title = module_name.replace("_", " ").title()
148-
page_data = docpage(f"/docs/hosting/{module_name}/", title)(docs)
148+
page_data = docpage(f"/docs/hosting/cli/{module_name}/", title)(docs)
149149
page_data.title = page_data.title.split("·")[0].strip()
150150
pages.append(page_data)

pcweb/pcweb.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
redirects = [
8787
("/docs", "/docs/getting-started/introduction"),
8888
("/docs/getting-started", "/docs/getting-started/introduction"),
89-
("/docs/components", "/docs/components/overview"),
9089
("/docs/state", "/docs/state/overview"),
9190
("/docs/styling", "/docs/styling/overview"),
9291
("/docs/database", "/docs/database/overview"),
@@ -97,7 +96,6 @@
9796
("/docs/library/layout/foreach", "/docs/library/dynamic-rendering/foreach"),
9897
("/docs/library/layout/match", "/docs/library/dynamic-rendering/match"),
9998
("/docs/library/layout/cond", "/docs/library/dynamic-rendering/cond"),
100-
("/docs/tutorial", "/docs/tutorial/intro"),
10199
("/docs/components", "/docs/components/props"),
102100
("/docs/pages", "/docs/pages/routes"),
103101
("/docs/assets", "/docs/assets/referencing-assets"),
@@ -112,6 +110,7 @@
112110
("/docs/utility-methods", "/docs/utility-methods/router-attributes"),
113111
("/docs/datatable-tutorial", "/docs/datatable-tutorial/simple-table"),
114112
("/docs/library/graphing", "/docs/library/graphing/charts"),
113+
("/docs/tutorial", "/docs/getting-started/chatapp-tutorial"),
115114
("/docs/tutorial/intro", "/docs/getting-started/chatapp-tutorial"),
116115
("/docs/tutorial/setup", "/docs/getting-started/chatapp-tutorial"),
117116
("/docs/tutorial/frontend", "/docs/getting-started/chatapp-tutorial"),
@@ -124,7 +123,6 @@
124123
),
125124
# Recipes
126125
("/docs/recipes/auth", "/docs/recipes"),
127-
("/docs/recipes/auth", "/docs/recipes"),
128126
("/docs/recipes/layout", "/docs/recipes"),
129127
("/docs/recipes/others", "/docs/recipes"),
130128
("/docs/recipes/content", "/docs/recipes"),

pcweb/templates/docpage/docpage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Template for documentation pages."""
22

33
from datetime import datetime
4+
import functools
45
from typing import Callable
56

67
import reflex as rx
@@ -407,6 +408,7 @@ def docpage(contents: Callable[[], Route]) -> Route:
407408
# Set the page title.
408409
title = contents.__name__.replace("_", " ").title() if t is None else t
409410

411+
@functools.wraps(contents)
410412
def wrapper(*args, **kwargs) -> rx.Component:
411413
"""The actual function wrapper.
412414

pcweb/templates/gallery_app_page.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
from typing import Callable
23
import reflex as rx
34
from pcweb.route import Route
@@ -39,6 +40,7 @@ def webpage(contents: Callable[[], Route]) -> Route:
3940
The templated route.
4041
"""
4142

43+
@functools.wraps(contents)
4244
def wrapper(*children, **props) -> rx.Component:
4345
"""The template component.
4446

pcweb/templates/storypage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
from typing import Callable
23

34
import reflex as rx
@@ -232,6 +233,7 @@ def webpage(contents: Callable[[], Route]) -> Route:
232233
The templated route.
233234
"""
234235

236+
@functools.wraps(contents)
235237
def wrapper(*children, **props) -> rx.Component:
236238
"""The template component.
237239

0 commit comments

Comments
 (0)