quickstart

Note

  1. install: jupyter-book library 설치

  2. create: jupyter sample book 생성

  3. build: html 파일 생성

  4. browse: 웹 브라우저로 book 확인

import os

home_dir = os.environ['HOME']
work_dir = home_dir + "/workspace/book_demo"
work_dir
'/home/runner/workspace/book_demo'

1. install

#!pdm add jupyter-book
!pdm show jupyter-book
Hide code cell output
Name:                  jupyter-book                                             
Latest version:        0.15.1                                                   
Latest stable version: 0.15.1                                                   
Installed version:     0.15.1                                                   
Summary:               Build a book with Jupyter Notebooks and Sphinx.          
Requires Python:       >=3.7                                                    
Author:                                                                         
Author email:          Executable Book Project <executablebooks@gmail.com>      
License:                                                                        
Homepage:                                                                       
Project URLs:          Documentation: https://jupyterbook.org                   
                       Funding: https://executablebooks.org                     
                       Homepage: https://executablebooks.org/                   
                       Source: https://github.com/executablebooks/jupyter-book/ 
                       Tracker:                                                 
                       https://github.com/executablebooks/jupyter-book/issues   
Platform:                                                                       
Keywords:              reproducible, science, environments, scholarship,        
                       notebook                                                 

2. create

  • pdm run jb create {폴더명}

  • {폴더명} 안에 관련 파일 생성됨(_config.yml, _toc.yml, intro.md 등)

    • _config.yml: jupyter book 환경 설정 파일

    • _toc.yml: 메뉴 구성 파일

    • intro.md: 메인화면 구성 파일

!tree ./docs -L 1 -l 
./docs  [error opening dir]

0 directories, 0 files

3. build

  • _build 폴더 내 html 파일 생성

Tip

  • 이전 빌드되었던 내용 삭제(_build 폴더 안 내용)

    • pdm run jb clean {폴더명} or pdm run jb build **–all** {폴더명}

  • clean하지 않을 경우 이전 내용이 캐쉬되어 정상적으로 보여지지 않는 경우 존재

!pdm run jb build docs/
Usage: jb build [OPTIONS] PATH_SOURCE
Try 'jb build -h' for help.

Error: Invalid value for 'PATH_SOURCE': Path 'docs/' does not exist.

<참고: build option>

!pdm run jb build --help
Usage: jb build [OPTIONS] PATH_SOURCE

  Convert your book's or page's content to HTML or a PDF.

Options:
  --path-output TEXT              Path to the output artifacts
  --config TEXT                   Path to the YAML configuration file
                                  (default: PATH_SOURCE/_config.yml)
  --toc TEXT                      Path to the Table of Contents YAML file
                                  (default: PATH_SOURCE/_toc.yml)
  -W, --warningiserror            Error on warnings.
  -n, --nitpick                   Run in nit-picky mode, to generates warnings
                                  for all missing references.
  --keep-going                    With -W, do not stop the build on the first
                                  warning, instead error on build completion
  --all                           Re-build all pages. The default is to only
                                  re-build pages that are new/changed since
                                  the last run.
  --builder [html|dirhtml|singlehtml|pdfhtml|latex|pdflatex|linkcheck|custom]
                                  Which builder to use.
  --custom-builder TEXT           Specify alternative builder provided by
                                  Sphinx, including text and epub. This can
                                  only be used with --builder=custom. Valid
                                  options listed at https://www.sphinx-
                                  doc.org/en/master/man/sphinx-build.html
  -v, --verbose                   increase verbosity (can be repeated)
  -q, --quiet                     -q means no sphinx status, -qq also turns
                                  off warnings
  --individualpages               [pdflatex] Enable build of PDF files for
                                  each individual page
  -h, --help                      Show this message and exit.

4. browse

  • ‘_build/html/index.html’을 브라우저로 열면 아래 화면 실행

../../_images/jb_02.png
  • 아래는 github pages로 호스팅

from IPython.display import IFrame
IFrame(src='https://gritism.github.io/tdc', width=1000, height=600)