Skip to content

Commit eb559e1

Browse files
committed
Improve docstring for categories_property per #1244
1 parent c5f7bcb commit eb559e1

2 files changed

Lines changed: 28 additions & 23 deletions

File tree

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Documentation
7070
- Revise AI policy, per NLnet advice. See discussion under `pycal.org issue #24 <https://github.com/pycalendar/pycal.org/issues/24>`_.
7171
- Add documentation for how to use uv for development. :issue:`1102`
7272
- Reorganize Design documentation. :issue:`1292`
73+
- Improve docstring for ``categories_property``, which renders to HTML in :attr:`Calendar.categories <icalendar.cal.calendar.Calendar.categories>`, :attr:`Event.categories <icalendar.cal.event.Event.categories>`, :attr:`Journal.categories <icalendar.cal.journal.Journal.categories>`, and :attr:`Todo.categories <icalendar.cal.todo.Todo.categories>`. :issue:`1244`
7374

7475
7.0.3 (2026-03-03)
7576
------------------

src/icalendar/attr.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -616,27 +616,36 @@ def _del_categories(component: Component) -> None:
616616
_del_categories,
617617
"""This property defines the categories for a component.
618618
619-
Property Parameters:
620-
IANA, non-standard, and language property parameters can be specified on this
621-
property.
619+
The categories property is used to specify categories or subtypes of the
620+
calendar component. The categories are useful to search for a calendar
621+
component of a particular type and category.
622622
623-
Conformance:
624-
The property can be specified within "VEVENT", "VTODO", or "VJOURNAL" calendar
625-
components.
626-
Since :rfc:`7986` it can also be defined on a "VCALENDAR" component.
623+
Within the calendar components, specify categories as a list of strings.
624+
You can get, set, and delete categories for a component.
627625
628-
Description:
629-
This property is used to specify categories or subtypes
630-
of the calendar component. The categories are useful in searching
631-
for a calendar component of a particular type and category.
632-
Within the "VEVENT", "VTODO", or "VJOURNAL" calendar components,
633-
more than one category can be specified as a COMMA-separated list
634-
of categories.
626+
This property can be used in icalendar through its Python attributes of:
627+
628+
- :attr:`Calendar.categories <icalendar.cal.calendar.Calendar.categories>`
629+
- :attr:`Event.categories <icalendar.cal.event.Event.categories>`
630+
- :attr:`Journal.categories <icalendar.cal.journal.Journal.categories>`
631+
- :attr:`Todo.categories <icalendar.cal.todo.Todo.categories>`
632+
633+
The categories property for ``Event``, ``Journal``, and ``Todo`` complies
634+
with :rfc:`5545#section-3.8.1.2`, and for ``Calendar`` with :rfc:`7986#section-5.6`.
635+
636+
Note:
637+
At present, icalendar doesn't take the LANGUAGE parameter as defined
638+
in :rfc:`5545#section-3.2.10` into account.
639+
640+
Parameters:
641+
categories(list[str]): A list of categories as strings.
635642
636643
Example:
637-
Below, we add the categories to an event:
644+
Create an event, add categories to it, print its ical representation,
645+
append another category, and finally compare the result
646+
against its expected value.
638647
639-
.. code-block:: pycon
648+
.. code-block:: pycon
640649
641650
>>> from icalendar import Event
642651
>>> event = Event()
@@ -649,13 +658,8 @@ def _del_categories(component: Component) -> None:
649658
>>> event.categories == ["Work", "Meeting", "Lecture"]
650659
True
651660
652-
.. note::
653-
654-
At present, we do not take the LANGUAGE parameter into account.
655-
656-
.. seealso::
657-
658-
:attr:`Component.concepts`
661+
See also:
662+
:attr:`Component.concepts <icalendar.cal.component.Component.concepts>`
659663
""",
660664
)
661665

0 commit comments

Comments
 (0)