diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml
new file mode 100644
index 0000000..ed0ea74
--- /dev/null
+++ b/.github/workflows/build-docs.yml
@@ -0,0 +1,39 @@
+name: build-docs
+on:
+ release:
+ types: [created]
+ push:
+ branches:
+ - '**'
+ tags:
+ - '**'
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Setup Pages
+ uses: actions/configure-pages@v5
+ - run: npm ci
+ - name: Build docs
+ run: npm run docs
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: ./docs/build
+
+ deploy:
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
+ permissions:
+ pages: write
+ id-token: write
+ 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
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 95e1e54..d3b03ee 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,19 +31,3 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'created'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- deploy:
- # https://github.com/actions/deploy-pages
- runs-on: ubuntu-latest
- permissions:
- pages: write
- id-token: write
- needs: build
- # Deploy to the github-pages environment
- environment:
- name: github-pages
- url: ${{ steps.deployment.outputs.page_url }}
- if: github.ref == 'refs/heads/main'
- steps:
- - name: Deploy to GitHub Pages
- id: deployment
- uses: actions/deploy-pages@v4
diff --git a/.gitignore b/.gitignore
index e571fed..4a30bf8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
+docs/build
# Editor directories and files
.vscode/*
diff --git a/LICENSE.md b/LICENSE.md
index 52209ef..0965380 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) YEAR AUTHOR
+Copyright (c) 2024-2025 Micro:bit Educational Foundation and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 84e5b6d..f402d5c 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,25 @@
-# React/JavaScript library for embedding Microsoft MakeCode as an iframe
+# MakeCode Embed
-This project is a work in progress.
+This documentation is best viewed on the documentation site rather than GitHub or NPM package site.
+
+This is a React/JavaScript library for embedding Microsoft MakeCode as an iframe.
It is intended to be used by other Micro:bit Educational Foundation projects
that need to embed MakeCode and, when the API stabilises, to be useful to others
who embed MakeCode.
-## Documentation
+- [StoryBook demo of the components](https://makecode-embed.pages.dev/)
+
+## Usage
-There isn't any documentation yet. You can find a StoryBook demo of the
-components at https://microbit-foundation.github.io/makecode-embed/
+- [React usage documentation](docs/react.md)
+- [VanillaJS usage documentation](docs/vanilla.md)
## License
This software is under the MIT open source license.
-[SPDX-License-Identifier: MIT](LICENSE)
+[SPDX-License-Identifier: MIT](LICENSE.md)
We use dependencies via the NPM registry as specified by the package.json file under common Open Source licenses.
diff --git a/docs/custom.css b/docs/custom.css
new file mode 100644
index 0000000..d327beb
--- /dev/null
+++ b/docs/custom.css
@@ -0,0 +1,4 @@
+/* Styling for hiding elements in the generated TypeDoc site. */
+a.typedoc-ignore {
+ display: none;
+}
\ No newline at end of file
diff --git a/docs/react.md b/docs/react.md
new file mode 100644
index 0000000..1705b11
--- /dev/null
+++ b/docs/react.md
@@ -0,0 +1,48 @@
+---
+title: React Usage
+---
+
+# React Usage
+
+This documentation is best viewed on the documentation site rather than GitHub or NPM package site.
+
+## Blocks rendering
+
+Use {@link react.MakeCodeRenderBlocksProvider | MakeCodeRenderBlocksProvider} and {@link react.MakeCodeBlocksRendering | MakeCodeBlocksRendering} React components to render MakeCode blocks for a MakeCode project. Example MakeCode projects used for the demo are defined in [fixtures.ts](../src/stories/fixtures.ts).
+
+```js
+import {
+ MakeCodeRenderBlocksProvider,
+ MakeCodeBlocksRendering,
+} from '@microbit/makecode-embed/react';
+
+
+
+;
+```
+
+The provider manages a hidden, embedded MakeCode. If you have more than one code embed then place the provider at a suitable location. You can use the `disabled` prop to avoid loading MakeCode if you know it's not needed.
+
+For more examples, take a look at the [MakeCode blocks rendering demo source code](../src/stories/react/MakeCodeBlocksRendering.stories.tsx).
+
+## Embed MakeCode editor
+
+Use {@link react.MakeCodeFrame | MakeCodeFrame} component to embed MakeCode.
+
+```js
+import { MakeCodeFrame } from '@microbit/makecode-embed/react';
+
+ console.log("MakeCode is now ready")},
+ onWorkspaceSave={(e) => {
+ // Set project as project changes in the editor.
+ setSavedProject(e.project);
+ }}
+/>;
+```
+
+For more examples, take a look at the [MakeCode frame demo source code](../src/stories/react/MakeCodeFrame.stories.tsx).
diff --git a/docs/vanilla.md b/docs/vanilla.md
new file mode 100644
index 0000000..ac759b4
--- /dev/null
+++ b/docs/vanilla.md
@@ -0,0 +1,69 @@
+---
+title: VanillaJS Usage
+---
+
+# VanillaJS Usage
+
+This documentation is best viewed on the documentation site rather than GitHub or NPM package site.
+
+## Blocks rendering
+
+Use {@link vanilla.createMakeCodeRenderBlocks | createMakeCodeRenderBlocks} to create a MakeCode block renderer. Initialise the renderer before calling `renderBlocks` with a {@link vanilla.RenderBlocksRequest | RenderBlocksRequest}, which includes a MakeCode project ([see examples](../src/stories/fixtures.ts)). The function will return a {@link vanilla.RenderBlocksResponse | RenderBlocksResponse}.
+
+```js
+import { createMakeCodeRenderBlocks } from "@microbit/makecode-embed/vanilla";
+
+const renderer = createMakeCodeRenderBlocks({});
+renderer.initialize();
+const result = await renderer.renderBlocks({ code: makeCodeProject });
+
+document.querySelector("#app")!.innerHTML = `
+