From 024d566c8dc555b82bbffe28198488a2ebc2cac8 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 11 Nov 2020 15:57:23 +1100 Subject: [PATCH] updates to work with sphinx-tomyst --- Makefile | 18 ++++----- conf.py | 112 ++++++------------------------------------------------- 2 files changed, 21 insertions(+), 109 deletions(-) diff --git a/Makefile b/Makefile index 18892b0..268da4f 100644 --- a/Makefile +++ b/Makefile @@ -49,34 +49,34 @@ clean-pdf: coverage: ifneq ($(strip $(parallel)),) - @$(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) + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDCOVERAGE)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_make_coverage=1 -D tojupyter_execute_notebooks=1 -D tojupyter_ignore_skip_test=0 -D tojupyter_theme_path="$(THEMEPATH)" -D tojupyter_template_path="$(TEMPLATEPATH)" -D tojupyter_template_coverage_file_path="error_report_template.html" -D tojupyter_number_workers=$(parallel) else - @$(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" + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDCOVERAGE)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_make_coverage=1 -D tojupyter_execute_notebooks=1 -D tojupyter_ignore_skip_test=0 -D tojupyter_theme_path="$(THEMEPATH)" -D tojupyter_template_path="$(TEMPLATEPATH)" -D tojupyter_template_coverage_file_path="error_report_template.html" endif website: echo "Theme: $(THEMEPATH)" ifneq ($(strip $(parallel)),) - @$(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) + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDWEBSITE)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_make_site=1 -D tojupyter_generate_html=1 -D tojupyter_download_nb=1 -D tojupyter_execute_notebooks=1 -D tojupyter_target_html=1 -D tojupyter_download_nb_image_urlpath="https://s3-ap-southeast-2.amazonaws.com/python-programming.quantecon.org/_static/" -D tojupyter_images_markdown=0 -D tojupyter_theme_path="$(THEMEPATH)" -D tojupyter_template_path="$(TEMPLATEPATH)" -D tojupyter_html_template="html.tpl" -D tojupyter_download_nb_urlpath="https://python-programming.quantecon.org/" -D tojupyter_coverage_dir=$(BUILDCOVERAGE) -D tojupyter_number_workers=$(parallel) else - @$(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) + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDWEBSITE)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_make_site=1 -D tojupyter_generate_html=1 -D tojupyter_download_nb=1 -D tojupyter_execute_notebooks=1 -D tojupyter_target_html=1 -D tojupyter_download_nb_image_urlpath="https://s3-ap-southeast-2.amazonaws.com/python-programming.quantecon.org/_static/" -D tojupyter_images_markdown=0 -D tojupyter_theme_path="$(THEMEPATH)" -D tojupyter_template_path="$(TEMPLATEPATH)" -D tojupyter_html_template="html.tpl" -D tojupyter_download_nb_urlpath="https://python-programming.quantecon.org/" -D tojupyter_coverage_dir=$(BUILDCOVERAGE) endif pdf: ifneq ($(strip $(parallel)),) - @$(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) + @$(SPHINXBUILD) -M jupyterpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_latex_template="latex.tpl" -D tojupyter_theme_path="$(THEMEPATH)" -D tojupyter_template_path="$(TEMPLATEPATH)" -D tojupyter_latex_template_book="latex_book.tpl" -D tojupyter_images_markdown=1 -D tojupyter_execute_notebooks=1 -D tojupyter_pdf_book=1 -D tojupyter_target_pdf=1 -D tojupyter_number_workers=$(parallel) else - @$(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 + @$(SPHINXBUILD) -M jupyterpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_theme_path="$(THEMEPATH)" -D tojupyter_template_path="$(TEMPLATEPATH)" -D tojupyter_latex_template="latex.tpl" -D tojupyter_latex_template_book="latex_book.tpl" -D tojupyter_images_markdown=1 -D tojupyter_execute_notebooks=1 -D tojupyter_pdf_book=1 -D tojupyter_target_pdf=1 endif constructor-pdf: ifneq ($(strip $(parallel)),) - @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDPDF)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_images_markdown=1 -D jupyter_execute_notebooks=1 -D jupyter_number_workers=$(parallel) + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDPDF)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_images_markdown=1 -D tojupyter_execute_notebooks=1 -D tojupyter_number_workers=$(parallel) else - @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDPDF)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_images_markdown=1 -D jupyter_execute_notebooks=1 + @$(SPHINXBUILD) -M jupyter "$(SOURCEDIR)" "$(BUILDPDF)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_images_markdown=1 -D tojupyter_execute_notebooks=1 endif notebooks: @@ -85,4 +85,4 @@ notebooks: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D jupyter_allow_html_only=1 + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(FILES) $(SPHINXOPTS) $(O) -D tojupyter_allow_html_only=1 diff --git a/conf.py b/conf.py index fe5be86..49c49d7 100644 --- a/conf.py +++ b/conf.py @@ -39,7 +39,7 @@ 'sphinxcontrib.bibtex', 'IPython.sphinxext.ipython_console_highlighting', # Custom Sphinx Extensions - 'sphinxcontrib.jupyter', + 'sphinx_tojupyter', ] # Retired Extensions but may be useful in Future @@ -367,22 +367,12 @@ linkcheck_timeout = 30 -# -------------------------------------------- -# jupyter Sphinx Extension conversion settings -# -------------------------------------------- +# ---------------- +# sphinx-tojupyter +# ---------------- -# Conversion Mode Settings -# If "all", convert codes and texts into notebook -# If "code", convert codes only -jupyter_conversion_mode = "all" - -jupyter_write_metadata = False - -# Location for _static folder -jupyter_static_file_path = ["source/_static", "_static"] - -# Configure Jupyter Kernels -jupyter_kernels = { +tojupyter_static_file_path = ["source/_static", "_static"] +tojupyter_kernels = { "python3": { "kernelspec": { "display_name": "Python", @@ -392,88 +382,10 @@ "file_extension": ".py", }, } +tojupyter_target_html = True +tojupyter_urlpath = "https://python-programming.quantecon.org/" +tojupyter_image_urlpath = "https://python-programming.quantecon.org/_static/" +tojupyter_lang_synonyms = ["ipython", "ipython3", "python"] +tojupyter_images_markdown = True +tojupyter_allow_html_only=True -# Configure jupyter headers -jupyter_headers = { - "python3": [ - # nbformat.v4.new_code_cell("%autosave 0") #@mmcky please make this an option - ], - "julia": [ - ], -} - -# Filename for the file containing the welcome block -jupyter_welcome_block = "" - -#Adjust links to target html (rather than ipynb) -jupyter_target_html = False - -#path to download notebooks from -jupyter_download_nb_urlpath = None - -#allow downloading of notebooks -jupyter_download_nb = False - -#Use urlprefix images -jupyter_download_nb_image_urlpath = None - -#Allow ipython as a language synonym for blocks to be ipython highlighted -jupyter_lang_synonyms = ["ipython", "ipython3"] - -#Execute skip-test code blocks for rendering of website (this will need to be ignored in coverage testing) -jupyter_ignore_skip_test = True - -#allow execution of notebooks -jupyter_execute_notebooks = False - -# Location of template folder for coverage reports -jupyter_template_coverage_file_path = False - -# generate html from IPYNB files -jupyter_generate_html = False - -# html template specific to your website needs -jupyter_html_template = "" - -# latex template specific to your website needs -jupyter_latex_template = "" - -#make website -jupyter_make_site = False - -#force markdown image inclusion -jupyter_images_markdown = True - -#This is set true by default to pass html to the notebooks -jupyter_allow_html_only=True - -## Theme specific variables -# jupyter_theme_path = 'theme/minimal' #Specified in Makefile -# jupyter_template_path = 'theme/minimal/templates' #Specified in Makefile - -jupyter_nextprev_ignore = ['404', "search", "status", "troubleshooting"] - -### pdf options -jupyter_pdf_logo = "_static/img/qe-menubar-logo.png" - -jupyter_bib_file = "_static/quant-econ" - -jupyter_pdf_author = "Thomas J. Sargent and John Stachurski" - -# Exclude Document Patterns for PDF Construction -jupyter_pdf_excludepatterns = ["404", "index", "references"] - -# Set urlpath for html links in documents -jupyter_pdf_urlpath = "https://python-programming.quantecon.org/" - -# make book -jupyter_pdf_book = False - -# book title -jupyter_pdf_book_title = "Python Programming for Economics and Finance" - -# pdf book name -jupyter_pdf_book_name = "python_programming_for_economics_finance" - -# pdf toc file -jupyter_pdf_book_index = "index_toc"