Skip to content

Commit

Permalink
fix inline examples
Browse files Browse the repository at this point in the history
  • Loading branch information
abe-101 committed Dec 10, 2024
1 parent 804ab52 commit 87d90b4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/icalendar/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,14 @@ def from_file(cls, file: Union[str, Path], multiple: bool = False):
Example:
>>> from icalendar import Calendar
>>> from pathlib import Path
>>> # Read a calendar file
>>> cal = Calendar.from_file("src/icalendar/tests/calendars/example.ics")
>>> # Read multiple calendars
>>> cals = Calendar.from_file("src/icalendar/tests/calendars/multiple_calendar_components.ics", multiple=True)
>>> # or pass a Path object
>>> path = Path("src/icalendar/tests/calendars/example.ics")
>>> cal = Calendar.from_file(path)
"""
# Handle string path by converting to Path
if isinstance(file, str):
Expand All @@ -637,15 +641,13 @@ def to_file(self, file: Union[str, Path], sorted: bool = True) -> None:
sorted: Whether parameters and properties should be lexicographically sorted.
Example:
>>> from icalendar import Calendar
>>> from pathlib import Path
>>> # Read a calendar file
>>> cal = Calendar.from_file("src/icalendar/tests/calendars/example.ics")
>>> # or pass a Path object
>>> path = Path("src/icalendar/tests/calendars/example.ics")
>>> cal = Calendar.from_file(path)
>>> # Read multiple calendars
>>> cals = Calendar.from_file("src/icalendar/tests/calendars/multiple_calendar_components.ics", multiple=True)
>>> from icalendar import Calendar, Event
>>> # Write a calendar
>>> cal = Calendar()
>>> cal.to_file("calendar.ics")
>>> # Write an event
>>> event = Event()
>>> event.to_file("event.ics")
"""

Expand Down

0 comments on commit 87d90b4

Please sign in to comment.