Skip to content

Commit d549fc5

Browse files
authored
Rewrite and categorize the main sdl2.ext docs (#209)
* Major reorganization of the ext docs index * Minor cleanup * Add uisystem deprecation notices to news
1 parent 071bbcc commit d549fc5

File tree

6 files changed

+118
-16
lines changed

6 files changed

+118
-16
lines changed

doc/modules/ext/particles.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. module:: sdl2.ext.particles
22
:synopsis: A simple particle system.
33

4-
sdl2.ext.particles - A simple particle system
5-
=============================================
4+
A simple particle system
5+
========================
66

77
.. class:: ParticleEngine()
88

File renamed without changes.

doc/modules/ext/uisystem.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
.. currentmodule:: sdl2.ext
22

3-
User interface elements
4-
=======================
3+
Designing component-oriented user interfaces
4+
============================================
5+
6+
.. warning::
7+
This module is deprecated, and may be removed in a future release of PySDL2.
8+
59
User interface elements within :mod:`sdl2.ext` are simple
610
:class:`Sprite` objects, which are enhanced by certain input hooks; as such,
711
they are not classes on their own, but implemented as mixins. The user input
@@ -17,6 +21,7 @@ elements, which support the event type.
1721

1822
.. _ui-elem-types:
1923

24+
2025
UI element types
2126
----------------
2227
Every :class:`sdl2.ext` UI element is a simple :class:`Sprite` object, to

doc/modules/sdl2ext.rst

Lines changed: 104 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,111 @@
11
.. module:: sdl2.ext
2-
:synopsis: Python extensions for SDL2
2+
:synopsis: Helpful wrappers for the SDL2 API
33

4-
sdl2.ext - Python extensions for SDL2
5-
=====================================
6-
The :mod:`sdl2.ext` package provides advanced functionality for creating
7-
applications using SDL2 and Python. It offers a rich set of modules, classes
8-
and functions, such as easy image loading, basic user interface elements,
9-
resource management and sprite and (on-screen) scene systems.
4+
sdl2.ext - Helpful wrappers for the SDL2 API
5+
============================================
106

11-
Learn more about
7+
The :mod:`sdl2.ext` module provides a rich set of modules, classes, and
8+
functions for creating games and other applications using PySDL2.
9+
10+
The aim of the `sdl2.ext` module is to wrap commonly-used parts of the SDL2 API
11+
in a more friendly and Pythonic manner, reducing the need for developers to
12+
understand the intricacies of working with ``ctypes`` and making it simpler and
13+
more fun to get PySDL2 programs up and running.
14+
15+
In addition, this module provides a number of template classes and utility
16+
functions for working with colors, input events, file assets, and more.
17+
18+
Due to its broad scope, the :mod:`sdl2.ext` module is divided into a number of
19+
submodules. However, everything in these submodules can be imported directly
20+
from :mod:`sdl2.ext`. For example, ``from sdl2.ext import Window`` is exactly
21+
the same as ``from sdl2.ext.window import Window``.
22+
23+
24+
SDL2 module wrappers
25+
--------------------
26+
27+
Some parts of the :mod:`sdl2.ext` module contain Pythonic wrappers for common
28+
and/or unpleasant parts of the SDL2 API. At present, these modules include:
29+
30+
.. toctree::
31+
:maxdepth: 1
32+
33+
ext/common.rst
34+
ext/window.rst
35+
ext/renderer.rst
36+
ext/msgbox.rst
37+
38+
39+
Utilities for working with SDL2 in Python
40+
-----------------------------------------
41+
42+
Other parts of this module implement functions and classes that make it easier
43+
to work with SDL2 functions and data structures in Python (and vice versa).
44+
These include functions for converting text to and from UTF8-encoded bytes,
45+
reading and writing ``ctypes`` arrays, and casting :obj:`~sdl2.SDL_Surface`
46+
objects to Numpy arrays:
47+
48+
.. toctree::
49+
:maxdepth: 1
50+
51+
ext/compat.rst
52+
ext/array.rst
53+
ext/pixelaccess.rst
54+
55+
56+
SDL2-based extensions
57+
---------------------
58+
59+
In addition to simple Pythonic wrappers for SDL2 functions and structures, the
60+
:mod:`sdl2.ext` module also offers a number of high-level classes and functions
61+
that use SDL2 internally to provide APIs for font rendering, building GUIs,
62+
importing images, and more:
63+
64+
.. toctree::
65+
:maxdepth: 1
66+
67+
ext/surface.rst
68+
ext/draw.rst
69+
ext/image.rst
70+
ext/ttf.rst
71+
ext/bitmapfont.rst
72+
73+
74+
Useful helpers for building apps
75+
--------------------------------
76+
77+
Beyond wrappers and utilities for working with SDL2's API, the
78+
:mod:`sdl2.ext` module also includes a number of submodules with various
79+
functions and classes to help facilitate general game and app development with
80+
PySDL2. These include classes for managing program resource files, working
81+
with colors, and more:
82+
83+
.. toctree::
84+
:maxdepth: 1
85+
86+
ext/resources.rst
87+
ext/color.rst
88+
ext/colorpalettes.rst
89+
ext/algorithms.rst
90+
91+
92+
Component-Oriented Systems
93+
--------------------------
94+
95+
PySDL2 contains several modules designed around the concept of
96+
component-oriented game programming. These modules define various types of
97+
"systems" for processing events and "factories" for creating different types
98+
of objects, among other things.
99+
100+
.. note::
101+
These modules are not regularly maintained, and their documentation
102+
may be inaccurate or out-of-date.
12103

13104
.. toctree::
14105
:maxdepth: 1
15-
:glob:
16106

17-
ext/*
107+
ext/ebs.rst
108+
ext/events.rst
109+
ext/spritesystem.rst
110+
ext/uisystem.rst
111+
ext/particles.rst

doc/news.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ Deprecation Notices:
131131
:meth:`sdl2.ext.BitmapFont.render_text`, which returns an SDL surface instead
132132
of a SoftwareSprite and ensures the output surface is in ARGB8888 format by
133133
default (PR #208)
134+
* The :class:`~sdl2.ext.UIFactory` and :class:`~sdl2.ext.UIProcessor` classes
135+
have been deprecated due to their complexity and maintenance burden. New
136+
functions and classes for creating GUIs with PySDL2 may be introduced in a
137+
future release (PR #209)
134138

135139

136140
0.9.9

sdl2/ext/events.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ class MPEventHandler(EventHandler):
7979
"""
8080
def __init__(self, sender, maxprocs=None):
8181
if not _HASMP:
82-
raise UnsupportedError(MPEventHandler,
83-
"no multiprocessing support found")
82+
raise UnsupportedError("no multiprocessing support found")
8483
super(MPEventHandler, self).__init__(sender)
8584
self.maxprocs = maxprocs
8685

0 commit comments

Comments
 (0)