How to build the API docs for any Phaser 3 or 4 release

If you don’t have a copy, download the source code of the Phaser release you want, e.g., https://github.com/phaserjs/phaser/archive/refs/tags/v4.2.1.zip and unzip.

In the terminal, run

cd path/to/phaser # the folder you just unzipped

npx typedoc ./types/*.d.ts --out docs --includeVersion --skipErrorChecking

open docs/index.html

There will be some warnings but it should finish.

Now you can browse the API docs offline. :smiling_face_with_sunglasses:


Alternative: download with git

This is a lot faster because it only downloads the type declarations.

TAG_VERSION="v4.2.1"

git clone --no-checkout --depth 1 --branch $TAG_VERSION https://github.com/phaserjs/phaser.git phaser

cd phaser

git sparse-checkout init --cone
git sparse-checkout set types
git checkout tags/$TAG_VERSION

Then continue with npx typedoc as above.

4 Likes

This approach is helpful when experimenting with newer Phaser releases. Being able to generate docs for any tag or RC version gives a chance to review API changes before they’re documented on the official site.