-
Notifications
You must be signed in to change notification settings - Fork 9
Migrate tutorials #1871
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
Merged
Merged
Migrate tutorials #1871
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4a5e7de
vendoring https://github.com/commontoolsinc/tutorials/tree/main at b8…
jakedahn 0418f5c
feat: Add GitHub Actions workflow for MyST documentation deployment
jakedahn 13cffcf
chore: Enable GitHub Actions for migrate-tutorials branch and PRs
jakedahn 62dc383
Create CNAME
jakedahn 92c04ff
ignore tutorials
jakedahn 1d3b581
fix: Exclude tutorials directory from Deno formatting checks
jakedahn 3d6abf0
chore: Lock down docs deployment to main branch only
jakedahn 736791c
fixing github url
jakedahn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| name: Deploy MyST Documentation | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "tutorials/**" | ||
| - ".github/workflows/deploy-docs.yml" | ||
| workflow_dispatch: # Allow manual trigger | ||
|
|
||
| env: | ||
| # For custom domain docs.commontools.dev, we don't need a subfolder | ||
| BASE_URL: "" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| cache: "npm" | ||
| cache-dependency-path: tutorials/package-lock.json | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: tutorials | ||
| run: npm ci | ||
|
|
||
| - name: Build MyST site | ||
| working-directory: tutorials | ||
| run: npm run build | ||
|
|
||
| - name: Copy CNAME to build directory | ||
| run: cp tutorials/CNAME tutorials/_build/html/CNAME | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: "tutorials/_build/html" | ||
|
|
||
| deploy: | ||
| # Only deploy from main branch | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| docs.commontools.dev |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Node / tooling | ||
| node_modules/ | ||
| npm-debug.log* | ||
|
|
||
| # Myst build output | ||
| _build/ | ||
| .cache/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 18 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| docs.commontools.dev |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Tutorials | ||
|
|
||
| Install MyST Markdown tooling by following https://mystmd.org/guide/installing. Once set up, run `myst` in this directory to serve the tutorial pages locally. | ||
|
|
||
| ## npm quickstart | ||
|
|
||
| ```sh | ||
| npm i | ||
| npm run dev | ||
| ``` | ||
|
|
||
| TODO: | ||
| * Add document on how Input and Output schemas work for Recipes | ||
| * Chapter on basic UI and existing ct components |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Documentation Build Process | ||
|
|
||
| This directory contains the MyST documentation that gets built and deployed to https://docs.commontools.dev | ||
|
|
||
| ## Overview | ||
|
|
||
| While the main codebase uses Deno, the documentation is built using MyST (mystmd), which is a Node.js-based static site generator for scientific and technical documentation. | ||
|
|
||
| ## GitHub Actions Deployment | ||
|
|
||
| The documentation is automatically built and deployed via GitHub Actions when: | ||
| - Changes are pushed to the `main` branch | ||
| - The changes affect files in the `tutorials/` directory | ||
| - Or when manually triggered via workflow dispatch | ||
|
|
||
| The workflow is defined in `.github/workflows/deploy-docs.yml` | ||
|
|
||
| ## Local Development | ||
|
|
||
| To work on the documentation locally, you'll need Node.js (not Deno) for MyST: | ||
|
|
||
| ```bash | ||
| # Navigate to tutorials directory | ||
| cd tutorials | ||
|
|
||
| # Install dependencies (requires Node.js) | ||
| npm install | ||
|
|
||
| # Start development server | ||
| npm run dev | ||
|
|
||
| # Build static site | ||
| npm run build | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| - **MyST Config**: `myst.yml` - Defines the site structure and settings | ||
| - **Custom Domain**: The CNAME file configures the custom domain (docs.commontools.dev) | ||
| - **GitHub Pages**: The site is deployed to GitHub Pages with the custom domain | ||
|
|
||
| ## Important Notes | ||
|
|
||
| 1. The MyST build process is completely separate from the Deno-based application code | ||
| 2. The GitHub Action uses Node.js to build the documentation | ||
| 3. The built HTML is deployed to GitHub Pages | ||
| 4. Make sure to configure DNS records to point `docs.commontools.dev` to GitHub Pages | ||
|
|
||
| ## DNS Configuration Required | ||
|
|
||
| For the custom domain to work, you need to configure DNS: | ||
| - Add a CNAME record pointing `docs.commontools.dev` to `<username>.github.io` | ||
| - Or configure it according to GitHub's custom domain documentation |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /// <cts-enable /> | ||
| import { | ||
| cell, | ||
| h, | ||
| recipe, | ||
| UI, | ||
| lift, | ||
| derive, | ||
| handler, | ||
| type Cell, | ||
| } from "commontools"; | ||
|
|
||
| const calcAC = (dex: number) : number => | ||
| 20 + Math.floor((dex - 10) / 2); | ||
|
|
||
| const updateName = handler< | ||
| { detail: { message: string } }, | ||
| { characterName: Cell<string> } | ||
| >( | ||
| (event, { characterName }) => { | ||
| console.log("Updating character name to:", event.detail.message); | ||
| characterName.set(event.detail.message); | ||
| } | ||
| ); | ||
|
|
||
| export default recipe("state test", () => { | ||
| const characterName = cell<string>(""); | ||
| characterName.set("Lady Ellyxir"); | ||
| const dex = cell<number>(16); | ||
| const ac = lift(calcAC)(dex); | ||
|
|
||
| return { | ||
| [UI]: ( | ||
| <div> | ||
| <h2>Character name: {characterName}</h2> | ||
| <common-send-message | ||
| name="Update" | ||
| placeholder="Update Name" | ||
| onmessagesend={updateName({ characterName })} | ||
| /> | ||
| <li>DEX: {dex}</li> | ||
| <li>DEX Modifier: {Math.floor((dex - 10) / 2)}</li> | ||
| <li>AC: {ac}</li> | ||
| </div> | ||
| ), | ||
| }; | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /// <cts-enable /> | ||
| import { | ||
| cell, | ||
| h, | ||
| recipe, | ||
| UI, | ||
| lift, | ||
| derive, | ||
| handler, | ||
| type Cell, | ||
| } from "commontools"; | ||
|
|
||
| const calcAC = (dex: number) : number => | ||
| 20 + Math.floor((dex - 10) / 2); | ||
|
|
||
| const updateName = handler< | ||
| { detail: { message: string } }, | ||
| { characterName: Cell<string> } | ||
| >( | ||
| (event, { characterName }) => { | ||
| characterName.set(event.detail.message); | ||
| } | ||
| ); | ||
|
|
||
| const rollD6 = () => Math.floor(Math.random() * 6) + 1; | ||
|
|
||
| const rollDex = handler< | ||
| unknown, | ||
| Cell<number> | ||
| >( | ||
| (_, dex) => { | ||
| // Roll 3d6 for new DEX value | ||
| const roll = rollD6() + rollD6() + rollD6(); | ||
| dex.set(roll); | ||
| } | ||
| ); | ||
|
|
||
| export default recipe("state test", () => { | ||
| const characterName = cell<string>(""); | ||
| characterName.set("Lady Ellyxir"); | ||
| const dex = cell<number>(16); | ||
| const ac = lift(calcAC)(dex); | ||
|
|
||
| return { | ||
| [UI]: ( | ||
| <div> | ||
| <h2>Character name: {characterName}</h2> | ||
| <common-send-message | ||
| name="Update" | ||
| placeholder="Update Name" | ||
| onmessagesend={updateName({ characterName })} | ||
| /> | ||
| <li> | ||
| DEX: {dex} | ||
| {" "} | ||
| <ct-button onClick={rollDex(dex)}> | ||
| Roll | ||
| </ct-button> | ||
| </li> | ||
| <li>DEX Modifier: {Math.floor((dex - 10) / 2)}</li> | ||
| <li>AC: {ac}</li> | ||
| </div> | ||
| ), | ||
| }; | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Update the .nvmrc to a supported Node.js release (Node 18 went end-of-life on 2025-04-30), so local docs builds run on a maintained runtime.
Prompt for AI agents