From 791d98fb49907b6b4035cf26209d4e71c0e72426 Mon Sep 17 00:00:00 2001 From: Ariel Rokem Date: Tue, 22 Aug 2023 21:12:20 -0700 Subject: [PATCH 1/2] Trying to incorporate a notebook into the doc build. --- .github/workflows/docbuild.yml | 2 +- .pre-commit-config.yaml | 9 ++++ docs/source/conf.py | 1 + .../howto_examples/plot_test_nbsphinx.ipynb | 51 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml create mode 100644 examples/howto_examples/plot_test_nbsphinx.ipynb diff --git a/.github/workflows/docbuild.yml b/.github/workflows/docbuild.yml index 7c7e8b2cc..ac2a96540 100644 --- a/.github/workflows/docbuild.yml +++ b/.github/workflows/docbuild.yml @@ -27,7 +27,7 @@ jobs: XVFB: 1 run: | cd docs - make html + python -m sphinx source build -j 4 - name: Upload docs uses: actions/upload-artifact@v1 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..1abfefe00 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: local + hooks: + - id: jupyter-nb-clear-output + name: jupyter-nb-clear-output + files: \.ipynb$ + stages: [commit] + language: system + entry: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 82427080e..2745aa8bd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -62,6 +62,7 @@ 'kwargsdocs', 'methodsdocs', 'myst_nb', + 'nbsphinx', ] # Add any paths that contain templates here, relative to this directory. diff --git a/examples/howto_examples/plot_test_nbsphinx.ipynb b/examples/howto_examples/plot_test_nbsphinx.ipynb new file mode 100644 index 000000000..033e9e334 --- /dev/null +++ b/examples/howto_examples/plot_test_nbsphinx.ipynb @@ -0,0 +1,51 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import numpy as np\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.plot(np.random.rand(10))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "afq", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From eb7f70f517f8d6653eaacea0827af2028731a155 Mon Sep 17 00:00:00 2001 From: Ariel Rokem Date: Tue, 22 Aug 2023 21:19:18 -0700 Subject: [PATCH 2/2] Adds installation of nbsphinx. --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 43f05f9c0..eae3e1f8c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -74,6 +74,7 @@ dev = pydata-sphinx-theme sphinx-design myst-nb + nbsphinx fury = fury==0.8.0 xvfbwrapper==0.2.9