Commit 336646de authored by Matthieu Boileau's avatar Matthieu Boileau

Fix some issues

parent adb3627a
......@@ -10,3 +10,4 @@ build/
notebooks/
tests/notebooks
.doit.db.db
.pytest_cache/
\ No newline at end of file
......@@ -7,4 +7,4 @@ test:
script:
- pip install -r requirements.txt
- pip install -r dev_requirements.txt
- pytest -sv
- pytest -v
......@@ -3,7 +3,7 @@ from distutils.dir_util import copy_tree
from pathlib import Path
SKEL_PATH = Path(__file__).absolute().parents[1] / Path("skeleton")
SKEL_PATH = Path(__file__).parents[1] / Path("skeleton")
def initialize():
......
......@@ -7,7 +7,6 @@ Define a NbCourse object containing:
from pathlib import Path, PosixPath
import yaml
import sys
from doit.tools import create_folder, config_changed
from .utils import update_material, clean_tree, get_file_list, update_dict, \
zip_files
......@@ -33,7 +32,7 @@ class NbCourse:
'material': ('css', 'img')
},
'nb': {
'dir': 'notebooks',
'dir': '.',
'material': ()
},
'pages': {
......@@ -78,8 +77,8 @@ class NbCourse:
self.conf['pages']['path'] = Path(self.conf['pages']['dir'])
self.conf['output_path'] = Path(self.conf['output_dir'])
if self.conf['local_reveal']:
libdir = Path(sys.argv[0]).parent
self.conf['reveal_path'] = libdir / Path('reveal.js')
nbcourse_libdir = Path(__file__).parents[1]
self.conf['reveal_path'] = nbcourse_libdir / Path('reveal.js')
self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb'))
if self.conf['book']['file']:
......
../reveal.js
\ No newline at end of file
../skeleton
\ No newline at end of file
......@@ -15,7 +15,7 @@
\vspace*{0.1\textheight}
\centering
\includegraphics{fig/head_of_python_molurus_frame}
\includegraphics{fig/python-logo_full.png}
\vfill
......
......@@ -6,6 +6,8 @@
"source": [
"# Introduction\n",
"\n",
"![Python logo](fig/python-logo_full.png)\n",
"\n",
"Link to [another part of this notebook](#Just-a-subheading), and to [chapter 2](02-in-which-we.ipynb)."
]
},
......
......@@ -6,7 +6,9 @@
"source": [
"# Part the Second\n",
"\n",
"Cross reference to [subheading in chapter 1](01-introduction.ipynb#Just-a-subheading)."
"Cross reference to [subheading in chapter 1](01-introduction.ipynb#Just-a-subheading).\n",
"\n",
"We would like to reference the external python file [helloworld.py](exos/helloworld.py)."
]
}
],
......@@ -44,4 +46,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
}
}
\ No newline at end of file
print("Hello, world!")
title: A sample course
slug_title: sample-course
subtitle: Not very useful
favicon: fig/favicon.ico
book:
file: sample-course.pdf
picture:
path: fig/python-logo_full.png
width: 300px
alt: Logo Python
authors:
- name: Nobody
email: nobody@nowhere.com
chapter_preview_only:
- 2
links:
- title: Manual
target: manual.html
icon:
path: img/Infobox_info_icon.svg
width: 35px
- title: PDF version
target: sample-cours.pdf
icon:
path: img/Adobe_PDF_icon.svg
width: 30px
- title: Complete archive
target: sample-course.zip
icon:
path: img/download.svg
width: 35px
license:
text: Content available under license
target: https://creativecommons.org/licenses/by-sa/4.0/
icon:
path: img/by-sa.svg
width: 70px
local_reveal: True
nb:
dir: 'sample'
material:
- fig
- exos
\ No newline at end of file
import nbcourse
from nbcourse.initialize import initialize
from nbcourse.initialize import initialize, SKEL_PATH
import contextlib
from pathlib import Path
import os
......@@ -8,9 +8,8 @@ import os
def test_initialize(tmpdir):
"""Test if initialize function creates the right project skeleton"""
# Get skeleton content
skeleton_path = Path(nbcourse.__path__[0]) / Path("skeleton")
skeleton_paths = set((path.relative_to(skeleton_path)
for path in skeleton_path.glob('**/*')))
skeleton_paths = set((path.relative_to(SKEL_PATH)
for path in SKEL_PATH.glob('**/*')))
# Create a temporary project dir
p = tmpdir.mkdir("test_project")
......
......@@ -6,6 +6,7 @@ from pathlib import Path
import os
from distutils.dir_util import copy_tree
TESTS_PATH = Path(__file__).parent.absolute()
MINI_CONF = {'nb': {'dir': 'sample'}}
......@@ -17,11 +18,14 @@ def create_project(tmpdir):
os.chdir(p)
initialize()
# Create a link to notebooks sample
# Create a link to sample notebooks
nb = Path('sample')
nb.symlink_to(TESTS_PATH / 'sample')
nb.symlink_to(TESTS_PATH / 'sample', target_is_directory=True)
return p
# Create a link to sample yaml file
yaml_file = Path('nbcourse.yml')
yaml_file.unlink()
yaml_file.symlink_to(TESTS_PATH / 'sample' / 'nbcourse.yml')
def test_minimal_nbcourse(create_project):
......@@ -37,12 +41,12 @@ def test_minimal_nbcourse_build(create_project, task):
def test_nbcourse(create_project):
"""Test sample with nbcourse.yml example file"""
"""Test sample with nbcourse.yml sample file"""
NbCourse(Path('nbcourse.yml'))
@pytest.mark.skip(reason="material directories not available yet")
def test_nbcourse_build(create_project):
"""Test sample build with nbcourse.yml example file"""
"""Test sample build with nbcourse.yml sample file"""
course = NbCourse(Path('nbcourse.yml'))
course.conf['book']
assert course.build(["-n 4"]) == 0
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