From 430a8cc7f2274edac86aa8094f6e2aad70915624 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 18 Nov 2024 13:16:22 +0100 Subject: [PATCH] Add simple gallery --- .gitignore | 2 ++ docs/Makefile | 4 ++++ docs/conf.py | 29 ++++++++++++++++++++++++++++- docs/index.rst | 1 + docs/static/custom.css | 4 ++++ examples/README.rst | 2 ++ examples/cube_auto.py | 3 +++ examples/cube_glfw.py | 3 +++ examples/cube_offscreen.py | 3 +++ examples/cube_qt.py | 3 +++ examples/cube_wx.py | 3 +++ examples/demo.py | 3 +++ examples/events.py | 3 +++ examples/multiple.py | 3 +++ examples/noise.py | 3 +++ examples/offsceen_threaded.py | 3 +++ examples/qt_app.py | 3 +++ examples/qt_app_asyncio.py | 3 +++ examples/snake.py | 3 +++ examples/wx_app.py | 3 +++ 20 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 docs/static/custom.css create mode 100644 examples/README.rst diff --git a/.gitignore b/.gitignore index 5ddeb4b..0a1b8af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # Special for this repo nogit/ +docs/gallery/ +docs/sg_execution_times.rst # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/docs/Makefile b/docs/Makefile index d4bb2cb..8d16328 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -12,6 +12,10 @@ BUILDDIR = _build help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +clean : + -rm -r _build + -rm -r gallery + .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new diff --git a/docs/conf.py b/docs/conf.py index af8b8b9..46eec3e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,6 +44,7 @@ "sphinx.ext.napoleon", "sphinx.ext.intersphinx", "sphinx_rtd_theme", + "sphinx_gallery.gen_gallery", ] intersphinx_mapping = { @@ -63,6 +64,31 @@ master_doc = "index" +# -- Sphinx Gallery ----------------------------------------------------- + +# Suppress "cannot cache unpickable configuration value" for sphinx_gallery_conf +# See https://github.com/sphinx-doc/sphinx/issues/12300 +suppress_warnings = ["config.cache"] + +# The gallery conf. See https://sphinx-gallery.github.io/stable/configuration.html +sphinx_gallery_conf = { + "gallery_dirs": "gallery", + "backreferences_dir": "gallery/backreferences", + "doc_module": ("rendercanvas",), + # "image_scrapers": (),, + "remove_config_comments": True, + # Define order of appearance of the examples + # "subsection_order": ExplicitOrder( + # [ + # "../examples/introductory", + # "../examples/feature_demo", + # "../examples/validation", + # "../examples/other", + # ] + # ), + "examples_dirs": "../examples/", +} + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -73,4 +99,5 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [] +html_static_path = ["static"] +html_css_files = ["custom.css"] diff --git a/docs/index.rst b/docs/index.rst index a52c973..6666764 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,6 +11,7 @@ Welcome to the rendercanvas docs! api backends utils + Gallery advanced diff --git a/docs/static/custom.css b/docs/static/custom.css new file mode 100644 index 0000000..0fd546b --- /dev/null +++ b/docs/static/custom.css @@ -0,0 +1,4 @@ +div.sphx-glr-download, +div.sphx-glr-download-link-note { + display: none; +} \ No newline at end of file diff --git a/examples/README.rst b/examples/README.rst new file mode 100644 index 0000000..9f38ea6 --- /dev/null +++ b/examples/README.rst @@ -0,0 +1,2 @@ +RenderCanvas examples +===================== \ No newline at end of file diff --git a/examples/cube_auto.py b/examples/cube_auto.py index 2fe56e1..0738fa2 100644 --- a/examples/cube_auto.py +++ b/examples/cube_auto.py @@ -1,4 +1,7 @@ """ +Cube auto +--------- + Run a wgpu example on an automatically selected backend. """ diff --git a/examples/cube_glfw.py b/examples/cube_glfw.py index b817d6c..878602e 100644 --- a/examples/cube_glfw.py +++ b/examples/cube_glfw.py @@ -1,4 +1,7 @@ """ +Cube glfw +--------- + Run a wgpu example on the glfw backend. """ diff --git a/examples/cube_offscreen.py b/examples/cube_offscreen.py index 73ed849..7d0bfa8 100644 --- a/examples/cube_offscreen.py +++ b/examples/cube_offscreen.py @@ -1,4 +1,7 @@ """ +Cube offscreen +-------------- + Render a wgpu example offscreen, and display as an image. """ diff --git a/examples/cube_qt.py b/examples/cube_qt.py index a781317..faf7080 100644 --- a/examples/cube_qt.py +++ b/examples/cube_qt.py @@ -1,4 +1,7 @@ """ +Cube qt +------- + Run a wgpu example on the Qt backend. Works with either PySide6, PyQt6, PyQt5 or PySide2. diff --git a/examples/cube_wx.py b/examples/cube_wx.py index 75768f0..b07784f 100644 --- a/examples/cube_wx.py +++ b/examples/cube_wx.py @@ -1,4 +1,7 @@ """ +Cube wx +------- + Run a wgpu example on the wx backend. """ diff --git a/examples/demo.py b/examples/demo.py index 04f1d0c..da8c890 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -1,4 +1,7 @@ """ +Demo +---- + An example that uses events to trigger some canvas functionality. A nice demo, and very convenient to test the different backends. diff --git a/examples/events.py b/examples/events.py index 8161385..27edf56 100644 --- a/examples/events.py +++ b/examples/events.py @@ -1,4 +1,7 @@ """ +Events +------ + A simple example to demonstrate events. """ diff --git a/examples/multiple.py b/examples/multiple.py index c4f73a9..8d1ea3e 100644 --- a/examples/multiple.py +++ b/examples/multiple.py @@ -1,4 +1,7 @@ """ +Multiple +-------- + Run cube example in two canvases. """ diff --git a/examples/noise.py b/examples/noise.py index a235c83..84e5289 100644 --- a/examples/noise.py +++ b/examples/noise.py @@ -1,4 +1,7 @@ """ +Noise +----- + Simple example that uses the bitmap-context to show images of noise. """ diff --git a/examples/offsceen_threaded.py b/examples/offsceen_threaded.py index bf8b5de..0827456 100644 --- a/examples/offsceen_threaded.py +++ b/examples/offsceen_threaded.py @@ -1,4 +1,7 @@ """ +Offscreen threaded +------------------ + Example that renders frames in a separate thread. This uses an offscreen canvas, the result is only used to print the diff --git a/examples/qt_app.py b/examples/qt_app.py index 13b8be5..08c1509 100644 --- a/examples/qt_app.py +++ b/examples/qt_app.py @@ -1,4 +1,7 @@ """ +Qt app +------ + An example demonstrating a qt app with a wgpu viz inside. If needed, change the PySide6 import to e.g. PyQt6, PyQt5, or PySide2. diff --git a/examples/qt_app_asyncio.py b/examples/qt_app_asyncio.py index fc00287..e30dc6f 100644 --- a/examples/qt_app_asyncio.py +++ b/examples/qt_app_asyncio.py @@ -1,4 +1,7 @@ """ +Qt app with asyncio +------------------- + An example demonstrating a qt app with a wgpu viz inside. This is the same as the ``qt_app.py`` example, except this uses diff --git a/examples/snake.py b/examples/snake.py index e4eec5a..d7d9e8e 100644 --- a/examples/snake.py +++ b/examples/snake.py @@ -1,4 +1,7 @@ """ +Snake game +---------- + Simple snake game based on bitmap rendering. Work in progress. """ diff --git a/examples/wx_app.py b/examples/wx_app.py index f1d9b9a..5111c12 100644 --- a/examples/wx_app.py +++ b/examples/wx_app.py @@ -1,4 +1,7 @@ """ +wx app +------ + An example demonstrating a wx app with a wgpu viz inside. """