Commit 6cce820b authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

New sample (fix #12)

parent 5f24b70c
......@@ -58,15 +58,25 @@ class NbCourse:
}]
}
def __init__(self, config_file: Path = None):
self.config_file = config_file
def __init__(self, user_conf=None):
"""Build from user_conf"""
self.conf = self.default_conf.copy()
if self.config_file:
if type(user_conf) is Path:
# Load user conf as file and update default conf
self.config_file = user_conf
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()
self.config_file = None
if type(user_conf) is dict:
# Load user conf as dict and update default conf
update_dict(self.conf, user_conf)
else:
# Only default config is loaded (only useful for tests)
log.debug("Default configuration is used")
self.conf['template_path'] = Path(self.conf['theme']['dir'],
'templates')
for key in 'nb', 'theme':
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction\n",
"\n",
"Link to [another part of this notebook](#Just-a-subheading), and to [chapter 2](02-in-which-we.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for a in range(1, 6):\n",
" print(a, 'squared is', a**2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Just a subheading\n",
"\n",
"Here's some content."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*These sample notebooks are from [bookbook project](https://github.com/takluyver/bookbook).*"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 1
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Part the Second\n",
"\n",
"Cross reference to [subheading in chapter 1](01-introduction.ipynb#Just-a-subheading)."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 1
}
......@@ -7,7 +7,7 @@ import os
from distutils.dir_util import copy_tree
TESTS_PATH = Path(__file__).parent.absolute()
MINI_CONF = {'nb': {'dir': 'sample'}}
@pytest.fixture
def create_project(tmpdir):
......@@ -17,8 +17,8 @@ def create_project(tmpdir):
initialize()
# Create a link to notebooks sample
nb = Path('notebooks')
nb.symlink_to(TESTS_PATH / 'notebooks')
nb = Path('sample')
nb.symlink_to(TESTS_PATH / 'sample')
return p
......@@ -29,7 +29,7 @@ def test_minimal_nbcourse(create_project):
def test_minimal_nbcourse_build_pages(create_project):
course = NbCourse()
course = NbCourse(MINI_CONF)
with pytest.raises(SystemExit):
course.build(["build_pages"])
......@@ -37,6 +37,6 @@ def test_minimal_nbcourse_build_pages(create_project):
@pytest.mark.parametrize('task', get_functions(NbCourse, 'task_(.*)'))
def test_minimal_nbcourse_build(create_project, task):
"""test nbcourse on list of doit tasks returned by get_functions"""
course = NbCourse()
course = NbCourse(MINI_CONF)
with pytest.raises(SystemExit):
course.build(["-n 4", task])
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