|
1 | | -# Ray Enablement Content |
| 1 | +# Ray Enablement Content: Jupyter Book Publishing |
| 2 | + |
| 3 | +This project provides a robust workflow for publishing Jupyter notebooks as a clean, embeddable Jupyter Book website. It automatically splits large notebooks into smaller sections, generates a navigation index, and applies a minimalist, content-focused style suitable for embedding or sharing. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Automatic notebook splitting**: Each notebook is split into parts at every second-level markdown header (`##`). |
| 8 | +- **Navigation index**: An `index.md` is generated with links to all notebook parts, serving as the landing page. |
| 9 | +- **Minimalist UI**: All navigation, sidebars, footers, and theme switchers are hidden by default. Light mode is always enforced. |
| 10 | +- **No code execution**: Notebooks are never executed during build, and all outputs are cleared in the published site. |
| 11 | +- **Easy local preview**: Build and serve the book locally for testing. |
| 12 | +- **GitHub Pages deployment**: The book is automatically published to GitHub Pages. |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +1. **Clone the repository** |
| 17 | + |
| 18 | +```bash |
| 19 | +# Clone your fork or the main repo |
| 20 | +git clone https://github.com/maxpumperla/enablement-content.git |
| 21 | +cd enablement-content |
| 22 | +``` |
| 23 | + |
| 24 | +2. **Set up a virtual environment (recommended)** |
| 25 | + |
| 26 | +```bash |
| 27 | +python3 -m venv venv |
| 28 | +source venv/bin/activate |
| 29 | +``` |
| 30 | + |
| 31 | +3. **Install dependencies** |
| 32 | + |
| 33 | +```bash |
| 34 | +pip install -r requirements.txt |
| 35 | +# Or, if you want to build/serve locally: |
| 36 | +pip install jupyter-book pyyaml |
| 37 | +``` |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +### 1. Split Notebooks and Generate Navigation |
| 42 | + |
| 43 | +Run the split script to: |
| 44 | +- Split all notebooks in `courses/` into parts (by `##` header) |
| 45 | +- Update `_toc.yml` and generate `index.md` with links to all parts |
| 46 | + |
| 47 | +```bash |
| 48 | +python split_notebooks.py |
| 49 | +``` |
| 50 | + |
| 51 | +### 2. Build the Book |
| 52 | + |
| 53 | +```bash |
| 54 | +jupyter-book build . |
| 55 | +``` |
| 56 | + |
| 57 | +### 3. Serve Locally for Testing |
| 58 | + |
| 59 | +```bash |
| 60 | +cd _build/html |
| 61 | +python -m http.server 8000 |
| 62 | +``` |
| 63 | +Then open [http://localhost:8000/](http://localhost:8000/) in your browser. |
| 64 | + |
| 65 | +## Customization |
| 66 | + |
| 67 | +- **Styling**: Place custom CSS/JS in the `_static/` directory (e.g., `_static/custom_hide.css`, `_static/custom_light.js`). These files are automatically included in the built site. |
| 68 | +- **Light mode**: Enforced via custom JS in `_static/custom_light.js`. |
| 69 | +- **Navigation**: All navigation, sidebars, and footers are hidden via custom CSS. |
| 70 | + |
| 71 | +## Disabling Notebook Execution and Outputs |
| 72 | + |
| 73 | +Notebook execution is disabled and all outputs are cleared in the built site via `_config.yml`: |
| 74 | + |
| 75 | +```yaml |
| 76 | +jupyter_execute_notebooks: "off" |
| 77 | +execute: |
| 78 | + execute_notebooks: "off" |
| 79 | + remove_code_outputs: true |
| 80 | +``` |
| 81 | +
|
| 82 | +## Adding New Notebooks or Courses |
| 83 | +
|
| 84 | +- Place new notebooks in a subdirectory of `courses/` (e.g., `courses/my-course/`). |
| 85 | +- Run `python split_notebooks.py` to split and index them. |
| 86 | +- Rebuild the book. |
| 87 | + |
| 88 | +## How Navigation Works |
| 89 | + |
| 90 | +- The `split_notebooks.py` script updates `_toc.yml` and generates `index.md`. |
| 91 | +- `index.md` is the landing page and contains links to all notebook parts. |
| 92 | +- All links are relative, so the site works both locally and on GitHub Pages. |
| 93 | + |
| 94 | +## Publishing |
| 95 | + |
| 96 | +- The book is automatically published to GitHub Pages at: |
| 97 | + - `https://<your-username>.github.io/<your-repo>/` |
| 98 | +- Make sure GitHub Pages is enabled in your repo settings (source: `gh-pages` branch). |
| 99 | + |
| 100 | +## Example Workflow |
| 101 | + |
| 102 | +```bash |
| 103 | +# 1. Split and index notebooks |
| 104 | +python split_notebooks.py |
| 105 | +
|
| 106 | +# 2. Build the book |
| 107 | +jupyter-book build . |
| 108 | +
|
| 109 | +# 3. Serve locally |
| 110 | +cd _build/html |
| 111 | +python -m http.server 8000 |
| 112 | +``` |
0 commit comments