Skip to content

Commit ae8c950

Browse files
authored
Reduce excessive output when building docs + fix missing docstring warnings (#2630)
* All output from docs build should use logging * Make warning the default log level * Missing docstring in pymunk_physics_engine * Missing docstrings
1 parent 35cf967 commit ae8c950

File tree

12 files changed

+151
-28
lines changed

12 files changed

+151
-28
lines changed

arcade/camera/data_types.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,16 @@ def use(self) -> None:
427427
...
428428

429429
@contextmanager
430-
def activate(self) -> Generator[Self, None, None]: ...
430+
def activate(self) -> Generator[Self, None, None]:
431+
"""
432+
Activate this projector for rendering.
433+
434+
This is a context manager and should be used with a ``with`` statement::
435+
436+
with projector.activate():
437+
# Render with this projector
438+
"""
439+
...
431440

432441
def project(self, world_coordinate: Point) -> Vec2:
433442
"""

arcade/clock.py

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def ticks_since(self, tick: int) -> int:
9595

9696
@property
9797
def max_deltatime(self) -> float | None:
98+
"""
99+
The maximum deltatime that the clock will allow. If a large dt is passed into
100+
"""
98101
return self._max_deltatime
99102

100103
@property

arcade/easing.py

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class EasingData:
2323
ease_function: Callable
2424

2525
def reset(self) -> None:
26+
"""
27+
Reset the easing data to its initial state.
28+
"""
2629
self.cur_period = self.start_period
2730

2831

arcade/future/background/background_texture.py

+42
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ class BackgroundTexture:
1515
1616
The Mat3s define the scaling, rotation, and translation of the pixel data in the texture.
1717
see background_fs.glsl in resources/shaders for an implementation of this.
18+
19+
Args:
20+
texture: The texture to use as the background.
21+
offset: The offset of the texture in pixels.
22+
scale: The scale of the texture.
23+
angle: The angle of the texture in radians.
1824
"""
1925

2026
def __init__(
@@ -41,6 +47,10 @@ def pixel_transform(self):
4147

4248
@property
4349
def scale(self) -> float:
50+
"""
51+
Get or set the scale of the texture. This is a multiplier on the size of the texture.
52+
Default value is ``1.0``.
53+
"""
4454
return self._scale
4555

4656
@scale.setter
@@ -50,6 +60,10 @@ def scale(self, value: float):
5060

5161
@property
5262
def angle(self) -> float:
63+
"""
64+
Get or set the angle of the texture. This is a rotation in radians.
65+
Default value is ``0.0``.
66+
"""
5367
return self._angle
5468

5569
@angle.setter
@@ -59,6 +73,10 @@ def angle(self, value: float):
5973

6074
@property
6175
def offset(self) -> tuple[float, float]:
76+
"""
77+
Get or set the offset of the texture. This is a translation in pixels.
78+
Default value is ``(0.0, 0.0)``.
79+
"""
6280
return self._offset
6381

6482
@offset.setter
@@ -134,6 +152,17 @@ def render_target(
134152
color_attachments: list[gl.Texture2D] | None = None,
135153
depth_attachment: gl.Texture2D | None = None,
136154
) -> gl.Framebuffer:
155+
"""
156+
Create a framebuffer for the texture.
157+
158+
This framebuffer is used to render to the texture. The framebuffer is created with the
159+
texture as the color attachment.
160+
161+
Args:
162+
context: The context to use for the framebuffer.
163+
color_attachments: The color attachments to use for the framebuffer."
164+
depth_attachment: The depth attachment to use for the framebuffer."
165+
"""
137166
if color_attachments is None:
138167
color_attachments = []
139168
return context.framebuffer(
@@ -149,6 +178,19 @@ def from_file(
149178
angle: float = 0.0,
150179
filters=(gl.NEAREST, gl.NEAREST),
151180
):
181+
""" "
182+
Create a BackgroundTexture from a file.
183+
This is a convenience function to create a BackgroundTexture from a file.
184+
185+
The file is loaded using PIL and converted to a texture.
186+
187+
Args:
188+
tex_src: The file to load.
189+
offset: The offset of the texture in pixels.
190+
scale: The scale of the texture.
191+
angle: The angle of the texture in radians.
192+
filters: The filters to use for the texture.
193+
"""
152194
_context = get_window().ctx
153195

154196
with Image.open(resolve(tex_src)).convert("RGBA") as img:

arcade/future/light/lights.py

+5
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,23 @@ def __init__(self, width: int, height: int):
122122

123123
@property
124124
def diffuse_texture(self):
125+
"""The diffuse texture"""
125126
return self.texture
126127

127128
@property
128129
def light_texture(self):
130+
"""The light texture"""
129131
return self._light_buffer.color_attachments[0]
130132

131133
def resize(self, width, height):
134+
"""Resize the light layer"""
132135
super().resize(width, height)
133136
self._light_buffer = self.ctx.framebuffer(
134137
color_attachments=self.ctx.texture((width, height), components=3)
135138
)
136139

137140
def clear(self):
141+
"""Clear the light layer"""
138142
super().clear()
139143
self._light_buffer.clear()
140144

@@ -145,6 +149,7 @@ def add(self, light: Light):
145149
self._rebuild = True
146150

147151
def extend(self, lights: Sequence[Light]):
152+
"""Add a list of lights to the layer"""
148153
for light in lights:
149154
self.add(light)
150155

arcade/gl/types.py

+12
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,17 @@ def __init__(
192192
location=0,
193193
):
194194
self.name = name
195+
"""The name of the attribute in the program"""
195196
self.gl_type = gl_type
197+
"""The OpenGL type of the attribute"""
196198
self.components = components
199+
"""Number of components for this attribute (1, 2, 3 or 4)"""
197200
self.bytes_per_component = bytes_per_component
201+
"""How many bytes for a single component"""
198202
self.offset = offset
203+
"""Offset of the attribute in the buffer"""
199204
self.location = location
205+
"""Location of the attribute in the program"""
200206

201207
@property
202208
def bytes_total(self) -> int:
@@ -408,13 +414,19 @@ def __init__(
408414
self, name: str, enum: GLenumLike, gl_type: PyGLenum, gl_size: int, components: int
409415
):
410416
self.name = name
417+
"""The string representation of this type"""
411418
self.enum = enum
419+
"""The OpenEL enum of this type"""
412420
self.gl_type = gl_type
421+
"""The base OpenGL data type"""
413422
self.gl_size = gl_size
423+
"""The size of the base OpenGL data type"""
414424
self.components = components
425+
"""The number of components (1, 2, 3 or 4)"""
415426

416427
@property
417428
def size(self) -> int:
429+
"""The total size of this type in bytes"""
418430
return self.gl_size * self.components
419431

420432
def __repr__(self) -> str:

arcade/gl/uniform.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import struct
22
from ctypes import POINTER, c_double, c_float, c_int, c_uint, cast
3+
from typing import Callable
34

45
from pyglet import gl
56

@@ -173,8 +174,10 @@ def __init__(self, ctx, program_id, location, name, data_type, array_length):
173174
self._array_length = array_length
174175
# Number of components (including per array entry)
175176
self._components = 0
176-
#: The getter function configured for this uniform
177-
#: The setter function configured for this uniform
177+
self.getter: Callable
178+
"""The getter function configured for this uniform"""
179+
self.setter: Callable
180+
"""The setter function configured for this uniform"""
178181
self._setup_getters_and_setters()
179182

180183
@property

arcade/isometric.py

+33
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
def isometric_grid_to_screen(
66
tile_x: int, tile_y: int, width: int, height: int, tile_width: int, tile_height: int
77
) -> tuple[int, int]:
8+
"""
9+
Convert isometric grid coordinates to screen coordinates.
10+
11+
Args:
12+
tile_x: The x coordinate of the tile in the isometric grid.
13+
tile_y: The y coordinate of the tile in the isometric grid.
14+
width: The width of the screen.
15+
height: The height of the screen.
16+
tile_width: The width of a tile in pixels.
17+
tile_height: The height of a tile in pixels.
18+
"""
819
screen_x = tile_width * tile_x // 2 + height * tile_width // 2 - tile_y * tile_width // 2
920
screen_y = (
1021
(height - tile_y - 1) * tile_height // 2
@@ -17,6 +28,17 @@ def isometric_grid_to_screen(
1728
def screen_to_isometric_grid(
1829
screen_x: int, screen_y: int, width: int, height: int, tile_width: int, tile_height: int
1930
) -> tuple[int, int]:
31+
"""
32+
Convert screen coordinates to isometric grid coordinates.
33+
34+
Args:
35+
screen_x: The x coordinate on the screen.
36+
screen_y: The y coordinate on the screen.
37+
width: The width of the screen.
38+
height: The height of the screen.
39+
tile_width: The width of a tile in pixels.
40+
tile_height: The height of a tile in pixels.
41+
"""
2042
x2 = (1 / tile_width * screen_x / 2 - 1 / tile_height * screen_y / 2 + width / 2) * 2 - (
2143
width / 2 + 0.5
2244
)
@@ -31,6 +53,17 @@ def screen_to_isometric_grid(
3153
def create_isometric_grid_lines(
3254
width: int, height: int, tile_width: int, tile_height: int, color: RGBA255, line_width: int
3355
) -> ShapeElementList:
56+
"""
57+
Create a ShapeElementList of isometric grid lines.
58+
59+
Args:
60+
width: The width of the grid in tiles.
61+
height: The height of the grid in tiles.
62+
tile_width: The width of a tile in pixels.
63+
tile_height: The height of a tile in pixels.
64+
color: The color of the lines.
65+
line_width: The width of the lines.
66+
"""
3467
# Grid lines 1
3568
shape_list: ShapeElementList = ShapeElementList()
3669

arcade/pymunk_physics_engine.py

+9
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,15 @@ def set_position(self, sprite: Sprite, position: pymunk.Vec2d | tuple[float, flo
499499
physics_object.body.position = position
500500

501501
def set_rotation(self, sprite: Sprite, rotation: float) -> None:
502+
"""
503+
Set the rotation of the sprite
504+
505+
Args:
506+
sprite:
507+
A sprite known to the physics engine.
508+
rotation:
509+
The angle in degrees (clockwise).
510+
"""
502511
physics_object = self.get_physics_object(sprite)
503512
if physics_object.body is None:
504513
raise PymunkException(

doc/conf.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
UTIL_DIR = REPO_LOCAL_ROOT / "util"
1919

2020
log = logging.getLogger('conf.py')
21-
logging.basicConfig(level=logging.INFO)
21+
logging.basicConfig(level=logging.WARNING)
22+
# logging.basicConfig(level=logging.INFO)
2223

2324
sys.path.insert(0, str(REPO_LOCAL_ROOT))
2425
sys.path.insert(0, str(ARCADE_MODULE))
@@ -513,12 +514,12 @@ def run(self) -> tuple[list[nodes.Node], list[nodes.system_message]]:
513514

514515

515516
def setup(app):
516-
print("Diagnostic info since readthedocs doesn't use our make.py:")
517+
log.info("Diagnostic info since readthedocs doesn't use our make.py:")
517518
for attr, comment in APP_CONFIG_DIRS:
518519
val = getattr(app, attr, None)
519-
print(f" {attr}: {val!r}")
520+
log.info(f"{attr}: {val!r}")
520521
if comment:
521-
print(f" {comment}")
522+
log.info(f" {comment}")
522523

523524
# Separate stylesheets loosely by category.
524525
# pending: sphinx >= 8.1.4 to remove the sphinx_static_file_temp_fix.py

0 commit comments

Comments
 (0)