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

Various fixes

parent 6cda94e3
......@@ -34,14 +34,14 @@ class BookContext:
class Book:
"""A book to be built with bookbook"""
bookbook_filename = 'bookbook_filename.tex'
def __init__(self, conf):
self.output_path = conf['output_path']
self.project_path = conf['project_path']
self.titlepage_path = conf['pages']['path'] / \
conf['pages']['titlepage']
self.book_title = conf['book_title']
self.bookbook_filename = conf['bookbook_filename']
self.titlepage_path = conf['pages']['path'] / conf['book']['titlepage']
self.book_title = conf['book']['title']
self.template_path = conf['template_path'].as_posix()
def build(self):
......
......@@ -38,10 +38,12 @@ class NbCourse:
},
'pages': {
'dir': 'pages',
'titlepage': 'titlepage.tex',
'home': 'index.html'
},
'bookbook_filename': 'bookbook.tex',
'book': {
'titlepage': 'titlepage.tex',
'title': None,
},
'local_reveal': False,
'slug_title': 'course',
'output_dir': 'build',
......@@ -57,10 +59,11 @@ class NbCourse:
}
def __init__(self, config_file: Path = None):
self.config_file = config_file
self.conf = self.default_conf.copy()
if config_file:
update_dict(self.conf, self._get_user_config(config_file))
self.conf['project_path'] = Path(config_file).absolute().parent
if self.config_file:
update_dict(self.conf, self._get_user_config(self.config_file))
self.conf['project_path'] = self.config_file.absolute().parent
else:
# Only default config is loaded (only useful for tests)
self.conf['project_path'] = Path.cwd()
......@@ -77,10 +80,15 @@ class NbCourse:
if self.conf['local_reveal']:
libdir = Path(sys.argv[0]).parent
self.conf['reveal_path'] = libdir / Path('reveal.js')
self.conf['book_title'] = Path(self.conf['slug_title']).with_suffix(
'.pdf')
self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb'))
self.book = self.conf['output_path'] / self.conf['book_title']
if self.conf['book']['title']:
self.titlepage_path = self.conf['pages']['path'] / \
self.conf['book']['titlepage']
self.book = self.conf['output_path'] / self.conf['book']['title']
else:
self.titlepage_path = None
self.book = None
self.md_page_paths = list(self.conf['pages']['path'].glob('*.md'))
self.html_pages = self._get_pages() # homepage and documentation pages
self.theme_files = [file for file in
......@@ -305,8 +313,11 @@ class NbCourse:
def task_build_pages(self):
"""Build html pages"""
deps = self.md_page_paths + self.theme_files
if self.config_file:
deps.append(self.config_file)
return {
'file_dep': self.md_page_paths + self.theme_files,
'file_dep': deps,
'task_dep': ['copy_material'],
'targets': self.html_pages,
'clean': True,
......@@ -315,17 +326,25 @@ class NbCourse:
def task_build_book(self):
"""Build pdf book"""
return {
'file_dep': self.executed_notebooks,
'targets': [self.book],
'clean': True,
'actions': [self.build_book],
}
if self.book:
return {
'file_dep': self.executed_notebooks + [self.titlepage_path],
'targets': [self.book],
'clean': True,
'actions': [self.build_book],
}
else:
return {
'uptodate': [True],
'actions': []
}
def task_zip_archive(self):
"""Build a single zip archive for all material"""
paths_to_zip = [self.book] + self.executed_notebooks + \
paths_to_zip = self.executed_notebooks + \
self.html_pages + self.htmls + self.slides + self.material
if self.book:
paths_to_zip.append(self.book)
return {
'file_dep': paths_to_zip,
'targets': [self.zip_file],
......
......@@ -2,6 +2,8 @@ title: Apprendre Python pour les sciences
slug_title: cours-python
subtitle: Master Communication Scientifique, 2019-2020
favicon: fig/favicon.ico
book:
title: cours-python.pdf
picture:
path: fig/python-logo_full.png
width: 300px
......
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