Skip to content

Commit 7829a5f

Browse files
authored
Documentation improvements (#2634)
* refs in resources * platform_tutorial * pymunk_platformer * views * card_game * Notice in shader tutorials * menu tutorial * sections * spritelists * opengl_notes * resource_handlers * texture_atlas
1 parent 1cd0b9d commit 7829a5f

File tree

12 files changed

+44
-40
lines changed

12 files changed

+44
-40
lines changed

arcade/resources/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def resolve_resource_path(path: str | Path) -> Path:
3636
If the path is a string it tries to resolve it as a resource handle
3737
or convert it to a Path object.
3838
39-
If the path is a Path object it will ``Path.resolve()`` it
39+
If the path is a Path object it will :py:meth:`~pathlib.Path.resolve` it
4040
unless it's not absolute and return it.
4141
4242
Example::
@@ -57,7 +57,7 @@ def resolve(path: str | Path) -> Path:
5757
If the path is a string it tries to resolve it as a resource handle
5858
or convert it to a Path object.
5959
60-
If the path is a Path object it will ``Path.resolve()`` it
60+
If the path is a Path object it will :py:meth:`~pathlib.Path.resolve` it
6161
unless it's not absolute and return it.
6262
6363
Example::

doc/programming_guide/opengl_notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ SpriteList & Threads
9191
SpriteLists can be created in threads if they are
9292
created with the ``lazy=True`` parameters.
9393
This ensures OpenGL resources are not created until the
94-
first ``draw()`` call or ``initialize()`` is called.
94+
first :py:meth:`~arcade.SpriteList.draw()` call or :py:meth:`~arcade.SpriteList.initialize` is called.
9595

9696
.. _prog-guide-gl-buffer-protocol-typing:
9797

doc/programming_guide/resource_handlers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Import the Path Class Before Arcade
221221
"""""""""""""""""""""""""""""""""""
222222

223223
To use :py:mod:`pathlib`, you usually only need to import
224-
py:class:`~pathlib.Path` from it.
224+
:py:class:`~pathlib.Path` from it.
225225

226226
Since Python developers usually import built-ins before add-on
227227
libraries like Arcade, we'll do the same here:

doc/programming_guide/sections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Properties of a :class:`~arcade.Section`:
228228
Other handy :class:`~arcade.Section` properties:
229229

230230
- block_updates: if True this section will not have the ``on_update`` method called.
231-
- camera: this is meant to hold a ``arcade.Camera`` but it is None by default. The SectionManager will trigger the use of the camera when is needed automatically.
231+
- camera: this is meant to hold a :py:class:`~arcade.Camera2D` but it is None by default. The SectionManager will trigger the use of the camera when is needed automatically.
232232

233233
Handy :class:`~arcade.Section`: methods:
234234

doc/programming_guide/sprites/spritelists.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Each sprite describes where a game object is & how to draw it. This includes:
1212
* Where to find the image data
1313
* How big the image should be
1414

15-
The rest of this page will explain using the ``SpriteList`` class to draw
15+
The rest of this page will explain using the :py:class:`~arcade.SpriteList` class to draw
1616
sprites to the screen.
1717

1818

doc/programming_guide/texture_atlas.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Most users will not be aware that Arcade is using a texture
5555
atlas under the hood. More advanced users can take advantage
5656
of these if they run into limitations.
5757

58-
Arcade has a global default texture atlas stored in ``window.ctx.default_atlas``.
58+
Arcade has a global default texture atlas stored in :py:attr:`arcade.Window.ctx.default_atlas`.
5959
This is an instance of :py:class:`arcade.ArcadeContext` where the low
6060
level rendering API is accessed (OpenGL).
6161

doc/tutorials/card_game/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Card Class
5151
~~~~~~~~~~
5252

5353
Next up, we'll create a card class. The card class is a subclass of
54-
``arcade.Sprite``. It will have attributes for the suit and value of the
54+
:py:class:`~arcade.Sprite`. It will have attributes for the suit and value of the
5555
card, and auto-load the image for the card based on that.
5656

5757
We'll use the entire image as the hit box, so we don't need to go through the

doc/tutorials/menu/index.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ Modify the MainView
4646
~~~~~~~~~~~~~~~~~~~~
4747

4848
We are going to add a button to change the view. For drawing a button we would
49-
need a ``UIManager``.
49+
need an :py:class:`~arcade.gui.UIManager`.
5050

5151
.. literalinclude:: menu_02.py
5252
:caption: Initialising the Manager
5353
:lines: 19-22
5454
:emphasize-lines: 3
5555

56-
After initialising the manager we need to enable it when the view is shown and
56+
After initializing the manager we need to enable it when the view is shown and
5757
disable it when the view is hidden.
5858

5959
.. literalinclude:: menu_02.py
@@ -74,12 +74,12 @@ We also need to draw the children of the menu in ``on_draw``.
7474
:emphasize-lines: 7
7575

7676
Now we have successfully setup the manager, we can now add a button to the view.
77-
We are using ``UIAnchorLayout`` to position the button. We also setup a function
77+
We are using :py:class:`~arcade.gui.UIAnchorLayout` to position the button. We also setup a function
7878
which is called when the button is clicked.
7979

8080
.. literalinclude:: menu_02.py
8181
:pyobject: MainView.__init__
82-
:caption: Initialising the Button
82+
:caption: Initializing the Button
8383
:emphasize-lines: 8-12
8484

8585
Initialise the Menu View
@@ -123,7 +123,7 @@ First we setup buttons for resume, starting a new game, volume, options and exit
123123
Displaying the Buttons in a Grid
124124
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125125

126-
After setting up the buttons we add them to ``UIGridLayout``, so that they can
126+
After setting up the buttons we add them to :py:class:`~arcade.gui.UIGridLayout`, so that they can
127127
displayed in a grid like manner.
128128

129129
.. literalinclude:: menu_03.py
@@ -167,7 +167,7 @@ Adding ``on_click`` Callback for Volume and Options
167167
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168168

169169
Now we need to implement an actual menu for volume and options, for that we have
170-
to make a class that acts like a window. Using ``UIMouseFilterMixin`` we catch
170+
to make a class that acts like a window. Using :py:class:`~arcade.gui.UIMouseFilterMixin` we catch
171171
all the events happening for the parent and respond nothing to them. Thus
172172
making it act like a window/view.
173173

@@ -221,7 +221,7 @@ Now you might be getting a little idea why we have edited the parameters but
221221
Adding a Title label
222222
--------------------
223223

224-
We will be adding a ``UILabel`` that explains the menu. ``UISpace`` is a widget
224+
We will be adding a :py:class:`~arcade.gui.UILabel` that explains the menu. :py:class:`~arcade.gui.UISpace` is a widget
225225
that can be used to add space around some widget, you can set its color to the
226226
background color so it appears invisible.
227227

@@ -236,10 +236,10 @@ Adding it to the widget layout.
236236
:lines: 238-239
237237

238238

239-
Adding a Input Field
239+
Adding an Input Field
240240
~~~~~~~~~~~~~~~~~~~~~
241241

242-
We will use ``UIInputText`` to add an input field. The ``with_border()``
242+
We will use :py:class:`~arcade.gui.UIInputText` to add an input field. The :py:meth:`~arcade.gui.UIWidget.with_border`
243243
function creates a border around the widget with color(default argument is
244244
black) black and thickness(default argument is 2px) 2px. Add this just below
245245
the title label.
@@ -263,7 +263,7 @@ in the last also for those of you who are skipping through this section :P.
263263
Adding a Toggle Button
264264
~~~~~~~~~~~~~~~~~~~~~~
265265

266-
Don't go on the section title much, in Arcade the ``UITextureToggle`` is not
266+
Don't go on the section title much, in Arcade the :py:class:`~arcade.gui.UITextureToggle` is not
267267
really a button it switches between two textures when clicked. Yes, it
268268
functions like a button but by "is not really a button" we meant that it
269269
doesn't inherits the button class. We also pair it up horizontally with the
@@ -283,7 +283,7 @@ field.
283283
Adding a Dropdown
284284
~~~~~~~~~~~~~~~~~
285285

286-
We add a dropdown by using ``UIDropdown``.
286+
We add a dropdown by using :py:class:`~arcade.gui.UIDropdown`.
287287

288288
.. literalinclude:: menu_05.py
289289
:caption: Adding dropdown
@@ -298,9 +298,9 @@ Adding it to the widget layout.
298298
Adding a Slider
299299
~~~~~~~~~~~~~~~
300300

301-
The final widget. In Arcade you can use ``UISlider`` to implement a slider.
301+
The final widget. In Arcade you can use :py:class:`~arcade.gui.UISlider` to implement a slider.
302302
Theres a functionality to style the slider, this is also present for
303-
``UIFlatButton`` and ``UITextureButton``.
303+
:py:class:`~arcade.gui.UIFlatButton` and :py:class:`~arcade.gui.UITextureButton`.
304304

305305
.. literalinclude:: menu_05.py
306306
:caption: Adding slider

doc/tutorials/platform_tutorial/step_04.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ functions, based on the key that was pressed or released, we will move our chara
4646
elif key == arcade.key.RIGHT or key == arcade.key.D:
4747
self.player_sprite.change_x = 0
4848
49-
In these boxes, we are modifying the ``change_x`` and ``change_y`` attributes on our
49+
In these boxes, we are modifying the :py:attr:`~arcade.Sprite.change_x` and :py:attr:`~arcade.Sprite.change_y` attributes on our
5050
player Sprite. Changing these values will not actually perform the move on the Sprite.
5151
In order to apply this change, we need to create a physics engine with our Sprite,
5252
and update the physics engine every frame. The physics engine will then be responsible

doc/tutorials/pymunk_platformer/index.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ lines of code like this:
8888
self.player_list: Optional[arcade.SpriteList] = None
8989
9090
This means the ``player_list`` attribute is going to be an instance of
91-
``SpriteList`` or ``None``. If you don't want to mess with typing, then
91+
:py:class:`~arcade.SpriteList` or ``None``. If you don't want to mess with typing, then
9292
this code also works just as well:
9393

9494
.. code-block::
@@ -121,7 +121,7 @@ If you aren't sure how to use the Tiled Map Editor, see :ref:`platformer_part_ei
121121

122122
Now, in the ``setup`` function, we are going add code to:
123123

124-
* Create instances of ``SpriteList`` for each group of sprites we are doing
124+
* Create instances of :py:class:`~arcade.SpriteList` for each group of sprites we are doing
125125
to work with.
126126
* Create the player sprite.
127127
* Read in the tiled map.
@@ -298,7 +298,7 @@ Then we will adjust the left/right force depending on if we are grounded or not:
298298
Add Player Animation
299299
--------------------
300300

301-
To create a player animation, we make a custom child class of ``Sprite``.
301+
To create a player animation, we make a custom child class of :py:class:`~arcade.Sprite`.
302302
We load each frame of animation that we need, including a mirror image of it.
303303

304304
We will flip the player to face left or right. If the player is in the air, we'll
@@ -318,7 +318,7 @@ animation, so that the feet appear in-sync with the ground.
318318
:linenos:
319319
:lines: 58-66
320320

321-
Next, we create a ``Player`` class that is a child to ``arcade.Sprite``. This
321+
Next, we create a ``Player`` class that is a child to :py:class:`~arcade.Sprite`. This
322322
class will update the player animation.
323323

324324
The ``__init__`` method loads all of the textures. Here we use Kenney.nl's
@@ -327,8 +327,8 @@ It has six different characters you can choose from with the same layout, so
327327
it makes changing as simple as changing which line is enabled. There are
328328
eight textures for walking, and textures for idle, jumping, and falling.
329329

330-
As the character can face left or right, we use ``arcade.load_texture_pair``
331-
which will load both a regular image, and one that's mirrored.
330+
As the character can face left or right, we prepare a standard and mirrored
331+
version of each texture by using :py:meth:`~arcade.Texture.flip_left_right`.
332332

333333
For the multi-frame walking animation, we use an "odometer." We need to move
334334
a certain number of pixels before changing the animation. If this value is too
@@ -344,7 +344,7 @@ called. This can be used to update the animation.
344344
:linenos:
345345
:pyobject: PlayerSprite
346346

347-
Important! At this point, we are still creating an instance of ``arcade.Sprite``
347+
Important! At this point, we are still creating an instance of :py:class:`~arcade.Sprite`
348348
and **not** ``PlayerSprite``. We need to go back to the ``setup`` method and
349349
replace the line that creates the ``player`` instance with:
350350

@@ -434,7 +434,7 @@ If our y value is too low, we'll remove the bullet.
434434
:pyobject: BulletSprite
435435

436436
And, of course, once we create the bullet we have to update our code to use
437-
it instead of the plain ``arcade.Sprite`` class.
437+
it instead of the plain :py:class:`~arcade.Sprite` class.
438438

439439
.. literalinclude:: pymunk_demo_platformer_10.py
440440
:caption: Destroy Bullets - Bullet Sprite

0 commit comments

Comments
 (0)