-
-
Notifications
You must be signed in to change notification settings - Fork 45
docs: Common code between examples #1995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a common folder for shared code between documentation examples to reduce duplication. The primary change involves moving the setup-orbit-camera.ts utility from individual example directories to a centralized common location.
- Establishes infrastructure to handle common files across examples with proper type definitions
- Refactors
setup-orbit-camera.tsto be a shared utility with enhanced touch gesture support (pinch-to-zoom) - Updates build tooling to automatically include relevant common files in StackBlitz exports and code editor views
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/typegpu-docs/src/utils/examples/types.ts | Adds ExampleCommonFile type to distinguish common files from example-specific files |
| apps/typegpu-docs/src/examples/simulation/gravity/setup-orbit-camera.ts | Removes local copy of orbit camera utility (moved to common folder) |
| apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts | Updates import path to reference common folder |
| apps/typegpu-docs/src/examples/simulation/gravity/index.ts | Updates import path to reference common folder |
| apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts | Updates import path and removes export keywords from shader functions |
| apps/typegpu-docs/src/examples/exampleContent.ts | Adds common file loading logic with glob patterns and path extraction |
| apps/typegpu-docs/src/examples/common/setup-orbit-camera.ts | New centralized orbit camera utility with enhanced pinch-to-zoom support |
| apps/typegpu-docs/src/components/stackblitz/openInStackBlitz.ts | Updates to include common files in StackBlitz projects with proper path rewriting |
| apps/typegpu-docs/src/components/ExampleView.tsx | Adds filtering logic to include only relevant common files per example |
| apps/typegpu-docs/src/components/ExamplePage.tsx | Passes common files to ExampleView component |
| apps/typegpu-docs/src/components/CodeEditor.tsx | Updates path handling to support both example and common file paths |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
| ]; | ||
|
|
||
| for (const common of commonFiles) { | ||
| for (const src of srcFiles) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this change allow common file to reference each other, and show up in the tabs?
| for (const src of srcFiles) { | |
| for (const src of [...srcFiles, ...commonFiles]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Or, I guess, it would, but with a side effect. If common1.ts references common2.ts, then common2.ts would be included in every example, regardless of whether the example uses common1.ts or not. We would need to do a BFS or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Could you create an issue for this so we can do it in another PR?
Changes:
commonfolder to examples,commonfiles when opening in StackBlitz,commonfiles in our examples,setup-orbit-camera.tsto be common (only where it was already used).