Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fixes a few thing while generating the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Nov 20, 2016
1 parent 497d234 commit 707af95
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
10 changes: 7 additions & 3 deletions _unittests/ut_helpgen/test_notebooks_bug.py
Expand Up @@ -71,7 +71,7 @@ def test_notebook(self):
fold = os.path.normpath(os.path.join(path, "notebooks"))
nbs = [os.path.join(fold, _)
for _ in os.listdir(fold) if ".ipynb" in _]
formats = ["present", "ipynb", "html",
formats = ["slides", "present", "ipynb", "html",
"python", "rst", "pdf", "docx"]

temp = get_temp_folder(__file__, "temp_nb_bug")
Expand All @@ -84,14 +84,18 @@ def test_notebook(self):
res = process_notebooks(nbs, temp, temp, formats=formats)
fLOG("*****", len(res))
for _ in res:
fLOG(_)
assert os.path.exists(_[0])
if not os.path.exists(_[0]):
raise Exception(_[0])

check = os.path.join(temp, "td1a_correction_session4.tex")
with open(check, "r", encoding="utf8") as f:
content = f.read()
if "\\section{" not in content:
raise Exception(content)
checks = [os.path.join(temp, "reveal.js"), os.path.join(temp, "require.js")]
for check in checks:
if not os.path.exists(check):
raise Exception(check)

def test_notebook_pdf(self):
fLOG(
Expand Down
3 changes: 1 addition & 2 deletions src/pyquickhelper/helpgen/process_notebook_api.py
Expand Up @@ -166,8 +166,7 @@ def _nbpresent_export(ipynb=None, outfile=None, out_format=None, verbose=None):

def nb2present(nb_file, outfile, add_tag=True):
"""
convert a notebooks into slides, it copies
reveal.js if not present in the folder of the output
convert a notebooks into slides with *format=present*.
@param nb_file notebook file or a stream or a @see fn read_nb
@param outfile output file (a string)
Expand Down
18 changes: 14 additions & 4 deletions src/pyquickhelper/helpgen/process_notebooks.py
Expand Up @@ -17,6 +17,7 @@
from .post_process import post_process_latex_output, post_process_latex_output_any, post_process_rst_output
from .post_process import post_process_html_output, post_process_slides_output, post_process_python_output
from .helpgen_exceptions import NotebookConvertError
from .install_js_dep import install_javascript_tools


if sys.version_info[0] == 2:
Expand Down Expand Up @@ -106,7 +107,7 @@ def process_notebooks(notebooks, outfold, build, latex_path=None, pandoc_path=No
Format *github* was added, it adds a link to file on github.
.. todoext::
:title: Allow hidden rst instruction in notebook (for references)
:title: Allow hidden rst instructions in notebook (for references)
:tag: enhancement
:issue: 10
Expand All @@ -122,9 +123,18 @@ def process_notebooks(notebooks, outfold, build, latex_path=None, pandoc_path=No
For Latex and PDF, the custom preprocessor is not taken into account.
by function _process_notebooks_in_private.
"""
return _process_notebooks_in(notebooks=notebooks, outfold=outfold, build=build,
latex_path=latex_path, pandoc_path=pandoc_path,
formats=formats, fLOG=fLOG, exc=exc)
res = _process_notebooks_in(notebooks=notebooks, outfold=outfold, build=build,
latex_path=latex_path, pandoc_path=pandoc_path,
formats=formats, fLOG=fLOG, exc=exc)
if "slides" in formats:
# we copy javascript dependencies, reveal.js
reveal = os.path.join(outfold, "reveal.js")
if not os.path.exists(reveal):
install_javascript_tools(None, dest=outfold)
reveal = os.path.join(build, "reveal.js")
if not os.path.exists(reveal):
install_javascript_tools(None, dest=build)
return res


def _process_notebooks_in_private(fnbcexe, list_args, options_args):
Expand Down
6 changes: 6 additions & 0 deletions src/pyquickhelper/helpgen/sphinx_main.py
Expand Up @@ -459,6 +459,12 @@ def lay_build_override_newconf(t3):
for html_static_path in html_static_paths:
install_javascript_tools(
root_sphinxdoc, dest=html_static_path, fLOG=fLOG)
for build in build_paths:
dest = os.path.join(build, "_downloads")
if not os.path.exists(dest):
os.makedirs(dest)
install_javascript_tools(
root_sphinxdoc, dest=dest, fLOG=fLOG)

##############
# copy the files
Expand Down

0 comments on commit 707af95

Please sign in to comment.