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
246 changes: 0 additions & 246 deletions docs/nbdev_callbacks.html

This file was deleted.

3 changes: 1 addition & 2 deletions docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"Command line functions": "cli.html",
"Clean notebooks": "clean.html",
"Setting up Search": "search.html",
"Magic Flags": "magic_flags.html",
"Callbacks": "nbdev_callbacks.html"
"Magic Flags": "magic_flags.html"
}
}
6 changes: 0 additions & 6 deletions nbdev/export2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ def convert_nb(fname, cls=HTMLExporter, template_file=None, exporter=None, dest=
fname = Path(fname).absolute()
# os.chdir(fname.parent)
nb = read_nb(fname)
call_cb('begin_doc_nb', nb, fname, 'html')
meta_jekyll = get_metadata(nb['cells'])
meta_jekyll['nb_path'] = str(fname.relative_to(Config().lib_path.parent))
cls_lvl = find_default_level(nb['cells'])
Expand All @@ -544,11 +543,9 @@ def convert_nb(fname, cls=HTMLExporter, template_file=None, exporter=None, dest=
nb['cells'] = [_func(c) for c in nb['cells']]
if execute: nb = execute_nb(nb, mod=mod)
nb['cells'] = [clean_exports(c) for c in nb['cells']]
call_cb('after_doc_nb_preprocess', nb, fname, 'html')
if exporter is None: exporter = nbdev_exporter(cls=cls, template_file=template_file)
with open(_nb2htmlfname(fname, dest=dest),'w') as f:
f.write(exporter.from_notebook_node(nb, resources=meta_jekyll)[0])
call_cb('after_doc_nb', fname, 'html')

# Cell
def _notebook2html(fname, cls=HTMLExporter, template_file=None, exporter=None, dest=None, execute=True):
Expand Down Expand Up @@ -596,14 +593,12 @@ def convert_md(fname, dest_path, img_path='docs/images/', jekyll=True):
if not img_path: img_path = fname.stem + '_files/'
Path(img_path).mkdir(exist_ok=True, parents=True)
nb = read_nb(fname)
call_cb('begin_doc_nb', nb, fname, 'md')
meta_jekyll = get_metadata(nb['cells'])
try: meta_jekyll['nb_path'] = str(fname.relative_to(Config().lib_path.parent))
except: meta_jekyll['nb_path'] = str(fname)
nb['cells'] = compose(*process_cells)(nb['cells'])
nb['cells'] = [compose(partial(adapt_img_path, fname=fname, dest=dest_path, jekyll=jekyll), *process_cell)(c)
for c in nb['cells']]
call_cb('after_doc_nb_preprocess', nb, fname, 'md')
fname = Path(fname).absolute()
dest_name = fname.with_suffix('.md').name
exp = nbdev_exporter(cls=MarkdownExporter, template_file='jekyll-md.tpl' if jekyll else 'md.tpl')
Expand All @@ -615,7 +610,6 @@ def convert_md(fname, dest_path, img_path='docs/images/', jekyll=True):
if hasattr(export[1]['outputs'], 'items'):
for n,o in export[1]['outputs'].items():
with open(Path(dest_path)/img_path/n, 'wb') as f: f.write(o)
call_cb('after_doc_nb', fname, 'md')

# Cell
_re_att_ref = re.compile(r' *!\[(.*)\]\(attachment:image.png(?: "(.*)")?\)')
Expand Down
15 changes: 1 addition & 14 deletions nbdev/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,4 @@ def re(self):
if not hasattr(Config(), 'lib_name'): raise Exception("Please fill in the library name in settings.ini.")
self.pat = self.pat.replace('LIB_NAME', Config().lib_name)
if self._re is None: self._re = re.compile(self.pat, self.flags)
return self._re

def call_cb(cb_name, *args):
"Calls `cb_name` from the `nbdev_callbacks` module but won't fail if it doesn't exist"
if 'nbdev_callbacks' not in globals():
_sys_path=sys.path
try:
cfg=Config()
sys.path=[str(cfg.config_file.parent/cfg.get('callbacks_path', '.'))]
try: import nbdev_callbacks
except: nbdev_callbacks={}
finally: sys.path=_sys_path
if not hasattr(nbdev_callbacks, cb_name): return args[0] if args else None
return getattr(nbdev_callbacks, cb_name)(*args)
return self._re
2 changes: 0 additions & 2 deletions nbdev/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ def test_nb(fn, flags=None):
if flags is None: flags = []
try:
nb = read_nb(fn)
nb = call_cb('begin_test_nb', nb, fn, flags)
for f in get_all_flags(nb['cells']):
if f not in flags: return
ep = NoExportPreprocessor(flags, timeout=600, kernel_name='python3')
pnb = nbformat.from_dict(nb)
ep.preprocess(pnb)
nb = call_cb('after_test_nb', fn)
finally: os.environ.pop("IN_TEST")
21 changes: 0 additions & 21 deletions nbdev_callbacks.py

This file was deleted.

Loading