Automating Sprint Review Slides with Pandoc
Tags: automation, markdown, pandoc, presentations
Published: 2020-06-12 13:51:45

In the MyCareersFuture team, we conduct sprint reviews at the end of the sprint to showcase what the team has achieved. We use PowerPoint slides to highlight stories that have been done and those which are still being worked on. Preparing this by hand was time-consuming. Here's how we automated the process.

* [Getting Story Data](#getting-story-data)
* [Generating PowerPoint Slides](#generating-powerpoint-slides)
* [Customizing Appearance of Generated Slides](#customizing-appearance-of-generated-slides)
* [Limitations](#limitations)
* [Conclusion](#conclusion)

## Getting Story Data <a name="getting-story-data"></a>

We use Pivotal Tracker for project management. The Pivotal Tracker API returns stories in the current iteration or sprint via the [`/projects/{project_id}/iterations?scope=current_backlog&limit=1`](https://www.pivotaltracker.com/help/api/rest/v5#projects_project_id_iterations_get) API call. The response looks like this:

```json
{
  "finish": "2020-05-19T00:00:00Z",
  "kind": "iteration",
  "start": "2020-05-04T00:00:00Z",
  "stories": [
    {
      "kind": "story",
      "id": 563,
      "created_at": "2020-05-19T12:01:00Z",
      "updated_at": "2020-05-19T12:01:00Z",
      "estimate": 3,
      "story_type": "feature",
      "name": "Complete construction of the Expeditionary Battle Planetoid",
      "description": "Palpatine was impressed with the PoC, make this one bigger",
      "current_state": "accepted",
      // lots more data for this story
    },
    // data for other stories in that sprint
  ]
}
```

## Generating PowerPoint Slides <a name="generating-powerpoint-slides"></a>

Programmatically generating a PowerPoint file isn't for the faint of heart even in a language that has a library for the task. This is where Pandoc comes to the rescue.

[Pandoc](https://pandoc.org/) is an open source tool that converts between almost any markup format that you can think of, including from markdown to PowerPoint. By using the Pivotal API, I wrote a tool that outputs markdown source which Pandoc then converts into the actual slides. Here's what the markdown might look like:

```markdown
---
title: Sprint 63
date: 18 Sep - 02 Oct
---

## Sprint backlog - Done!

*Jobseeker*

* Create a service/API to serve constants to all other modules (5 points)
* change redux code to Typescript for ui-jobseeker
* Populate the content placeholder on the category landing page with the html content (batch 2)
* Implement page title and meta description for category landing page (batch 2)
* Revise content piece, page title and meta description for Risk Management category landing page 

*Employer*

* Add "Employers Toolkit" link in Employer navbar

## Jobseeker - In Progress Features

*Delivered*

* Implement VDP link for MCF jobseeker and make changes to footer

*Finished*

* Implement GA tracking on the recommended jobs on the application confirmation page
* Switch to MCF figures for application count of all jobs
* Include "Search term" in recommender API
* Implement recommended jobs on JD page (getting the jobs from DSAID API)
* Implement data science tracking for view JD page
* Set up company profile page
* Implement data science tracking for the jobs returned on each page of the search page

*Started*

* Change copy for government scheme section on JD page and search results page
* Implement recommended jobs on JD page (frontend)
* Company profile page - jobs section
* Company profile page - About the company section
* Company profile page meta description
* Take contact number and email address from MCF instead of MySF 

## Jobseeker - In Progress Chores

*Started*

* Improve stability of job application tests
* Jobseeker: Cypress Tests for GA calls
```

Saving that to a file named `presentation.md`, the following Pandoc invocation generates `presentation.pptx`:

```sh
pandoc presentation.md -o presentation.pptx --self-contained --reference-doc=template.pptx --slide-level 2
```

When there is too much content to fit into a slide or if ad hoc changes need to be made, the generated markdown and PowerPoint file can be edited afterwards.

![Sprint 63 Title Slide with a main title of Sprint 63 and subtitle 18 Sep - 02 Oct](https://neurrone.com/images/sprint 63 title slide.png)

![Sprint 63 slide for done stories. Refer to the markdown source above for its contents](https://neurrone.com/images/sprint 63 done stories.png)

![Sprint 63 slide for in-progress Jobseeker feature stories. Refer to the markdown source above for its contents](https://neurrone.com/images/sprint 63 jobseeker in progress features.png)

The references to "Jobseeker" and "Employer" are the 2 squads in MCF which implement the jobseeker and employer facing portions of the product respectively.

Here's how markdown's semantics naturally map to slides:

* Lines 2 and 3 in the source above specify metadata about the document, title and date in this case. This is part of Pandoc's support for front matter and causes a title slide to be generated with this information.
* Pandoc was configured to use a slide level of 2. Hence, the level 2 headings are used as slide titles of new slides.
* Text between level 2 headings appear on slides as content. Any markdown formatting there such as lists and emphasis causes the corresponding formatting changes in the output.
* A line with 3 consecutive dashes (`---`) causes a new slide to begin after that point. This isn't used in the example above but is very useful when content needs to be split between slides without creating a title for each slide. Refer to [Pandoc's user guide](https://pandoc.org/MANUAL.html#producing-slide-shows-with-pandoc) for other directives to insert pauses, incremental lists and speaker notes.

## Customizing Appearance of Generated Slides <a name="customizing-appearance-of-generated-slides"></a>

The `--reference-doc=template.pptx` argument instructs Pandoc to use a PowerPoint template which provides some control over layout and formatting. Although Pandoc technically supports using your own templates, Pandoc crashed often when I tried doing so[^crashes-with-non-builtin-templates]. Hence, I recommend exporting a copy of Pandoc's default PowerPoint template and using it as a starting point for customization with the following command:

```sh
# writes Pandoc's default PowerPoint template to template.pptx
pandoc -o template.pptx --print-default-data-file reference.pptx
```

Open this file in PowerPoint and under the view ribbon, activate slide master view.

The first slide is the master slide. Changing the formatting of the title and text at various list levels applies the corresponding formatting when used to generate slides, a poor man's CSS.

<figure>
  <img src="https://neurrone.com/images/slide master.png" alt="The Slide Master for our sprint review slides, which lets you adjust formatting for slide titles and text in list levels 1 through 6">
  <figcaption>Here's the Slide Master for our sprint review slides set to use the Arial font instead of the default Calibri. Notice how this matches with the content slides above.</figcaption>
</figure>

<figure>
  <img src="https://neurrone.com/images/title slide.png" alt="The title slide for our sprint review slides. It can have its main title, subtitle and date placeholder fields customized">
  <figcaption>Similarly, here's our Title Slide layout.</figcaption>
</figure>

## Limitations <a name="limitations"></a>

The format of content was kept as simple as possible - essentially a title and content in lists. Pandoc's PowerPoint writer technically supports a 2-column layout and the use of tables. However, we ran into issues because we could not adequately customize the formatting applied to our needs. For instance, each column in a table could not have different widths causing text to often go offscreen.

Besides PowerPoint, Pandoc also supports creating PDF slides via LaTeX and HTML5 slides via Slideous, Slidy, DZSlides or reveal.js. These formats allow virtually full customization of the generated slides, including the use of JavaScript and CSS for HTML5 presentations.

## Conclusion <a name="conclusion"></a>

We've been automating most of the preparation for our sprint review slides this way for almost a year now, saving an hour each sprint. If you're preparing slides with information from a system that exposes an API or prefer the text editor like I do, I highly recommend trying Pandoc out.

[^crashes-with-non-builtin-templates]: this seems to happen if the template file is not compatible with the set of XML directives Pandoc recognizes for PowerPoint files. For example, Pandoc wouldn't accept the template file from a set of slides prepared with Google Slides.