Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nbcourse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matthieu Boileau
nbcourse
Commits
b76c32b0
Commit
b76c32b0
authored
5 years ago
by
Matthieu Boileau
Browse files
Options
Downloads
Patches
Plain Diff
Various fixes
parent
6cda94e3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
nbcourse/book.py
+4
-4
4 additions, 4 deletions
nbcourse/book.py
nbcourse/nbcourse.py
+35
-16
35 additions, 16 deletions
nbcourse/nbcourse.py
skeleton/nbcourse.yml
+2
-0
2 additions, 0 deletions
skeleton/nbcourse.yml
with
41 additions
and
20 deletions
nbcourse/book.py
+
4
−
4
View file @
b76c32b0
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
nbcourse/nbcourse.py
+
35
−
16
View file @
b76c32b0
...
...
@@ -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_file
s
,
'
file_dep
'
:
dep
s
,
'
task_dep
'
:
[
'
copy_material
'
],
'
targets
'
:
self
.
html_pages
,
'
clean
'
:
True
,
...
...
@@ -315,17 +326,25 @@ class NbCourse:
def
task_build_book
(
self
):
"""
Build pdf book
"""
if
self
.
book
:
return
{
'
file_dep
'
:
self
.
executed_notebooks
,
'
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
],
...
...
This diff is collapsed.
Click to expand it.
skeleton/nbcourse.yml
+
2
−
0
View file @
b76c32b0
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment