Skip to content

Commit

Permalink
🐛 FIX: Path to custom output directory for _sources (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfm authored Jul 8, 2021
1 parent cdad8b2 commit e05def5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sphinx_book_theme/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit e05def5

Please sign in to comment.