A Sphinx extension that embeds Pyxel apps directly in your HTML documentation using the official Pyxel web runtime.
Install
pip install sphinx-pyxel
Or from source:
pip install .
Usage
Add the extension to your conf.py:
extensions = ["sphinx_pyxel"]
Then use the pyxel directive in any reStructuredText document:
.. pyxel:: examples/01_hello_pyxel.py
For a packaged app (.pyxapp) with gamepad support:
.. pyxel:: examples/30sec_of_daylight.pyxapp
:mode: play
:gamepad: enabled
If your app loads external resources, copy them next to it:
.. pyxel:: my_game.py
:assets: my_game.pyxres, my_game_bank.json
Options
| Option | Default | Description |
|---|---|---|
mode |
run for .py, play for .pyxapp |
run (just runs) or play (player controls, gamepad support). |
root |
. (or rel path to pyxel_root) |
Root path served relative to the HTML page. |
name |
basename of the argument | File name served by the runtime. |
gamepad |
unset | enabled or disabled (only meaningful for play). |
assets |
unset | Comma-separated extra files to copy next to the app. |
script |
jsdelivr wasm build | URL of the Pyxel web runtime script. |
height |
480px |
CSS height of the inline app window. |
How it works
During the build, the directive copies the referenced app file (and any
assets) into the output directory next to the generated HTML page, then emits
a <pyxel-run> (or <pyxel-play>) custom element plus the Pyxel web runtime
script tag. The app runs entirely in the browser — no Python is executed by
Sphinx.
The app renders inline at the location of the directive (not fullscreen):
the extension places a #pyxel-screen container there and overrides the
runtime's fullscreen CSS so the canvas fills that container. Set :height:
to control the window size.
Config value: pyxel_root
Set pyxel_root in conf.py to collect every app into one shared
directory under the HTML output instead of copying it next to each page that
references it. Each emitted root then points from the page back at the
shared directory, so an app reused across many pages is stored once.
pyxel_root = "_pyxel"
Limitations
- The embedded app only renders in the HTML builder. Other builders (LaTeX, man, text, etc.) emit a short note instead. This is expected: the Pyxel web runtime is JavaScript and only runs in a browser.
- One file is copied next to each page that references it unless
pyxel_rootis set, in which case apps are collected into one shared directory. Two apps with the same basename underpyxel_rootwould collide; give one a distinct:name:if that happens.
License
MIT
Metadata
Release files for sphinx-pyxel 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sphinx_pyxel-0.2.0.tar.gz | 424.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sphinx_pyxel-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 851.8 kB
Release files / sphinx_pyxel-0.2.0.tar.gz
| Download URL | sphinx_pyxel-0.2.0.tar.gz |
|---|---|
| Size | 424.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e8f0ed6d1cf7e9d8b833e903af95de691e58587a0e94f076b4f3f148993a51c
|
|
BLAKE2b-256 checksum How to use checksums |
c962b7fb3a6f8dfa2e1bf8ecf0d9da6983c8514897b407e0b81beeb6ac76ff4a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sphinx_pyxel-0.2.0-py3-none-any.whl
| Download URL | sphinx_pyxel-0.2.0-py3-none-any.whl |
|---|---|
| Size | 427.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
686e5d57641b861ec3132ecb130b0f416576425758fda1354b634d23b6a1d275
|
|
BLAKE2b-256 checksum How to use checksums |
87903bf306545b6e2262a5804cb82f8fba67156e4d21e1261c52e2fd3bdfb7d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|