web/bugc-react: curated example selector for the docs BugPlayground#243
Merged
Conversation
The docs BugPlayground only ever showed one program; the example picker lived in the standalone packages/playground app. Port a lean version into the docs widget (gnidan #33). - bugc-react: add a curated `bugExamples` set (Counter, Function calls, Arrays & loops) as a reusable export. Sources are distilled from packages/bugc/examples and stripped of the `/*@test*/` behavioral annotations the raw files carry, so they read cleanly in an editor. examples.test.ts asserts each compiles to bytecode without errors (guards against a typo in an inlined source); adds the missing vitest.config.ts so the package's test script runs. - web BugPlayground: add an optional `examples` prop (defaults to bugExamples) and an Example dropdown in the header controls. The selector shows only when no `initialCode` is passed — so the bare playground page gains it while inline single-example doc embeds stay unchanged. Selecting an example loads its source and recompiles. Additive; does not affect the tracer or #227. Example sources verified to compile via the new tests; UI wiring mirrors the existing optimizer selector.
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports a lean program selector into the docs
BugPlaygroundwidget (gnidan feature #33). The docs widget only ever showed a single program; the example picker previously lived only in the standalonepackages/playgroundapp. Not a regression — the docs widget never had one. Targetstransform-context; additive, doesn't touch the tracer or #227.Changes
bugc-react (reusable, testable home):
bugExamplesexport — a curated trio: Counter, Function calls, Arrays & loops. Sources are distilled frompackages/bugc/examplesand stripped of the/*@test*/behavioral-annotation blocks the raw files carry, so they read cleanly in an editor.examples.test.tsasserts the set's shape and that each example compiles to bytecode without errors (guards against a typo in an inlined source).vitest.config.tsso the package's already-declaredtestscript runs (mirrors programs-react's).web BugPlayground:
examplesprop (defaults tobugExamples) + an Example dropdown in the header controls.initialCodeis passed — so the bare playground page (<BugPlayground/>) gains it, while inline single-example doc embeds stay unchanged.Design
Curated inline sources rather than a glob import: Docusaurus is webpack (the playground's
import.meta.globis Vite-only), and inlining keeps the widget self-contained and lets us curate clean, annotation-free sources. Decisions approved by team-lead/gnidan (third example = arrays/loops; home = bugc-react; visibility = no-initialCode).Verification
Placement on the #227 Explore page is being coordinated with docs; the bare embed auto-gains the selector with no MDX change.