Skip to content

Commit

Permalink
remove unnecessary paths from Sphinx directives.
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygoy committed Feb 21, 2024
1 parent ed809bf commit dd6b4ae
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 73 deletions.
48 changes: 24 additions & 24 deletions screenpy/actions/either.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Either:
By default, ``Either`` catches AssertionErrors, so you can use
:class:`~screenpy.actions.See` to decide which path to follow. Use the
:meth:`~screenpy.actions.Either.ignoring` method to ignore other exceptions.
:meth:`ignoring` method to ignore other exceptions.
Examples::
Expand All @@ -46,33 +46,15 @@ class Either:
except_performables: tuple[Performable, ...]
ignore_exceptions: tuple[type[BaseException], ...]

def perform_as(self, the_actor: Actor) -> None:
"""Direct the Actor to perform one of two performances."""
# kinking the cable before the attempt
# avoids explaning what the actor tries to do.
# logs the first attempt only if it succeeds
# or if UNABRIDGED_NARRATION is enabled
with the_narrator.mic_cable_kinked():
try:
the_actor.will(*self.try_performables)
except self.ignore_exceptions:
if not settings.UNABRIDGED_NARRATION:
the_narrator.clear_backup()
else:
return

the_actor.will(*self.except_performables)
return

def or_(self, *except_performables: Performable) -> Self:
"""Provide the alternative routine to perform.
Aliases:
* :meth:`~screenpy.actions.Either.except_`
* :meth:`~screenpy.actions.Either.else_`
* :meth:`~screenpy.actions.Either.otherwise`
* :meth:`~screenpy.actions.Either.alternatively`
* :meth:`~screenpy.actions.Either.failing_that`
* :meth:`except_`
* :meth:`else_`
* :meth:`otherwise`
* :meth:`alternatively`
* :meth:`failing_that`
"""
self.except_performables = except_performables
return self
Expand All @@ -95,6 +77,24 @@ def describe(self) -> str:

return f"Either {try_summary} or {except_summary}"

def perform_as(self, the_actor: Actor) -> None:
"""Direct the Actor to perform one of two performances."""
# kinking the cable before the attempt
# avoids explaning what the actor tries to do.
# logs the first attempt only if it succeeds
# or if UNABRIDGED_NARRATION is enabled
with the_narrator.mic_cable_kinked():
try:
the_actor.will(*self.try_performables)
except self.ignore_exceptions:
if not settings.UNABRIDGED_NARRATION:
the_narrator.clear_backup()
else:
return

the_actor.will(*self.except_performables)
return

def __init__(self, *first: Performable) -> None:
self.try_performables: tuple[Performable, ...] = first
self.ignore_exceptions = (AssertionError,)
20 changes: 10 additions & 10 deletions screenpy/actions/eventually.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,40 +81,40 @@ def for_(self, amount: float) -> _TimeframeBuilder:
"""Set for how long the actor should continue trying.
Aliases:
* :meth:`~screenpy.actions.Eventually.trying_for_no_longer_than`
* :meth:`~screenpy.actions.Eventually.trying_for`
* :meth:`~screenpy.actions.Eventually.waiting_for`
* :meth:`trying_for_no_longer_than`
* :meth:`trying_for`
* :meth:`waiting_for`
"""
return self._TimeframeBuilder(self, amount, "timeout")

def trying_for_no_longer_than(self, amount: float) -> _TimeframeBuilder:
"""Alias for :meth:`~screenpy.actions.Eventually.for_`."""
"""Alias for :meth:`for_`."""
return self.for_(amount)

def trying_for(self, amount: float) -> _TimeframeBuilder:
"""Alias for :meth:`~screenpy.actions.Eventually.for_`."""
"""Alias for :meth:`for_`."""
return self.for_(amount)

def waiting_for(self, amount: float) -> _TimeframeBuilder:
"""Alias for :meth:`~screenpy.actions.Eventually.for_`."""
"""Alias for :meth:`for_`."""
return self.for_(amount)

def polling(self, amount: float) -> _TimeframeBuilder:
"""Adjust the polling frequency.
Aliases:
* :meth:`~screenpy.actions.Eventually.polling_every`
* :meth:`~screenpy.actions.Eventually.trying_every`
* :meth:`polling_every`
* :meth:`trying_every`
"""
self.poll = amount
return self._TimeframeBuilder(self, amount, "poll")

def polling_every(self, amount: float) -> _TimeframeBuilder:
"""Alias for :meth:`~screenpy.actions.Eventually.polling`."""
"""Alias for :meth:`polling`."""
return self.polling(amount)

def trying_every(self, amount: float) -> _TimeframeBuilder:
"""Alias for :meth:`~screenpy.actions.Eventually.polling`."""
"""Alias for :meth:`polling`."""
return self.polling(amount)

