Skip to content

Commit 9f304b7

Browse files
committed
rework docs extension + misc changes
1 parent af3bf90 commit 9f304b7

20 files changed

+396
-544
lines changed

docs/source/_custom_js/package-lock.json

Lines changed: 15 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/_custom_js/src/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { mountWithLayoutServer, LayoutServerInfo } from "@reactpy/client";
1+
import { SimpleReactPyClient, mount } from "@reactpy/client";
22

33
let didMountDebug = false;
44

55
export function mountWidgetExample(
66
mountID,
77
viewID,
88
reactpyServerHost,
9-
useActivateButton
9+
useActivateButton,
1010
) {
1111
let reactpyHost, reactpyPort;
1212
if (reactpyServerHost) {
@@ -16,27 +16,27 @@ export function mountWidgetExample(
1616
reactpyPort = window.location.port;
1717
}
1818

19-
const serverInfo = new LayoutServerInfo({
20-
host: reactpyHost,
21-
port: reactpyPort,
22-
path: "/_reactpy/",
23-
query: `view_id=${viewID}`,
24-
secure: window.location.protocol == "https:",
19+
const client = new SimpleReactPyClient({
20+
serverLocation: {
21+
url: `${window.location.protocol}//${reactpyHost}:${reactpyPort}`,
22+
route: "/",
23+
query: `?view_id=${viewID}`,
24+
},
2525
});
2626

2727
const mountEl = document.getElementById(mountID);
2828
let isMounted = false;
2929
triggerIfInViewport(mountEl, () => {
3030
if (!isMounted) {
31-
activateView(mountEl, serverInfo, useActivateButton);
31+
activateView(mountEl, client, useActivateButton);
3232
isMounted = true;
3333
}
3434
});
3535
}
3636

37-
function activateView(mountEl, serverInfo, useActivateButton) {
37+
function activateView(mountEl, client, useActivateButton) {
3838
if (!useActivateButton) {
39-
mountWithLayoutServer(mountEl, serverInfo);
39+
mount(mountEl, client);
4040
return;
4141
}
4242

@@ -51,7 +51,7 @@ function activateView(mountEl, serverInfo, useActivateButton) {
5151
mountEl.setAttribute("class", "interactive widget-container");
5252
mountWithLayoutServer(mountEl, serverInfo);
5353
}
54-
})
54+
}),
5555
);
5656

5757
function fadeOutElementThenCallback(element, callback) {
@@ -87,7 +87,7 @@ function triggerIfInViewport(element, callback) {
8787
{
8888
root: null,
8989
threshold: 0.1, // set offset 0.1 means trigger if atleast 10% of element in viewport
90-
}
90+
},
9191
);
9292

9393
observer.observe(element);

noxfile.py

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def __call__(self, session: Session) -> Callable[[bool], None]:
3535
SRC_DIR = ROOT_DIR / "src"
3636
CLIENT_DIR = SRC_DIR / "client"
3737
REACTPY_DIR = SRC_DIR / "reactpy"
38-
LANGUAGE_TYPES: list[LanguageName] = ["py", "js"]
3938
TAG_PATTERN = re.compile(
4039
# start
4140
r"^"
@@ -46,7 +45,6 @@ def __call__(self, session: Session) -> Callable[[bool], None]:
4645
# end
4746
r"$"
4847
)
49-
print(TAG_PATTERN.pattern)
5048
REMAINING_ARGS = Option(nargs=REMAINDER, type=str)
5149

5250

@@ -89,6 +87,12 @@ def format(session: Session) -> None:
8987
session.run("npm", "run", "format", external=True)
9088

9189

90+
@group.session
91+
def tsc(session: Session) -> None:
92+
session.chdir(CLIENT_DIR)
93+
session.run("npx", "tsc", "-b", "-w", "packages/app", external=True)
94+
95+
9296
@group.session
9397
def example(session: Session) -> None:
9498
"""Run an example"""
@@ -269,16 +273,38 @@ def build_python(session: Session) -> None:
269273

270274

271275
@group.session
272-
def publish(session: Session, dry_run: bool = False) -> None:
276+
def publish(
277+
session: Session,
278+
publish_dry_run: Annotated[
279+
bool,
280+
Option(help="whether to test the release process"),
281+
] = False,
282+
publish_fake_tags: Annotated[
283+
Sequence[str],
284+
Option(nargs="*", type=str, help="fake tags to use for a dry run release"),
285+
] = (),
286+
) -> None:
273287
packages = get_packages(session)
274288

275289
release_prep: dict[LanguageName, ReleasePrepFunc] = {
276290
"js": prepare_javascript_release,
277291
"py": prepare_python_release,
278292
}
279293

294+
if publish_fake_tags and not publish_dry_run:
295+
session.error("Cannot specify --publish-fake-tags without --publish-dry-run")
296+
297+
parsed_tags: list[TagInfo] = []
298+
for tag in publish_fake_tags or get_current_tags(session):
299+
tag_info = parse_tag(tag)
300+
if tag_info is None:
301+
session.error(
302+
f"Invalid tag {tag} - must be of the form <package>-<language>-<version>"
303+
)
304+
parsed_tags.append(tag_info)
305+
280306
publishers: list[tuple[Path, Callable[[bool], None]]] = []
281-
for tag, tag_pkg, tag_ver in get_current_tags(session):
307+
for tag, tag_pkg, tag_ver in parsed_tags:
282308
if tag_pkg not in packages:
283309
session.error(f"Tag {tag} references package {tag_pkg} that does not exist")
284310

@@ -296,7 +322,7 @@ def publish(session: Session, dry_run: bool = False) -> None:
296322
for pkg_path, publish in publishers:
297323
session.log(f"Publishing {pkg_path}...")
298324
session.chdir(pkg_path)
299-
publish(dry_run)
325+
publish(publish_dry_run)
300326

301327

302328
# --- Utilities ------------------------------------------------------------------------
@@ -420,7 +446,7 @@ class PackageInfo(NamedTuple):
420446
version: str
421447

422448

423-
def get_current_tags(session: Session) -> list[TagInfo]:
449+
def get_current_tags(session: Session) -> list[str]:
424450
"""Get tags for the current commit"""
425451
# check if unstaged changes
426452
try:
@@ -468,24 +494,20 @@ def get_current_tags(session: Session) -> list[TagInfo]:
468494
if not tags:
469495
session.error("No tags found for current commit")
470496

471-
parsed_tags: list[TagInfo] = []
472-
for tag in tags:
473-
match = TAG_PATTERN.match(tag)
474-
if not match:
475-
session.error(
476-
f"Invalid tag {tag} - must be of the form <package>-<language>-<version>"
477-
)
478-
parsed_tags.append(
479-
TagInfo(
480-
tag,
481-
match["name"], # type: ignore[index]
482-
match["version"], # type: ignore[index]
483-
)
484-
)
497+
session.log(f"Found tags: {tags}")
485498

486-
session.log(f"Found tags: {[info.tag for info in parsed_tags]}")
499+
return tags
487500

488-
return parsed_tags
501+
502+
def parse_tag(tag: str) -> TagInfo | None:
503+
match = TAG_PATTERN.match(tag)
504+
if not match:
505+
return None
506+
return TagInfo(
507+
tag,
508+
match["name"], # type: ignore[index]
509+
match["version"], # type: ignore[index]
510+
)
489511

490512

491513
class TagInfo(NamedTuple):

src/client/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
tsconfig.tsbuildinfo
2+
packages/**/package-lock.json

0 commit comments

Comments
 (0)