add more detail to the ics output files

Put the titles of the cross-project events in the summary of the
calendar event so they show up in the main calendar view.

Add the full descriptions of the cross-project events to the calendar
event description so any extra notes (such as specific dates for
deadlines) or details about the event are visible to calendar users.

Change-Id: I6eebcdd827241f008522065a40b765b2089e2856
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann
2017-01-04 17:22:01 -05:00
parent 82a98d7f51
commit 571083b0d5

View File

@@ -6,9 +6,7 @@ import os.path
from docutils.io import FileOutput
from docutils import nodes
from docutils.parsers import rst
from docutils.statemachine import ViewList
import icalendar
from sphinx.util.nodes import nested_parse_with_titles
import yaml
@@ -89,19 +87,7 @@ def doctree_resolved(app, doctree, docname):
event = icalendar.Event()
event.add('summary', week['name'])
start = datetime.datetime.strptime(week['start'], '%Y-%m-%d')
event.add('dtstart', icalendar.vDate(start.date()))
# NOTE(dhellmann): ical assumes a time of midnight, so in
# order to have the event span the final day of the week
# we have to add an extra day.
raw_end = datetime.datetime.strptime(week['end'], '%Y-%m-%d')
end = raw_end + datetime.timedelta(days=1)
event.add('dtend', icalendar.vDate(end.date()))
description = []
summary = []
for item in week.get('x-project', []):
try:
# Look up the cross-reference name to get the
@@ -115,9 +101,32 @@ def doctree_resolved(app, doctree, docname):
# fail.
app.info('could not get title for {}: {}'.format(item, e))
title = item
description.append(title)
summary.append(title)
if summary:
summary_text = ' (' + '; '.join(summary) + ')'
else:
summary_text = ''
event.add('summary', week['name'] + summary_text)
start = datetime.datetime.strptime(week['start'], '%Y-%m-%d')
event.add('dtstart', icalendar.vDate(start.date()))
# NOTE(dhellmann): ical assumes a time of midnight, so in
# order to have the event span the final day of the week
# we have to add an extra day.
raw_end = datetime.datetime.strptime(week['end'], '%Y-%m-%d')
end = raw_end + datetime.timedelta(days=1)
event.add('dtend', icalendar.vDate(end.date()))
# Look up the cross-reference name to get the
# section, then add the full description to the
# text.
description = [
doctree.ids[item].astext()
for item in week.get('x-project', [])
]
if description:
event.add('description', ', '.join(description))
event.add('description', '\n\n'.join(description))
cal.add_component(event)