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 news/1072.documentation.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Converted the :meth:`~icalendar.prop.factory.TypesFactory.to_ical` docstring to Google style, including Parameters and Returns sections. I used an AI assistant (Grok Bot) to help identify a function whose docstring was not yet in Google style and was not already covered by an open pull request, draft the wording, and prepare this changelog entry. @sneha-shukla-dev
15 changes: 13 additions & 2 deletions src/icalendar/prop/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,19 @@ def default_value_type(self, name: str) -> str:
return self[internal].default_value.lower()

def to_ical(self, name, value):
"""Encodes a named value from a primitive python type to an icalendar
encoded string.
"""Encode a named value from a Python object into iCalendar bytes.

Looks up the value type for ``name`` with :meth:`for_property` and
returns that type's iCalendar encoding of ``value``.

Parameters:
name: The iCalendar property or parameter name, for example
``"SUMMARY"`` or ``"DURATION"``.
value: A Python value accepted by the corresponding value type,
for example a :class:`str` or :class:`~datetime.timedelta`.

Returns:
The iCalendar-encoded value as :class:`bytes`.
"""
type_class = self.for_property(name)
return type_class(value).to_ical()
Expand Down