Skip to content

Commit

Permalink
FIX: remainder of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Dec 13, 2023
1 parent 2a67969 commit 40fa0eb
Show file tree
Hide file tree
Showing 12 changed files with 414 additions and 8 deletions.
10 changes: 8 additions & 2 deletions jupyter_book/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ def build(
is_flag=True,
help="Use cookiecutter to interactively create a Jupyter Book template.",
)
def create(path_book, cookiecutter):
@click.option(
"--no-input",
is_flag=True,
help="If using cookiecutter, do not prompt the user for input.",
)
def create(path_book, cookiecutter, no_input):
"""Create a Jupyter Book template that you can customize."""
book = Path(path_book)
if not cookiecutter: # this will be the more common option
Expand All @@ -341,7 +346,8 @@ def create(path_book, cookiecutter):
f"{e}. To install, run\n\n\tpip install cookiecutter",
kind=e.__class__,
)
book = cookiecutter(cc_url, output_dir=Path(path_book))

book = cookiecutter(cc_url, output_dir=Path(path_book), no_input=no_input)
_message_box(f"Your book template can be found at\n\n {book}{os.sep}")


Expand Down
2 changes: 1 addition & 1 deletion jupyter_book/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_final_config(

# TODO: deprecate this in version 0.14
# https://github.com/executablebooks/jupyter-book/issues/1502
if "mathjax_path" in user_yaml_update:
if "mathjax_config" in user_yaml_update:
# Switch off warning if user has specified mathjax v2
if (
"mathjax_path" in user_yaml_update
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ markers = [
]
filterwarnings = [
"error",
'ignore:nodes.Node.traverse() is obsoleted by Node.findall():PendingDeprecationWarning',
'ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning'
'ignore:nodes\.Node\.traverse\(\) is obsoleted by Node\.findall\(\):PendingDeprecationWarning',
'ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning',
'ignore:The frontend\.OptionParser class will be replaced:DeprecationWarning',
'ignore:The frontend\.Option class will be removed:DeprecationWarning',
# Pyppeteer throws this exception
'ignore:remove loop argument:DeprecationWarning'
]
10 changes: 8 additions & 2 deletions tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import shutil
import warnings
from pathlib import Path

import docutils
Expand Down Expand Up @@ -28,7 +30,7 @@ def test_create(temp_with_override: Path, cli):

def test_create_from_cookiecutter(temp_with_override: Path, cli):
book = temp_with_override / "new_book"
result = cli.invoke(commands.create, [book.as_posix(), "--cookiecutter"])
result = cli.invoke(commands.create, [book.as_posix(), "--cookiecutter", "--no-input"])
assert result.exit_code == 0
# this test uses default cookiecutter prompt values
# note that default cookiecutter book name is "my_book"
Expand Down Expand Up @@ -133,12 +135,16 @@ def test_toc_rebuild(cli, build_resources):
assert tags[1].attrs["href"] == "content1.html"
assert tags[2].attrs["href"] == "content2.html"

# Clean build manually (to avoid caching of sidebar)
build_path = tocs.joinpath("_build")
shutil.rmtree(build_path)

# Build with secondary ToC
toc = tocs / "_toc_simple_changed.yml"
result = cli.invoke(
commands.build,
[tocs.as_posix(), "--toc", toc.as_posix(), "-n"],
)
print(result.exception)
assert result.exit_code == 0, result.output
html = BeautifulSoup(index_html.read_text(encoding="utf8"), "html.parser")
tags = html.find_all("a", "reference internal")
Expand Down
45 changes: 45 additions & 0 deletions tests/test_build/_toc_numbered.sphinx7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<nav aria-label="Main" class="bd-links bd-docs-nav">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1 current active">
<a class="reference internal" href="#">
Main index
</a>
</li>
</ul>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content1.html">
1. Content1
</a>
</li>
<li class="toctree-l1 has-children">
<a class="reference internal" href="subfolder/index.html">
2. Subfolder
</a>
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
<label class="toctree-toggle" for="toctree-checkbox-1">
<i class="fa-solid fa-chevron-down">
</i>
</label>
<ul>
<li class="toctree-l2">
<a class="reference internal" href="subfolder/asubpage.html">
2.1. Asubpage
</a>
</li>
</ul>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content2.html">
3. Content2
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content3.html">
4. Content3
</a>
</li>
</ul>
</div>
</nav>
45 changes: 45 additions & 0 deletions tests/test_build/_toc_numbered_depth.sphinx7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<nav aria-label="Main" class="bd-links bd-docs-nav">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1 current active">
<a class="reference internal" href="#">
Main index
</a>
</li>
</ul>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content1.html">
1. Content1
</a>
</li>
<li class="toctree-l1 has-children">
<a class="reference internal" href="subfolder/index.html">
2. Subfolder
</a>
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
<label class="toctree-toggle" for="toctree-checkbox-1">
<i class="fa-solid fa-chevron-down">
</i>
</label>
<ul>
<li class="toctree-l2">
<a class="reference internal" href="subfolder/asubpage.html">
Asubpage
</a>
</li>
</ul>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content2.html">
3. Content2
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content3.html">
4. Content3
</a>
</li>
</ul>
</div>
</nav>
64 changes: 64 additions & 0 deletions tests/test_build/_toc_numbered_depth_parts_subset.sphinx7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<nav aria-label="Main" class="bd-links bd-docs-nav">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1 current active">
<a class="reference internal" href="#">
Main index
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 1
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content1.html">
1. Content1
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 2
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content2.html">
Content2
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content3.html">
Content3
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 3
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1 has-children">
<a class="reference internal" href="subfolder/index.html">
2. Subfolder
</a>
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
<label class="toctree-toggle" for="toctree-checkbox-1">
<i class="fa-solid fa-chevron-down">
</i>
</label>
<ul>
<li class="toctree-l2">
<a class="reference internal" href="subfolder/asubpage.html">
Asubpage
</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
57 changes: 57 additions & 0 deletions tests/test_build/_toc_numbered_parts.sphinx7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<nav aria-label="Main" class="bd-links bd-docs-nav">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1 current active">
<a class="reference internal" href="#">
Main index
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 1
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content1.html">
1. Content1
</a>
</li>
<li class="toctree-l1 has-children">
<a class="reference internal" href="subfolder/index.html">
2. Subfolder
</a>
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
<label class="toctree-toggle" for="toctree-checkbox-1">
<i class="fa-solid fa-chevron-down">
</i>
</label>
<ul>
<li class="toctree-l2">
<a class="reference internal" href="subfolder/asubpage.html">
2.1. Asubpage
</a>
</li>
</ul>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 2
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content2.html">
3. Content2
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content3.html">
4. Content3
</a>
</li>
</ul>
</div>
</nav>
64 changes: 64 additions & 0 deletions tests/test_build/_toc_numbered_parts_subset.sphinx7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<nav aria-label="Main" class="bd-links bd-docs-nav">
<div class="bd-toc-item navbar-nav active">
<ul class="nav bd-sidenav bd-sidenav__home-link">
<li class="toctree-l1 current active">
<a class="reference internal" href="#">
Main index
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 1
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content1.html">
1. Content1
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 2
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="content2.html">
Content2
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="content3.html">
Content3
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Chapter 3
</span>
</p>
<ul class="nav bd-sidenav">
<li class="toctree-l1 has-children">
<a class="reference internal" href="subfolder/index.html">
2. Subfolder
</a>
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
<label class="toctree-toggle" for="toctree-checkbox-1">
<i class="fa-solid fa-chevron-down">
</i>
</label>
<ul>
<li class="toctree-l2">
<a class="reference internal" href="subfolder/asubpage.html">
2.1. Asubpage
</a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
3 changes: 2 additions & 1 deletion tests/test_sphinx_jupyterbook_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def test_toc(cli, build_resources, file_regression):

# reading the xml file
doctree_path = path_parts_toc.joinpath("_build", ".doctrees", "intro.doctree")
doc = pickle.load(open(doctree_path, "rb"))
with open(doctree_path, "rb") as f:
doc = pickle.load(f)
pseudoxml = doc.pformat()

# to remove source attribute of document as it is a temp
Expand Down
21 changes: 21 additions & 0 deletions tests/test_tocdirective/test_toc_parts_directive.sphinx7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="toctree-wrapper compound">
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
A section
</span>
</p>
<ul>
<li class="toctree-l1">
<a class="reference internal" href="subfolder/index.html">
Subfolder
</a>
<ul>
<li class="toctree-l2">
<a class="reference internal" href="subfolder/asubpage1.html">
Asubpage 1
</a>
</li>
</ul>
</li>
</ul>
</div>
Loading

0 comments on commit 40fa0eb

Please sign in to comment.