Skip to main content

sphinx-pyxel

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_root is set, in which case apps are collected into one shared directory. Two apps with the same basename under pyxel_root would collide; give one a distinct :name: if that happens.

License

MIT

Metadata

Release files for sphinx-pyxel 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-pyxel 0.1.0
File Size Uploaded
sphinx_pyxel-0.1.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-pyxel 0.1.0
File Interpreter ABI Platform
sphinx_pyxel-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.7 kB

Release files / sphinx_pyxel-0.1.0.tar.gz

Download URL sphinx_pyxel-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea1d55c3d04cd9dec296852051723c6697c6e3865cd72ff6bc96b40dfa609a91
BLAKE2b-256 checksum
How to use checksums
8d85988a5749bbd56648d9c9b6af3084d1ab0e3f137f80d887e7248d9022d063
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.1.0-py3-none-any.whl

Download URL sphinx_pyxel-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2cb41949eee8ff7fa937e3c8a9138dc1e0d77e163485c0cc4945224b993165ff
BLAKE2b-256 checksum
How to use checksums
8430a2062216fdff632dfe7a554c1fd840097da9fbff833465af1e6170378c6f
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 history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page