Skip to content

Commit bc6495f

Browse files
committed
Refactor docstrings to include class references for better clarity
1 parent 1d5781a commit bc6495f

4 files changed

Lines changed: 23 additions & 16 deletions

File tree

engine/core/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ def __init__(self, *, parent: "Game") -> None:
339339

340340
def _get_colliding_entities(self, entity: Entity) -> list[Entity]:
341341
"""
342-
Internal collision query used by Entity.get_colliding_entities().
342+
Internal collision query used by
343+
:meth:`~engine.core.Entity.get_colliding_entities`.
343344
344345
Args:
345346
entity (Entity): Entity to evaluate collisions for.

engine/core/animation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
class EntityAnim:
1515
"""
16-
Manage an animation for an entity.
16+
Manage an animation for an :class:`~engine.core.Entity`.
1717
18-
Stands in for EntityImage when an entity should show a moving image (GIF
19-
or WebP) instead of a still one. It offers the same three methods, so an
18+
Stands in for :class:`~engine.core.image.EntityImage`
19+
when an entity should show a moving image (GIF or WebP)
20+
instead of a still one. It offers the same three methods, so an
2021
entity holding one needs no special handling, and frames advance off the
2122
clock on their own: drawing it is all the caller has to do. The animation
2223
loops for as long as it keeps being drawn, at the pace the file asks for.

engine/core/image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212

1313
class EntityImage:
1414
"""
15-
Manage a pygame image surface for an entity.
15+
Manage a pygame image surface for an :class:`~engine.core.Entity`.
1616
"""
1717

1818
surface: Optional[pygame.Surface]
1919

2020
def __init__(self, image_path: str) -> None:
2121
"""
22-
Initialize the EntityImage by loading the image at ``image_path``.
22+
Initialize the :class:`~engine.core.image.EntityImage` by loading the
23+
image at ``image_path``.
2324
2425
Args:
2526
image_path (str): The path to the image file.

engine/core/ose.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313

1414
def _script_defines(scriptobj: EntityScriptType, name: str) -> bool:
1515
"""
16-
Check whether scriptobj itself defines `name`, rather than inheriting
17-
it from Entity. Since script classes are commonly subclasses of Entity
18-
(for typing convenience), a plain hasattr() check would also match
19-
Entity's own init/update/event, causing infinite recursion when they
20-
are dispatched.
16+
Check whether scriptobj itself defines ``name``, rather than inheriting
17+
it from :class:`~engine.core.Entity`. Since script classes are commonly
18+
subclasses of :class:`~engine.core.Entity` (for typing convenience), a
19+
plain hasattr() check would also match its own init/update/event,
20+
causing infinite recursion when they are dispatched.
2121
2222
2323
Args:
2424
scriptobj (EntityScriptType): The script object to check.
2525
name (str): The name of the method to check for.
2626
2727
Returns:
28-
bool: True if scriptobj defines `name`, False otherwise.
28+
bool: True if scriptobj defines ``name``, False otherwise.
2929
"""
3030

3131
func: Optional[Callable] = getattr(scriptobj, name, None)
@@ -39,16 +39,20 @@ class ObjectScriptEntity(Entity):
3939

4040
def __new__(cls, *args: Any, scriptobj: EntityScriptType, **kwargs: Any) -> Any:
4141
"""
42-
Create an Entity configured to dispatch lifecycle calls to ``scriptobj``.
42+
Create an :class:`~engine.core.Entity` configured to dispatch lifecycle
43+
calls to ``scriptobj``.
4344
4445
Args:
45-
*args (Any): Positional arguments forwarded to Entity.
46+
*args (Any): Positional arguments forwarded to
47+
Entity.
4648
scriptobj (EntityScriptType): Object script providing optional
4749
init, update, and event methods.
48-
**kwargs (Any): Keyword arguments forwarded to Entity.
50+
**kwargs (Any): Keyword arguments forwarded to
51+
Entity.
4952
5053
Returns:
51-
Any: Entity instance with object-script dispatch metadata attached.
54+
Any: :class:`~engine.core.Entity` instance with object-script
55+
dispatch metadata attached.
5256
"""
5357

5458
kwargs["scriptfile"] = None

0 commit comments

Comments
 (0)