Skip to content

Commit 0c55cc4

Browse files
committed
add more useful msg to nbdev_export
1 parent e3a44ce commit 0c55cc4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

nbdev/doclinks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ def nbdev_export(
143143
**kwargs):
144144
"Export notebooks in `path` to Python modules"
145145
if os.environ.get('IN_TEST',0): return
146+
if not is_nbdev(): raise Exception('`nbdev_export` must be called from a directory within a nbdev project.')
147+
path = Path(path or get_config().nbs_path)
146148
if procs:
147149
import nbdev.export
148150
procs = [getattr(nbdev.export, p) for p in L(procs)]

nbs/api/05_doclinks.ipynb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@
362362
" **kwargs):\n",
363363
" \"Export notebooks in `path` to Python modules\"\n",
364364
" if os.environ.get('IN_TEST',0): return\n",
365+
" if not is_nbdev(): raise Exception('`nbdev_export` must be called from a directory within a nbdev project.')\n",
366+
" path = Path(path or get_config().nbs_path)\n",
365367
" if procs:\n",
366368
" import nbdev.export\n",
367369
" procs = [getattr(nbdev.export, p) for p in L(procs)]\n",
@@ -576,24 +578,24 @@
576578
"text/markdown": [
577579
"---\n",
578580
"\n",
579-
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L216){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
581+
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L226){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
580582
"\n",
581583
"### NbdevLookup.doc\n",
582584
"\n",
583585
"> NbdevLookup.doc (sym)\n",
584586
"\n",
585-
"Link to docs for `sym`"
587+
"*Link to docs for `sym`*"
586588
],
587589
"text/plain": [
588590
"---\n",
589591
"\n",
590-
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L216){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
592+
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L226){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
591593
"\n",
592594
"### NbdevLookup.doc\n",
593595
"\n",
594596
"> NbdevLookup.doc (sym)\n",
595597
"\n",
596-
"Link to docs for `sym`"
598+
"*Link to docs for `sym`*"
597599
]
598600
},
599601
"execution_count": null,
@@ -670,24 +672,24 @@
670672
"text/markdown": [
671673
"---\n",
672674
"\n",
673-
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L221){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
675+
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L231){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
674676
"\n",
675677
"### NbdevLookup.code\n",
676678
"\n",
677679
"> NbdevLookup.code (sym)\n",
678680
"\n",
679-
"Link to source code for `sym`"
681+
"*Link to source code for `sym`*"
680682
],
681683
"text/plain": [
682684
"---\n",
683685
"\n",
684-
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L221){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
686+
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L231){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
685687
"\n",
686688
"### NbdevLookup.code\n",
687689
"\n",
688690
"> NbdevLookup.code (sym)\n",
689691
"\n",
690-
"Link to source code for `sym`"
692+
"*Link to source code for `sym`*"
691693
]
692694
},
693695
"execution_count": null,
@@ -729,7 +731,7 @@
729731
"text/markdown": [
730732
"---\n",
731733
"\n",
732-
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L238){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
734+
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L248){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
733735
"\n",
734736
"### NbdevLookup.linkify\n",
735737
"\n",
@@ -738,7 +740,7 @@
738740
"text/plain": [
739741
"---\n",
740742
"\n",
741-
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L238){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
743+
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L248){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
742744
"\n",
743745
"### NbdevLookup.linkify\n",
744746
"\n",

0 commit comments

Comments
 (0)