Skip to content

Instantly share code, notes, and snippets.

@dapperfu
Created June 10, 2020 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dapperfu/4ed3e8f4a7d8f23852421734d5ef6ae2 to your computer and use it in GitHub Desktop.
Save dapperfu/4ed3e8f4a7d8f23852421734d5ef6ae2 to your computer and use it in GitHub Desktop.
Notebook to Docs.
# Python Bits
VENV = /tmp/Kalman-and-Bayesian-Filters-in-Python
.PHONY: venv
venv: ${VENV}
${VENV}:
@python3.8 -mvenv ${@}
@${VENV}/bin/pip install --upgrade pip setuptools wheel
@${VENV}/bin/pip install --upgrade --requirement requirements.txt
.PHONY: notebook
notebook:
@${VENV}/bin/jupyter-notebook
## Make Documentation
# Generate the README from the Jupyter Notebook.
README.md: README.ipynb
jupyter-nbconvert --ExecutePreprocessor.timeout=600 --execute --to markdown --output=${@} ${<}
.PHONY: clean.docs
clean.docs:
rm -rf docs
# All other documents.
IPYNB:=$(wildcard *.ipynb)
MD:=$(patsubst %.ipynb,docs/markdown/%.md,${IPYNB})
PDF:=$(patsubst %.ipynb,docs/pdf/%.pdf,${IPYNB})
HTML:=$(patsubst %.ipynb,docs/html/%.html,${IPYNB})
.PHONY: docs
docs: ${MD} ${PDF} ${HTML}
docs/markdown/%.md: %.ipynb
mkdir -p `dirname ${@}`
jupyter-nbconvert --ExecutePreprocessor.timeout=600 --execute --to markdown --output=${@} ${<}
docs/pdf/%.pdf: %.ipynb
mkdir -p `dirname ${@}`
-jupyter-nbconvert --ExecutePreprocessor.timeout=600 --execute --to pdf --output=${@} ${<}
docs/html/%.html: %.ipynb
mkdir -p `dirname ${@}`
jupyter-nbconvert --ExecutePreprocessor.timeout=600 --execute --to html --output=${@} ${<}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment