diff --git a/sphinx_book_theme/launch.py b/sphinx_book_theme/launch.py index 7cec0b06..86da7465 100644 --- a/sphinx_book_theme/launch.py +++ b/sphinx_book_theme/launch.py @@ -45,9 +45,10 @@ def add_hub_urls( or context["sourcename"].endswith(".md.txt") ): # Figure out the folders we want - build_dir = Path(app.outdir).parent + out_dir = Path(app.outdir) + build_dir = out_dir.parent ntbk_dir = build_dir.joinpath("jupyter_execute") - sources_dir = build_dir.joinpath(context.get("builder", "html"), "_sources") + sources_dir = out_dir.joinpath("_sources") # Paths to old and new notebooks path_ntbk = ntbk_dir.joinpath(pagename).with_suffix(".ipynb") path_new_notebook = sources_dir.joinpath(pagename).with_suffix(".ipynb") diff --git a/tests/test_build.py b/tests/test_build.py index 6301de90..db2ca096 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -302,3 +302,12 @@ def test_logo_only(sphinx_build_factory): "h1", attrs={"id": "site-title"} ) assert not logo_text + + +def test_copy_rendered_notebooks(): + target = Path("build/outdir/_sources/section1/ntbkmd.ipynb") + if target.exists(): + target.unlink() + # Switch to sphinx_build_factory if we figure out how to use outdir w/ it + check_call("sphinx-build -W -b dirhtml tests/sites/base build/outdir", shell=True) + assert target.exists()