def describe(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/make_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def of(cls, question: T_Q) -> Self:
"""Supply the Question to answer and its arguments.
Aliases:
* :meth:`~screenpy.actions.MakeNote.of_the`
* :meth:`of_the`
"""
return cls(question)

@classmethod
def of_the(cls, question: T_Q) -> Self:
"""Alias for :meth:`~screenpy.actions.MakeNote.of`."""
"""Alias for :meth:`of`."""
return cls.of(question)

def as_(self, key: str) -> Self:
Expand Down
4 changes: 2 additions & 2 deletions screenpy/actions/pause.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def seconds_because(self, reason: str) -> Self:
"""Use seconds and provide a reason for the pause.
Aliases:
* :meth:`~screenpy.actions.Pause.second_because`
* :meth:`second_because`
"""
self.unit = f"second{'s' if self.number != 1 else ''}"
self.reason = self._massage_reason(reason)
return self

def second_because(self, reason: str) -> Self:
"""Alias for :meth:`~screenpy.actions.Pause.seconds_because`."""
"""Alias for :meth:`seconds_because`."""
return self.seconds_because(reason)

def milliseconds_because(self, reason: str) -> Self:
Expand Down
70 changes: 35 additions & 35 deletions screenpy/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def who_can(self, *abilities: T_Ability) -> Self:
"""Add one or more Abilities to this Actor.
Aliases:
* :meth:`~screenpy.actor.Actor.can`
* :meth:`can`
"""
self.abilities.extend(abilities)
return self

def can(self, *abilities: T_Ability) -> Self:
"""Alias for :meth:`~screenpy.actor.Actor.who_can`."""
"""Alias for :meth:`who_can`."""
return self.who_can(*abilities)

def has_ordered_cleanup_tasks(self, *tasks: Performable) -> Self:
Expand All @@ -85,13 +85,13 @@ def has_ordered_cleanup_tasks(self, *tasks: Performable) -> Self:
and will be discarded.
Aliases:
* :meth:`~screenpy.actor.Actor.with_ordered_cleanup_tasks`
* :meth:`with_ordered_cleanup_tasks`
"""
self.ordered_cleanup_tasks.extend(tasks)
return self

def with_ordered_cleanup_tasks(self, *tasks: Performable) -> Self:
"""Alias for :meth:`~screenpy.actor.Actor.has_ordered_cleanup_tasks`."""
"""Alias for :meth:`has_ordered_cleanup_tasks`."""
return self.has_ordered_cleanup_tasks(*tasks)

def has_independent_cleanup_tasks(self, *tasks: Performable) -> Self:
Expand All @@ -102,13 +102,13 @@ def has_independent_cleanup_tasks(self, *tasks: Performable) -> Self:
previous ones were successful.
Aliases:
* :meth:`~screenpy.actor.Actor.with_independent_cleanup_tasks`
* :meth:`with_independent_cleanup_tasks`
"""
self.independent_cleanup_tasks.extend(tasks)
return self

def with_independent_cleanup_tasks(self, *tasks: Performable) -> Self:
"""Alias for :meth:`~screenpy.actor.Actor.has_independent_cleanup_tasks`."""
"""Alias for :meth:`has_independent_cleanup_tasks`."""
return self.has_independent_cleanup_tasks(*tasks)

def uses_ability_to(self, ability: type[T_Ability]) -> T_Ability:
Expand All @@ -118,7 +118,7 @@ def uses_ability_to(self, ability: type[T_Ability]) -> T_Ability:
UnableToPerform: the Actor doesn't possess the Ability.
Aliases:
* :meth:`~screenpy.actor.Actor.ability_to`
* :meth:`ability_to`
"""
for a in self.abilities:
if isinstance(a, ability):
Expand All @@ -128,7 +128,7 @@ def uses_ability_to(self, ability: type[T_Ability]) -> T_Ability:
raise UnableToPerform(msg)

def ability_to(self, ability: type[T_Ability]) -> T_Ability:
"""Alias for :meth:`~screenpy.actor.Actor.uses_ability_to`."""
"""Alias for :meth:`uses_ability_to`."""
return self.uses_ability_to(ability)

def has_ability_to(self, ability: type[T_Ability]) -> bool:
Expand All @@ -144,58 +144,58 @@ def attempts_to(self, *actions: Performable) -> None:
"""Perform a list of Actions, one after the other.
Aliases:
* :meth:`~screenpy.actor.Actor.was_able_to`
* :meth:`~screenpy.actor.Actor.should`
* :meth:`~screenpy.actor.Actor.shall`
* :meth:`~screenpy.actor.Actor.will`
* :meth:`~screenpy.actor.Actor.tries_to`
* :meth:`~screenpy.actor.Actor.tried_to`
* :meth:`~screenpy.actor.Actor.tries`
* :meth:`~screenpy.actor.Actor.tried`
* :meth:`~screenpy.actor.Actor.does`
* :meth:`~screenpy.actor.Actor.did`
* :meth:`was_able_to`
* :meth:`did`
* :meth:`will`
* :meth:`tries_to`
* :meth:`tried_to`
* :meth:`tries`
* :meth:`tried`
* :meth:`does`
* :meth:`should`
* :meth:`shall`
"""
for action in actions:
self.perform(action)

def was_able_to(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def tries_to(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def tried_to(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def tries(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def tried(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def does(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def did(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def will(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def shall(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def should(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def perform(self, action: Performable) -> None:
Expand Down Expand Up @@ -234,29 +234,29 @@ def exit(self) -> None:
"""Direct the Actor to forget all their Abilities.
Aliases:
* :meth:`~screenpy.actor.Actor.exit_stage_left`
* :meth:`~screenpy.actor.Actor.exit_stage_right`
* :meth:`~screenpy.actor.Actor.exit_through_vomitorium`
* :meth:`exit_stage_left`
* :meth:`exit_stage_right`
* :meth:`exit_through_vomitorium`
"""
self.cleans_up()
for ability in self.abilities:
ability.forget()
self.abilities = []

def exit_stage_left(self) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.exit`."""
"""Alias for :meth:`exit`."""
return self.exit()

def exit_stage_right(self) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.exit`."""
"""Alias for :meth:`exit`."""
return self.exit()

def exit_through_vomitorium(self) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.exit`."""
"""Alias for :meth:`exit`."""
return self.exit()

def __call__(self, *actions: Performable) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.attempts_to`."""
"""Alias for :meth:`attempts_to`."""
return self.attempts_to(*actions)

def __repr__(self) -> str:
Expand Down

0 comments on commit dd6b4ae

Please sign in to comment.