Commit f65ad111 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Fix #15

parent a679eec4
......@@ -34,7 +34,7 @@ class NbCourse:
},
'nb': {
'dir': 'notebooks',
'material': ('fig', 'exos')
'material': ()
},
'pages': {
'dir': 'pages',
......@@ -99,7 +99,7 @@ class NbCourse:
self.material = [] # additional material (pictures, etc.)
self.chapter_zips = []
self.executed_notebooks = [self.get_executed_notebook(notebook)
self.executed_notebooks = [self._get_executed_nb_path(notebook)
for notebook in self.notebooks]
self.zip_file = self.conf['output_path'] / \
Path(self.conf['slug_title']).with_suffix('.zip')
......@@ -228,14 +228,14 @@ class NbCourse:
with open(executed_notebook, 'w', encoding='utf-8') as f:
nbformat.write(nb, f)
def get_executed_notebook(self, notebook) -> Path:
def _get_executed_nb_path(self, notebook) -> Path:
"""Return executed notebook path"""
return self.conf['output_path'] / Path(notebook.name)
def task_execute_notebooks(self):
"""Write executed notebooks to output directory"""
for notebook in self.notebooks:
executed_notebook = self.get_executed_notebook(notebook)
executed_notebook = self._get_executed_nb_path(notebook)
yield {
'name': executed_notebook,
'file_dep': [notebook],
......@@ -250,6 +250,7 @@ class NbCourse:
output_file: Path,
to='html'):
"""Convert notebook to output_file"""
log.debug(f"Converting {notebook} to {output_file}")
if to == 'slide':
exporter = self.slide_exporter
else:
......@@ -266,7 +267,7 @@ class NbCourse:
def task_convert_to_html(self):
"""Convert executed notebook to html page"""
for notebook in self.notebooks:
executed_notebook = self.get_executed_notebook(notebook)
executed_notebook = self._get_executed_nb_path(notebook)
html = executed_notebook.with_suffix('.html')
self.htmls.append(html)
yield {
......@@ -274,13 +275,14 @@ class NbCourse:
'file_dep': [executed_notebook],
'targets': [html],
'clean': True,
'actions': [(self.convert_notebook, (notebook, html))],
'actions': [(self.convert_notebook,
(executed_notebook, html))],
}
def task_convert_to_slides(self):
"""Convert executed notebook to reveal slides"""
for notebook in self.notebooks:
executed_notebook = self.get_executed_notebook(notebook)
executed_notebook = self._get_executed_nb_path(notebook)
slide = executed_notebook.with_suffix('.slides.html')
self.slides.append(slide)
yield {
......@@ -290,14 +292,14 @@ class NbCourse:
'targets': [slide],
'clean': True,
'actions': [(self.convert_notebook,
(notebook, slide, 'slide'))],
(executed_notebook, slide, 'slide'))],
}
def task_zip_chapters(self):
"""Build zip archives for single chapter downloads"""
for notebook in self.notebooks:
zip_file = self.get_executed_notebook(notebook).with_suffix('.zip')
zip_file = self._get_executed_nb_path(notebook).with_suffix('.zip')
paths_to_zip = [notebook]
for path in self.conf['nb']['material_paths']:
paths_to_zip += get_file_list(path, relative=False)
......
......@@ -4,7 +4,7 @@ subtitle: Master Communication Scientifique, 2019-2020
favicon: fig/favicon.ico
book:
title: cours-python.pdf
picture:
picture:
path: fig/python-logo_full.png
width: 300px
alt: Logo Python
......@@ -50,3 +50,8 @@ license:
path: img/by-sa.svg
width: 70px
local_reveal: True
nb:
dir: notebooks
material:
- fig
- exos
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment