Skip to content

Commit

Permalink
Merge pull request #76 from hamelsmu/backticks
Browse files Browse the repository at this point in the history
Fix Bug in #73
  • Loading branch information
sgugger authored Jan 31, 2020
2 parents c420a89 + 6f492ff commit 2e14737
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/export2html.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ <h4 id="add_jekyll_notes" class="doc_header"><code>add_jekyll_notes</code><a hre


<div class="output_markdown rendered_html output_subarea ">
<h4 id="copy_images" class="doc_header"><code>copy_images</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/export2html.py#L131" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>copy_images</code>(<strong><code>cell</code></strong>, <strong><code>fname</code></strong>, <strong><code>dest</code></strong>, <strong><code>jekyll</code></strong>=<em><code>True</code></em>)</p>
<h4 id="copy_images" class="doc_header"><code>copy_images</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/export2html.py#L132" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>copy_images</code>(<strong><code>cell</code></strong>, <strong><code>fname</code></strong>, <strong><code>dest</code></strong>, <strong><code>jekyll</code></strong>=<em><code>True</code></em>)</p>
</blockquote>
<p>Copy images referenced in <code>cell</code> from <code>fname</code> parent folder to <code>dest</code> folder</p>

Expand Down Expand Up @@ -973,7 +973,7 @@ <h4 id="notebook2html" class="doc_header"><code>notebook2html</code><a href="htt


<div class="output_markdown rendered_html output_subarea ">
<h4 id="convert_md" class="doc_header"><code>convert_md</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/export2html.py#L413" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>convert_md</code>(<strong><code>fname</code></strong>, <strong><code>dest_path</code></strong>, <strong><code>img_path</code></strong>=<em><code>'docs/images/'</code></em>, <strong><code>jekyll</code></strong>=<em><code>True</code></em>)</p>
<h4 id="convert_md" class="doc_header"><code>convert_md</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/export2html.py#L415" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>convert_md</code>(<strong><code>fname</code></strong>, <strong><code>dest_path</code></strong>, <strong><code>img_path</code></strong>=<em><code>'docs/images/'</code></em>, <strong><code>jekyll</code></strong>=<em><code>True</code></em>)</p>
</blockquote>
<p>Convert a notebook <code>fname</code> to a markdown file in <code>dest_path</code>.</p>

Expand Down Expand Up @@ -1033,7 +1033,7 @@ <h4 id="convert_md" class="doc_header"><code>convert_md</code><a href="https://g


<div class="output_markdown rendered_html output_subarea ">
<h4 id="nb_detach_cells" class="doc_header"><code>nb_detach_cells</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/export2html.py#L470" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>nb_detach_cells</code>(<strong><code>path_nb</code></strong>, <strong><code>dest</code></strong>=<em><code>None</code></em>, <strong><code>replace</code></strong>=<em><code>True</code></em>, <strong><code>use_img</code></strong>=<em><code>False</code></em>)</p>
<h4 id="nb_detach_cells" class="doc_header"><code>nb_detach_cells</code><a href="https://github.com/fastai/nbdev/tree/master/nbdev/export2html.py#L472" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>nb_detach_cells</code>(<strong><code>path_nb</code></strong>, <strong><code>dest</code></strong>=<em><code>None</code></em>, <strong><code>replace</code></strong>=<em><code>True</code></em>, <strong><code>use_img</code></strong>=<em><code>False</code></em>)</p>
</blockquote>
<p>Export cell attachments to <code>dest</code> and update references</p>

Expand Down
4 changes: 3 additions & 1 deletion nbdev/export2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ def notebook2html(fname=None, force_all=False, n_workers=None, cls=HTMLExporter,
"Convert all notebooks matching `fname` to html files"
if fname is None:
files = [f for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]
else: files = list(p.parent.glob(p.name))
else:
p = Path(fname)
files = list(p.parent.glob(p.name))
if len(files)==1:
force_all = True
if n_workers is None: n_workers=0
Expand Down
58 changes: 56 additions & 2 deletions nbs/03_export2html.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"hide_input": false
},
"outputs": [],
"source": [
"# export\n",
Expand Down Expand Up @@ -1147,7 +1149,9 @@
" \"Convert all notebooks matching `fname` to html files\"\n",
" if fname is None: \n",
" files = [f for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]\n",
" else: files = list(p.parent.glob(p.name))\n",
" else: \n",
" p = Path(fname)\n",
" files = list(p.parent.glob(p.name))\n",
" if len(files)==1:\n",
" force_all = True\n",
" if n_workers is None: n_workers=0\n",
Expand All @@ -1166,6 +1170,56 @@
" raise Exception(msg + '\\n'.join([f.name for p,f in zip(passed,files) if not p]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide_input": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"converting: 01_sync.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/99_search.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/06_cli.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/04_test.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/03_export2html.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/01_sync.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/00_export.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/02_showdoc.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/07_clean.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/index.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/tutorial.ipynb\n",
"converting: /home/jovyan/nbdev/nbs/05_merge.ipynb\n",
"converting: ../README.md\n",
"Notebook does not appear to be JSON: '![](https://github.com/fastai/nbdev/wor...\n"
]
}
],
"source": [
"#hide\n",
"\n",
"# Test when an argument is given to notebook2html\n",
"p1 = Path('/tmp/sync.html')\n",
"if p1.exists(): p1.unlink()\n",
"notebook2html('01_sync.ipynb', dest='/tmp');\n",
"assert p1.exists()\n",
"\n",
"# Test when no argument is given to notebook2html\n",
"dest_files = [_nb2htmlfname(f, dest='/tmp') for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]\n",
"[f.unlink() for f in dest_files if f.exists()]\n",
"notebook2html(fname=None, dest='/tmp');\n",
"assert all([f.exists() for f in dest_files])\n",
"\n",
"\n",
"# Test Error handling\n",
"try: notebook2html('../README.md');\n",
"except Exception as e: assert True\n",
"else: assert False, 'An error should be raised when a non-notebook file is passed to notebook2html!'"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 2e14737

Please # to comment.