|
| 1 | +SHELL := bash |
| 2 | +# |
| 3 | +# Makefile for Sphinx Extension Test Cases |
| 4 | +# |
| 5 | + |
| 6 | +# You can set these variables from the command line. |
| 7 | +SPHINXOPTS = -c "./" -P |
| 8 | +SPHINXBUILD = python -msphinx |
| 9 | +SPHINXPROJ = lecture-python-programming |
| 10 | +SOURCEDIR = source/rst |
| 11 | +BUILDDIR = _build |
| 12 | +BUILDWEBSITE = _build/website |
| 13 | +BUILDCOVERAGE = _build/coverage |
| 14 | +BUILDPDF = _build/pdf |
| 15 | +PORT = 8890 |
| 16 | +FILES = |
| 17 | +THEMEPATH = theme/minimal |
| 18 | +TEMPLATEPATH = $(THEMEPATH)/templates |
| 19 | + |
| 20 | +# Put it first so that "make" without argument is like "make help". |
| 21 | +help: |
| 22 | + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) |
| 23 | + |
| 24 | +.PHONY: help Makefile |
| 25 | + |
| 26 | +# Install requiremenets for building lectures. |
| 27 | +setup: |
| 28 | + pip install -r requirements.txt |
| 29 | + |
| 30 | +preview: |
| 31 | +ifeq (,$(filter $(target),website Website)) |
| 32 | + cd $(BUILDWEBSITE)/jupyter_html && python -m http.server $(PORT) |
| 33 | +else |
| 34 | +ifdef lecture |
| 35 | + cd $(BUILDDIR)/jupyter/ && jupyter notebook --port $(PORT) --port-retries=0 $(basename $(lecture)).ipynb |
| 36 | +else |
| 37 | + cd $(BUILDDIR)/jupyter/ && jupyter notebook --port $(PORT) --port-retries=0 |
| 38 | +endif |
| 39 | +endif |
| 40 | + |
| 41 | +clean-coverage: |
| 42 | + rm -rf $(BUILDCOVERAGE) |
| 43 | + |
| 44 | +clean-website: |
| 45 | + rm -rf $(BUILDWEBSITE) |
| 46 | + |
| 47 | +clean-pdf: |
| 48 | + rm -rf $(BUILDDIR)/jupyterpdf |
| 49 | + |
| 50 | +coverage: |
| 51 | +ifneq ($(strip $(parallel)),) |
| 52 | + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDCOVERAGE)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_make_coverage=1 -D jupyter_execute_notebooks=1 -D jupyter_ignore_skip_test=0 -D jupyter_theme_path="$(THEMEPATH)" -D jupyter_template_path="$(TEMPLATEPATH)" -D jupyter_template_coverage_file_path="error_report_template.html" -D jupyter_number_workers=$(parallel) |
| 53 | +else |
| 54 | + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDCOVERAGE)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_make_coverage=1 -D jupyter_execute_notebooks=1 -D jupyter_ignore_skip_test=0 -D jupyter_theme_path="$(THEMEPATH)" -D jupyter_template_path="$(TEMPLATEPATH)" -D jupyter_template_coverage_file_path="error_report_template.html" |
| 55 | +endif |
| 56 | + |
| 57 | +website: |
| 58 | + echo "Theme: $(THEMEPATH)" |
| 59 | +ifneq ($(strip $(parallel)),) |
| 60 | + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDWEBSITE)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_make_site=1 -D jupyter_generate_html=1 -D jupyter_download_nb=1 -D jupyter_execute_notebooks=1 -D jupyter_target_html=1 -D jupyter_download_nb_image_urlpath="https://s3-ap-southeast-2.amazonaws.com/python-programming.quantecon.org/_static/" -D jupyter_images_markdown=0 -D jupyter_theme_path="$(THEMEPATH)" -D jupyter_template_path="$(TEMPLATEPATH)" -D jupyter_html_template="html.tpl" -D jupyter_download_nb_urlpath="https://python-programming.quantecon.org/" -D jupyter_coverage_dir=$(BUILDCOVERAGE) -D jupyter_number_workers=$(parallel) |
| 61 | + |
| 62 | +else |
| 63 | + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDWEBSITE)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_make_site=1 -D jupyter_generate_html=1 -D jupyter_download_nb=1 -D jupyter_execute_notebooks=1 -D jupyter_target_html=1 -D jupyter_download_nb_image_urlpath="https://s3-ap-southeast-2.amazonaws.com/python-programming.quantecon.org/_static/" -D jupyter_images_markdown=0 -D jupyter_theme_path="$(THEMEPATH)" -D jupyter_template_path="$(TEMPLATEPATH)" -D jupyter_html_template="html.tpl" -D jupyter_download_nb_urlpath="https://python-programming.quantecon.org/" -D jupyter_coverage_dir=$(BUILDCOVERAGE) |
| 64 | +endif |
| 65 | + |
| 66 | +pdf: |
| 67 | +ifneq ($(strip $(parallel)),) |
| 68 | + @$(SPHINXBUILD) -M jupyterpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_latex_template="latex.tpl" -D jupyter_theme_path="$(THEMEPATH)" -D jupyter_template_path="$(TEMPLATEPATH)" -D jupyter_latex_template_book="latex_book.tpl" -D jupyter_images_markdown=1 -D jupyter_execute_notebooks=1 -D jupyter_pdf_book=1 -D jupyter_target_pdf=1 -D jupyter_number_workers=$(parallel) |
| 69 | + |
| 70 | +else |
| 71 | + @$(SPHINXBUILD) -M jupyterpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_theme_path="$(THEMEPATH)" -D jupyter_template_path="$(TEMPLATEPATH)" -D jupyter_latex_template="latex.tpl" -D jupyter_latex_template_book="latex_book.tpl" -D jupyter_images_markdown=1 -D jupyter_execute_notebooks=1 -D jupyter_pdf_book=1 -D jupyter_target_pdf=1 |
| 72 | +endif |
| 73 | + |
| 74 | +constructor-pdf: |
| 75 | +ifneq ($(strip $(parallel)),) |
| 76 | + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDPDF)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_images_markdown=1 -D jupyter_execute_notebooks=1 -D jupyter_number_workers=$(parallel) |
| 77 | + |
| 78 | +else |
| 79 | + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDPDF)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_images_markdown=1 -D jupyter_execute_notebooks=1 |
| 80 | +endif |
| 81 | + |
| 82 | +notebooks: |
| 83 | + make jupyter |
| 84 | + |
| 85 | +# Catch-all target: route all unknown targets to Sphinx using the new |
| 86 | +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). |
| 87 | +%: Makefile |
| 88 | + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_allow_html_only=1 |
0 commit comments