Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary paths from Sphinx directives. #132

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions docs/api/actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,30 @@ Debug
.. autoclass:: Debug
:members:

Either
------

**Aliases**: ``Attempt``,
``AttemptTo``,
``GoFor``,
``Try``
``TryTo``,
``Attempts``,
``AttemptsTo``,
``GoesFor``,
``Tries``,
``TriesTo``

.. autoclass:: Either
:members:
:exclude-members: except_, else_, otherwise, alternatively, failing_that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my knowledge; what does this do?

Copy link
Member Author

@perrygoy perrygoy Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tells autodoc-sphinx to not add these methods to the auto-generated documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are the aliases of the original method, so it will just say the same thing N times, which is very confusing to read in my opinion. We document the aliases in the docstring of the original, so they will show. Here's what it looks like now:
Screenshot 2024-02-22 at 1 15 28 AM
here's what it looks like after the PR:
Screenshot 2024-02-22 at 1 16 10 AM


Eventually
----------

.. autoclass:: Eventually
:members:
:exclude-members: trying_for_no_longer_than, trying_for, waiting_for, polling_every, trying_every

Log
---
Expand All @@ -45,6 +64,7 @@ MakeNote

.. autoclass:: MakeNote
:members:
:exclude-members: of_the

Pause
-----
Expand All @@ -55,6 +75,7 @@ Pause

.. autoclass:: Pause
:members:
:exclude-members: second_because,

See
---
Expand Down Expand Up @@ -112,21 +133,3 @@ Silently
**Aliases**: ``Quietly``

.. autofunction:: Silently


Either
------

**Aliases**: ``Attempt``,
``AttemptTo``,
``GoFor``,
``Try``
``TryTo``,
``Attempts``,
``AttemptsTo``,
``GoesFor``,
``Tries``,
``TriesTo``

.. autoclass:: Either
:members:
7 changes: 7 additions & 0 deletions docs/api/actors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ Actor API

.. autoclass:: screenpy.actor.Actor
:members:
:exclude-members:
can,
with_ordered_cleanup_tasks, with_independent_cleanup_tasks,
ability_to,
was_able_to, did, will, tries_to, tried_to, tries, tried, does, should, shall
perform,
exit_stage_left, exit_stage_right, exit_through_vomitorium
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`
* ``except_``
* ``else_``
* ``otherwise``
* ``alternatively``
* ``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,)
30 changes: 7 additions & 23 deletions screenpy/actions/eventually.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,41 +81,25 @@ 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`
* ``trying_for_no_longer_than``
* ``trying_for``
* ``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_`."""
return self.for_(amount)

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

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

def polling(self, amount: float) -> _TimeframeBuilder:
"""Adjust the polling frequency.

Aliases:
* :meth:`~screenpy.actions.Eventually.polling_every`
* :meth:`~screenpy.actions.Eventually.trying_every`
* ``polling_every``
* ``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`."""
return self.polling(amount)

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

def describe(self) -> str:
"""Describe the Action in present tense."""
Expand Down
7 changes: 2 additions & 5 deletions screenpy/actions/make_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ def of(cls, question: T_Q) -> Self:
"""Supply the Question to answer and its arguments.

Aliases:
* :meth:`~screenpy.actions.MakeNote.of_the`
* ``of_the``
"""
return cls(question)

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

def as_(self, key: str) -> Self:
"""Set the key to use to recall this noted value."""
Expand Down
6 changes: 2 additions & 4 deletions screenpy/actions/pause.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ def seconds_because(self, reason: str) -> Self:
"""Use seconds and provide a reason for the pause.

Aliases:
* :meth:`~screenpy.actions.Pause.second_because`
* ``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`."""
return self.seconds_because(reason)
second_because = seconds_because

def milliseconds_because(self, reason: str) -> Self:
"""Use milliseconds and provide a reason for the pause."""
Expand Down
Loading
Loading