# Rendu
A programmatic presentation generator library for Python

## Introduction

Rendu allows programmatic construction of professional-looking HTML slide decks similar in concept to documents that can be created with presentation software like Microsoft Powerpoint, Apple's Keynote or LibreOffice Impress.

Rendu reports are composed of multiple slides and feature easy navigation via push buttons whose behavior is regulated by javascript code that is automatically generated by the library.

Rendu is particularly useful to create and assemble a slide deck as a final pipeline step in any type of data analysis.

## Main Features

  * Create slide decks programmatically from within Python code
  * Single HTML file, can be rendered by any web browser that supports Javascript
  * Easy slide navigation through push-button HTML widgets
  * Text: supports paragraphs, unordered and ordered lists
  * Images: Embed and display png and jpg
  * Raw Data: embed files within the document, download via push button widget
  * Optimized slide layout divided in main and side area

## Screenshots

![First slide of example in next section](/doc/img/penguins_screenshot_01.png)
![Second slide of example in next section](/doc/img/penguins_screenshot_02.png)
![Third slide of example in next section](/doc/img/penguins_screenshot_03.png)

## Quick Start-Up Reference

The following example uses Pandas and Seaborn to download a dataset, compute some statistics on it and plot a histogram and save data into a CSV file. The dataset analysis is just an example that is used to showcase how to create a Rendu slide deck and add text, plots and even embed the raw CSV file into the final document. The resulting HTML rendering is shown in the screenshots of the previous section.

```python
import os
import seaborn as sns
import matplotlib as mpl
from datetime import date
from rendu.htmldeck import HtmlSlideDeck

# ----------------------------------------------- #
# Use pandas/seaborn to perform some data analysis
# ----------------------------------------------- #
os.makedirs('./tmp', exist_ok=True)
mpl.use('AGG')
penguins = sns.load_dataset('penguins')
fig = sns.displot(penguins, x='flipper_length_mm')
fig.savefig('./tmp/penguins_histogram.png')
flen_ave = penguins.flipper_length_mm.mean().round(2)
flen_med = penguins.flipper_length_mm.median().round(2)
flen_std = penguins.flipper_length_mm.std().round(2)
penguins.to_csv('./tmp/penguins.csv')

# ------------------------------------------------------ #
# Now use rendu to quickly assemble an HTML presentation
# ------------------------------------------------------ #

# Create HTML report
rep = HtmlSlideDeck(f'Analysis Of Penguin Population [{date.today()}]',
                    footer='University Of Penguinia, dept. of Marine Science')

# Add intro slide
s = rep.add_slide(0, "Penguin Study Report", "Intro")
s.main.add_h2('Data Sources')
s.main.add_ul(['Raw data available at seaborn-data repository',
               'https://github.com/mwaskom/seaborn-data'])
s.main.add_h2('Disclaimer')
s.main.add_p('NO PENGUINS WERE HARMED FOR THIS STUDY')
s.side.add_h2('Authors')
s.side.add_ul(['John Doe, PhD', 'Jane Doe, PhD'])

# Add slide with histogram with stats
s = rep.add_slide(1, "Flipper Length Distribution", "Flipper Length")

# Add figure to main layout
s.main.add_figure('./penguins_histogram.png')

# Add more info to side layout
s.side.add_h2('Main Stats')
s.side.add_ul([f'Average: {flen_ave}',
               f'Median: {flen_med}',
               f'Std: {flen_std}'])

# Add slide that embeds raw data
s = rep.add_raw_data_slide(2, "Raw Data", "Raw Data", './tmp/penguins.csv')

# Save report
rep.save('./tmp/penguin_report.html')
```
