from-python-to-numpy icon indicating copy to clipboard operation
from-python-to-numpy copied to clipboard

Add jupyter book version

Open lhoupert opened this issue 4 years ago • 6 comments

As promised in https://github.com/rougier/from-python-to-numpy/issues/95 , I am proposing a jupyter-book version of the book. To generate the jupyter-book, I added a _config.yml and _toc.yml files. Then it is relatively straightforward to build the book.

Essentially:

  1. Install the most up to date version of jupyter-book:
pip install git+https://github.com/executablebooks/jupyter-book
  1. Go to the root directory of the repository and run:
jupyter-book build . --path-output jupyter-book/.
  1. Open Jupyter-book at jupyter-book/_build/html/index.html

Pdf version of the jupyter-book

It is also possible to use jupyter-book to generate a pdf version of the book, which could interest https://github.com/rougier/from-python-to-numpy/issues/99 . To do that you need to:

  1. Install pyppeteer

  2. Go to the root directory of the repository and run:

jupyter-book build . --builder pdfhtml --path-output jupyter-book/.   
  1. Open jupyter-book/_build/pdf/book.pdf

lhoupert avatar May 05 '21 13:05 lhoupert

Deploying the book as an html website, is also relatively straightforward. I tested it on my website.

I first, created a new repository, then I copy the content of the _build/html directory and then I use the ghp-import package following instructions on the jupyter-book website (https://jupyterbook.org/start/publish.html).

The test repository I created can be seen here: https://github.com/lhoupert/test-jbook and the book can be seen online here: https://lhoupert.fr/test-jbook/book.html

lhoupert avatar May 05 '21 13:05 lhoupert

Impressive! Many thanks. Maybe you can add your name in the preface with a new section About the Jupyer notebook and explaining you did the conversion for notebook and PDF.

Currently, the HTML displays some glitches (probably because of fonts) and movies are not rendered. Any idea?

Should I merge now and you'll open a new PR if needed or do you prefer I wait?

rougier avatar May 15 '21 07:05 rougier

Hello @rougier , yes good idea. I will do that later this week and also try to see why the movies are not rendered. Do you have any example of glitches ?

lhoupert avatar May 17 '21 07:05 lhoupert

In factn the only "glitch" is mostly the front page at https://lhoupert.fr/test-jbook/book.html. The copyright notice is too big compared to the title. By the way, you could also add your name/copyright on the front page for the ebook/jupyter conversion.

rougier avatar May 19 '21 06:05 rougier

I fixed the gliches :-) For the video, I just copied again the data folder into the folder with the html/ build. I think the relative links were not recognized when inserting raw html block in the rst files?

Anyway I think it is good practice to have a self-contained html folder : it is easier to publish it using Github Pages tools.

A test version can be seen here: https://lhoupert.fr/test-jbook

lhoupert avatar May 20 '21 18:05 lhoupert

@rougier if you want you could create a repository (e.g. from-python-to-numpy-jupyterbook? ) where you copied only the HTML folder from https://github.com/lhoupert/from-python-to-numpy/tree/add-jupyter-book-version/jupyter-book

If you follow the steps indicated here, you should be able to publish it on a custom domain name.

There is certainly a way to integrate this directly to this repository (from-python-to-numpy) using github CI/CD tools but I am less familiar with it.

Let me know what you think is the best. I am also happy to host it on my website, for example at lhoupert.fr/from-python-to-numpy-jupyter-book/

lhoupert avatar May 20 '21 18:05 lhoupert