|
| 1 | +# Making your own executable book |
| 2 | + |
| 3 | +```{warning} |
| 4 | + This notebook is a work in progress. This is based on `Jupyter Book 2.0` which is currently in alpha, meaning that |
| 5 | + it might change considerably before release. |
| 6 | +``` |
| 7 | + |
| 8 | +```{seealso} |
| 9 | + - Jupyter book: https://next.jupyterbook.org |
| 10 | + - MyST: https://mystmd.org/guide/ |
| 11 | +``` |
| 12 | + |
| 13 | +## Dependencies |
| 14 | + |
| 15 | +Remember to set a `venv` first. The Python policies are becoming evermore stringent in this regard. |
| 16 | + |
| 17 | +```commandline |
| 18 | +python -m venv venv |
| 19 | +source venv/bin/activate |
| 20 | +``` |
| 21 | + |
| 22 | +Installation can be done as follows. |
| 23 | + |
| 24 | +```{important} |
| 25 | + The `--pre` flag is important while this version is not released. |
| 26 | +``` |
| 27 | + |
| 28 | +```commandline |
| 29 | +python -m pip install jupyter-book --pre |
| 30 | +``` |
| 31 | + |
| 32 | +## Cloning or downloading the repository |
| 33 | + |
| 34 | +To clone, please use the usual. |
| 35 | + |
| 36 | +```commandline |
| 37 | +git clone https://github.com/MarinhoLab/OpenExecutableBooksRobotics.git |
| 38 | +``` |
| 39 | + |
| 40 | +Further, the package can be downloaded from [here](https://github.com/MarinhoLab/OpenExecutableBooksRobotics/archive/refs/heads/main.zip). |
| 41 | + |
| 42 | +## Building the book |
| 43 | + |
| 44 | +### Live document |
| 45 | + |
| 46 | +```commandline |
| 47 | +jupyter book start |
| 48 | +``` |
| 49 | + |
| 50 | +Then click on the link, output below |
| 51 | + |
| 52 | +``` |
| 53 | + ✨✨✨ Starting Book Theme ✨✨✨ |
| 54 | +
|
| 55 | +
|
| 56 | +
|
| 57 | +🔌 Server started on port 3000! 🥳 🎉 |
| 58 | +
|
| 59 | +
|
| 60 | + 👉 http://localhost:3000 👈 |
| 61 | +
|
| 62 | +``` |
| 63 | + |
| 64 | +which usually, as described, connects to `http://localhost:3000`. |
| 65 | + |
| 66 | +### Building the HTML |
| 67 | + |
| 68 | +``` |
| 69 | +jupyter book build --html |
| 70 | +``` |
| 71 | + |
| 72 | +If needed, the page can be opened at `_build/html/index.html`. |
| 73 | + |
| 74 | +## Notebook configuration |
| 75 | + |
| 76 | +In this version of jupyter notebook, `myst.yml` is the soul of the book. It is very uncommon that `conf.py` is needed. |
| 77 | + |
| 78 | +```{literalinclude} myst.yml |
| 79 | +``` |
| 80 | + |
| 81 | +Everything in `myst.yml` is standard, aside from the following block. |
| 82 | + |
| 83 | +```{literalinclude} myst.yml |
| 84 | +:start-at: #USING DQROBOTICS DEVEL [START] |
| 85 | +:end-at: #USING DQROBOTICS DEVEL [END] |
| 86 | +``` |
| 87 | + |
| 88 | +This is a temporary solution to address notebooks that do not play well together. Currently, a jupyter book spawns one process |
| 89 | +of each notebook and results can be nondeterministic if notebooks can affect each other. More information can be seen |
| 90 | +[here](https://github.com/jupyter-book/mystmd/issues/1794). |
| 91 | + |
| 92 | +I'm combining that block with a simple use of `sed` to guarantee the initial lessons that use the stable version of `dqrobotics` |
| 93 | +run before lessons that need the development version of `dqrobotics.` For more information, see the file below. |
| 94 | + |
| 95 | +```{literalinclude} build_html.sh |
| 96 | +``` |
| 97 | + |
| 98 | +We currently only need `conf.py` below for math commands in MySt documents. |
| 99 | + |
| 100 | +```{literalinclude} conf.py |
| 101 | +``` |
| 102 | + |
| 103 | +## Deployment in GitHub |
| 104 | + |
| 105 | +```{important} |
| 106 | + It is very common for GitHub Actions to change how it works internally. This can affect, for instance, the version of the |
| 107 | + images run by the GitHub Actions runners, how GitHub Pages works, or how artifact upload works. If the workflow mentioned |
| 108 | + herein no longer works in the future, it is important to look at initially newer versions of the imported actions. |
| 109 | + Currently: |
| 110 | + - `actions/checkout@v4` |
| 111 | + - `actions/upload-pages-artifact@v3` |
| 112 | + - `actions/configure-pages@v4` |
| 113 | + - `actions/deploy-pages@v4` |
| 114 | +``` |
| 115 | + |
| 116 | +This workflow is straightforward and effective. The only external action needed is to set, in your repository, |
| 117 | +`⚙Settings > Pages > Build and deployment > Source > GitHub Actions`. |
| 118 | + |
| 119 | + |
| 120 | +```{literalinclude} .github/workflows/notebook_to_html.yml |
| 121 | +``` |
| 122 | + |
| 123 | + |
0 commit comments