Skip to content

Commit a37decf

Browse files
committed
Update project description and enhance demo route handling
1 parent a4bd291 commit a37decf

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

sdk/python/packages/flet-web/src/flet_web/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ def get_package_web_dir():
1313
return web_root_dir or str(Path(__file__).parent.joinpath("web"))
1414

1515

16-
__all__ = ["patch_font_manifest_json", "patch_index_html", "patch_manifest_json"]
16+
__all__ = [
17+
"patch_font_manifest_json",
18+
"patch_index_html",
19+
"patch_manifest_json",
20+
"get_package_web_dir",
21+
]

sdk/python/packages/flet/docs/apps/examples-gallery/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "examples-gallery"
33
version = "0.1.0"
4-
description = ""
4+
description = "Live demo of Flet examples."
55
readme = "README.md"
66
requires-python = ">=3.10"
77
authors = [

sdk/python/packages/flet/docs/extras/macros/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,33 @@ def iframe(
158158

159159
@env.macro
160160
def demo(
161-
route: str,
161+
route_or_path: str,
162162
*,
163163
width: str = "100%",
164164
height: str = "350",
165165
title: Optional[str] = None,
166166
):
167167
"""
168168
Embed an examples gallery route as a centered demo iframe.
169+
170+
`route_or_path` may be:
171+
- a gallery route, e.g. "slider/basic"
172+
- or a file path like "../../examples/controls/slider/basic.py"
169173
"""
174+
route = route_or_path
175+
176+
# Strip known prefixes
177+
for prefix in ("../../examples/controls/",):
178+
if route.startswith(prefix):
179+
route = route.removeprefix(prefix)
180+
break
181+
182+
# Strip known suffixes
183+
for suffix in (".py", "/"):
184+
if route.endswith(suffix):
185+
route = route.removesuffix(suffix)
186+
break
187+
170188
return render_iframe(
171189
route=route,
172190
base="/apps/examples-gallery/dist/index.html#/",

sdk/python/packages/flet/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ plugins:
163163
target_url_path: test-images
164164
include_exts: [".png", ".gif", ".svg"]
165165
- examples_gallery:
166-
src: apps/examples-gallery/src/main.py
166+
src: apps/examples-gallery/src
167167
dist: apps/examples-gallery/dist
168168
base_url: apps/examples-gallery/dist
169169

0 commit comments

Comments
 (0)