Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions nbdev/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
'nbdev.export.ExportModuleProc.begin': ('api/export.html#exportmoduleproc.begin', 'nbdev/export.py'),
'nbdev.export.nb_export': ('api/export.html#nb_export', 'nbdev/export.py'),
'nbdev.export.nb_mdoc': ('api/export.html#nb_mdoc', 'nbdev/export.py')},
'nbdev.extract_attachments': {},
'nbdev.frontmatter': { 'nbdev.frontmatter.FrontmatterProc': ('api/frontmatter.html#frontmatterproc', 'nbdev/frontmatter.py'),
'nbdev.frontmatter.FrontmatterProc._update': ( 'api/frontmatter.html#frontmatterproc._update',
'nbdev/frontmatter.py'),
Expand All @@ -150,7 +149,6 @@
'nbdev.frontmatter._dict2fm': ('api/frontmatter.html#_dict2fm', 'nbdev/frontmatter.py'),
'nbdev.frontmatter._fm2dict_md': ('api/frontmatter.html#_fm2dict_md', 'nbdev/frontmatter.py'),
'nbdev.frontmatter._insertfm': ('api/frontmatter.html#_insertfm', 'nbdev/frontmatter.py')},
'nbdev.imports': {},
'nbdev.maker': { 'nbdev.maker.ModuleMaker': ('api/maker.html#modulemaker', 'nbdev/maker.py'),
'nbdev.maker.ModuleMaker.__init__': ('api/maker.html#modulemaker.__init__', 'nbdev/maker.py'),
'nbdev.maker.ModuleMaker._last_future': ('api/maker.html#modulemaker._last_future', 'nbdev/maker.py'),
Expand Down Expand Up @@ -215,7 +213,6 @@
'nbdev.migrate.migrate_nb': ('api/migrate.html#migrate_nb', 'nbdev/migrate.py'),
'nbdev.migrate.nbdev_migrate': ('api/migrate.html#nbdev_migrate', 'nbdev/migrate.py'),
'nbdev.migrate.nbdev_migrate_config': ('api/migrate.html#nbdev_migrate_config', 'nbdev/migrate.py')},
'nbdev.moddocs': {},
'nbdev.process': { 'nbdev.process.NBProcessor': ('api/process.html#nbprocessor', 'nbdev/process.py'),
'nbdev.process.NBProcessor.__init__': ('api/process.html#nbprocessor.__init__', 'nbdev/process.py'),
'nbdev.process.NBProcessor._proc': ('api/process.html#nbprocessor._proc', 'nbdev/process.py'),
Expand Down Expand Up @@ -364,12 +361,10 @@
'nbdev.release.update_changelog': ('api/release.html#update_changelog', 'nbdev/release.py'),
'nbdev.release.write_conda_meta': ('api/release.html#write_conda_meta', 'nbdev/release.py'),
'nbdev.release.write_requirements': ('api/release.html#write_requirements', 'nbdev/release.py')},
'nbdev.scrubmagics': {},
'nbdev.serve': { 'nbdev.serve._is_qpy': ('api/serve.html#_is_qpy', 'nbdev/serve.py'),
'nbdev.serve._keep_file': ('api/serve.html#_keep_file', 'nbdev/serve.py'),
'nbdev.serve._proc_file': ('api/serve.html#_proc_file', 'nbdev/serve.py'),
'nbdev.serve.proc_nbs': ('api/serve.html#proc_nbs', 'nbdev/serve.py')},
'nbdev.serve_drv': {},
'nbdev.showdoc': { 'nbdev.showdoc.BasicMarkdownRenderer': ('api/showdoc.html#basicmarkdownrenderer', 'nbdev/showdoc.py'),
'nbdev.showdoc.BasicMarkdownRenderer._repr_markdown_': ( 'api/showdoc.html#basicmarkdownrenderer._repr_markdown_',
'nbdev/showdoc.py'),
Expand All @@ -378,7 +373,6 @@
'nbdev.showdoc.doc': ('api/showdoc.html#doc', 'nbdev/showdoc.py'),
'nbdev.showdoc.show_doc': ('api/showdoc.html#show_doc', 'nbdev/showdoc.py'),
'nbdev.showdoc.showdoc_nm': ('api/showdoc.html#showdoc_nm', 'nbdev/showdoc.py')},
'nbdev.skill': {},
'nbdev.sync': { 'nbdev.sync._mod_files': ('api/sync.html#_mod_files', 'nbdev/sync.py'),
'nbdev.sync._to_absolute': ('api/sync.html#_to_absolute', 'nbdev/sync.py'),
'nbdev.sync._update_mod': ('api/sync.html#_update_mod', 'nbdev/sync.py'),
Expand Down
2 changes: 1 addition & 1 deletion nbdev/doclinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _stor(nm):
if isinstance(tree, ast.ClassDef):
for t2 in tree.body:
if isinstance(t2, _def_types): _stor(f'{tree.name}.{t2.name}')
return {mod_name: d}
return {mod_name: d} if d else {}

# %% ../nbs/api/05_doclinks.ipynb #587df0d4
def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
Expand Down
4 changes: 2 additions & 2 deletions nbdev/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def __call__(self, cell):
if str2bool(fm.get('skip_showdoc', False)): return
if _do_eval(cell): self.k.cell(cell)
title = fm.get('title', '')
if self.k.exc:
raise Exception(f"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\n{cell.source}") from self.k.exc
if (e := self.k.exc):
raise Exception(f"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\n{cell.source}\n{type(e).__name__}: {e}") from e

def end(self):
try: from ipywidgets import Widget
Expand Down
28 changes: 27 additions & 1 deletion nbs/api/05_doclinks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
" if isinstance(tree, ast.ClassDef):\n",
" for t2 in tree.body:\n",
" if isinstance(t2, _def_types): _stor(f'{tree.name}.{t2.name}')\n",
" return {mod_name: d}"
" return {mod_name: d} if d else {}"
]
},
{
Expand All @@ -224,6 +224,32 @@
"# _get_modidx(get_config().lib_path/'sync.py', get_config().lib_path, get_config().nbs_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "325f22b8",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"import tempfile"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fbbdbd9d",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"# A data file with no symbols gets no entry. The index is then the same whether or not a generated file exists.\n",
"with tempfile.TemporaryDirectory() as d:\n",
" d = Path(d).resolve()\n",
" (d/'data.py').write_text(\"{'a': 1}\")\n",
" test_eq(_get_modidx(d/'data.py', d, d), {})"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
23 changes: 21 additions & 2 deletions nbs/api/10_processors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@
" if str2bool(fm.get('skip_showdoc', False)): return\n",
" if _do_eval(cell): self.k.cell(cell)\n",
" title = fm.get('title', '')\n",
" if self.k.exc: \n",
" raise Exception(f\"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\\n{cell.source}\") from self.k.exc\n",
" if (e := self.k.exc):\n",
" raise Exception(f\"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\\n{cell.source}\\n{type(e).__name__}: {e}\") from e\n",
"\n",
" def end(self):\n",
" try: from ipywidgets import Widget\n",
Expand Down Expand Up @@ -798,6 +798,25 @@
"assert res"
]
},
{
"cell_type": "markdown",
"id": "b1a63b85",
"metadata": {},
"source": [
"When a cell fails, the error names the exception as well as the cell. The last lines of a docs build log then state the cause."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "93734aba",
"metadata": {},
"outputs": [],
"source": [
"nb = dict2nb(dict(cells=[mk_cell('#| export\\ndef f(): pass'), mk_cell('import not_a_real_module')], metadata={}, nbformat=4, nbformat_minor=5))\n",
"with ExceptionExpected(regex='ModuleNotFoundError'): NBProcessor(nb=nb, procs=[add_show_docs, exec_show_docs]).process()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
7 changes: 3 additions & 4 deletions nbs/tutorials/migrating.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@
"rm -f .git/hooks/post-merge\n",
"\n",
"rm -f setup.py\n",
"curl -O https://raw.githubusercontent.com/fastai/nbdev3-template/master/styles.css\n",
"curl -O https://raw.githubusercontent.com/fastai/nbdev3-template/master/setup.py\n",
"curl -O https://raw.githubusercontent.com/AnswerDotAI/nbdev3-template/master/styles.css\n",
"\n",
"cat >>.gitignore <<EOF\n",
"_docs/\n",
Expand Down Expand Up @@ -179,8 +178,8 @@
"\n",
"```bash\n",
"rm -f .github/workflows/main.yml\n",
"curl -O https://raw.githubusercontent.com/fastai/nbdev3-template/master/.github/workflows/test.yaml\n",
"curl -O https://raw.githubusercontent.com/fastai/nbdev3-template/master/.github/workflows/deploy.yaml\n",
"curl -O https://raw.githubusercontent.com/AnswerDotAI/nbdev3-template/master/.github/workflows/test.yaml\n",
"curl -O https://raw.githubusercontent.com/AnswerDotAI/nbdev3-template/master/.github/workflows/deploy.yaml\n",
"mv deploy.yaml test.yaml .github/workflows/\n",
"```"
]
Expand Down
Loading