Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Minor changes
~~~~~~~~~~~~~

- Bump PyPy from 3.10 to 3.11 for testing. :pr:`1383`
- Replaced RFC copy-paste text in docstrings with Pythonic docstrings for calendar components. :pr:`1385`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move this to /news/1244.documentation?

Suggested change
- Replaced RFC copy-paste text in docstrings with Pythonic docstrings for calendar components. :pr:`1385`
- Replaced RFC copy-paste text in docstrings with Pythonic docstrings for calendar components. :issue:`1244`

- Created an :attr:`~icalendar.prop.dt.period.vPeriod.ical_value` property for the :class:`~icalendar.prop.dt.period.vPeriod` component. :issue:`876`

Breaking changes
Expand Down
83 changes: 48 additions & 35 deletions src/icalendar/cal/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,32 +156,29 @@ class Alarm(Component):

ACKNOWLEDGED = single_utc_property(
"ACKNOWLEDGED",
"""This is defined in RFC 9074:

Purpose: This property specifies the UTC date and time at which the
corresponding alarm was last sent or acknowledged.

This property is used to specify when an alarm was last sent or acknowledged.
This allows clients to determine when a pending alarm has been acknowledged
by a calendar user so that any alerts can be dismissed across multiple devices.
It also allows clients to track repeating alarms or alarms on recurring events or
to-dos to ensure that the right number of missed alarms can be tracked.

Clients SHOULD set this property to the current date-time value in UTC
when a calendar user acknowledges a pending alarm. Certain kinds of alarms,
such as email-based alerts, might not provide feedback as to when the calendar user
sees them. For those kinds of alarms, the client SHOULD set this property
when the alarm is triggered and the action is successfully carried out.

When an alarm is triggered on a client, clients can check to see if an "ACKNOWLEDGED"
property is present. If it is, and the value of that property is greater than or
equal to the computed trigger time for the alarm, then the client SHOULD NOT trigger
the alarm. Similarly, if an alarm has been triggered and
an "alert" has been presented to a calendar user, clients can monitor
the iCalendar data to determine whether an "ACKNOWLEDGED" property is added or
changed in the alarm component. If the value of any "ACKNOWLEDGED" property
in the alarm changes and is greater than or equal to the trigger time of the alarm,
then clients SHOULD dismiss or cancel any "alert" presented to the calendar user.
"""The UTC datetime at which this alarm was last sent or acknowledged.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When I looked at the rendered docs, I found that there was a snippet prepended to this docstring. Would you please revise the following:

https://github.com/stevepiercy/icalendar/blob/8c26d2b22ce33c37bd2bfce7997ca240641236ab/src/icalendar/attr.py#L401-L415

Specifically, and possibly wrapped after using make format:

-        f"""The {name} property. datetime in UTC
+        f"""The {name} property with all values converted to a :class:`~datetime.datetime` in UTC.

-    All values will be converted to a datetime in UTC.
+ 

The two blank lines will ensure proper concatenation with a new paragraph to begin the description of the docstring.

Suggested change
"""The UTC datetime at which this alarm was last sent or acknowledged.
"""This property is the UTC datetime at which this alarm was last sent or acknowledged as defined in :rfc:`9074`.


Defined in :rfc:`9074`. Setting this property allows calendar clients to
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moved into previous paragraph.

Suggested change
Defined in :rfc:`9074`. Setting this property allows calendar clients to
Setting this property allows calendar clients to

dismiss or suppress an alarm across multiple devices. Once set to a value
greater than or equal to the alarm's computed trigger time, conforming clients
will not re-fire the alarm.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
will not re-fire the alarm.
will not refire the alarm.


Returns ``None`` when no acknowledgment has been recorded.

Example:
Mark an alarm as acknowledged at the current time.

.. code-block:: pycon

>>> from datetime import timezone, datetime
>>> from icalendar import Alarm
>>> alarm = Alarm()
>>> alarm.ACKNOWLEDGED = datetime(2024, 1, 15, 10, 0, 0, tzinfo=timezone.utc)
>>> alarm.ACKNOWLEDGED # doctest: +ELLIPSIS
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Inline comments don't render. Is the comment necessary?

Suggested change
>>> alarm.ACKNOWLEDGED # doctest: +ELLIPSIS
>>> alarm.ACKNOWLEDGED

datetime.datetime(2024, 1, 15, 10, 0, tzinfo=...)

See also:
:attr:`TRIGGER` — the time at which the alarm fires.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
:attr:`TRIGGER` the time at which the alarm fires.
:attr:`TRIGGER`, the time at which the alarm fires.

""",
)

Expand All @@ -190,17 +187,33 @@ class Alarm(Component):
"dt",
(datetime, timedelta),
timedelta | datetime | None,
"""Purpose: This property specifies when an alarm will trigger.
"""The time at which this alarm fires, per :rfc:`5545#section-3.8.6.3`.

Value Type: The default value type is DURATION. The value type can
be set to a DATE-TIME value type, in which case the value MUST
specify a UTC-formatted DATE-TIME value.
The value is either a :class:`~datetime.timedelta` (relative trigger) or a
UTC :class:`~datetime.datetime` (absolute trigger).

Either a positive or negative duration may be specified for the
"TRIGGER" property. An alarm with a positive duration is
triggered after the associated start or end of the event or to-do.
An alarm with a negative duration is triggered before the
associated start or end of the event or to-do.""",
A negative :class:`~datetime.timedelta` fires *before* the related
component boundary (start or end); a positive one fires *after* it.
Use :attr:`TRIGGER_RELATED` to choose whether the offset is measured from
the start or the end of the parent event or to-do.
An absolute trigger fires at an exact UTC point in time regardless of the
parent component's dates.

Example:
Set an alarm to fire 15 minutes before the start of an event.

.. code-block:: pycon

>>> from datetime import timedelta
>>> from icalendar import Alarm
>>> alarm = Alarm()
>>> alarm.TRIGGER = timedelta(minutes=-15)
>>> alarm.TRIGGER # doctest: +ELLIPSIS
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
>>> alarm.TRIGGER # doctest: +ELLIPSIS
>>> alarm.TRIGGER

datetime.timedelta(...)

See also:
:attr:`TRIGGER_RELATED`, :attr:`DURATION`, :attr:`REPEAT`
""",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This docstring is almost perfect.

However, the property has documentation that gets prepended and appended, as defined in https://github.com/stevepiercy/icalendar/blob/8c26d2b22ce33c37bd2bfce7997ca240641236ab/src/icalendar/attr.py#L958-L966.

Let's clean that up, too.

    p_doc = f"""The {prop} property.

    {doc}

    You can also delete the value with ``del`` or by setting it to ``None``.

    Parameters:
        {", ".join(t.__name__ for t in value_type)}

    Raises:
        InvalidCalendar: if the attribute has invalid values.

    Returns:
        A :class:`~datetime.datetime` or :class:`~datetime.timedelta` if the value is valid. ``None`` if the value is absent.
    """

)

@property
Expand Down
Loading