import nblite.export.export_as_func as this_module
from nblite.export.export_as_func import get_nb_as_py_file, get_top_exports
export.export_as_func
show_doc(get_nb_as_py_file)
get_nb_as_py_file
str, lib_name: str, nb_format) get_nb_as_py_file(nb_path:
= Path('../../../test_proj/')
root_path = get_nb_as_py_file(root_path / 'nbs' / 'func_notebook.ipynb', 'my_module') py_content
show_doc(get_top_exports)
get_top_exports
str, nb_format) get_top_exports(nb_path:
Get the content of the notebook as a python file
= get_top_exports(root_path / 'nbs' / 'func_notebook.ipynb')
py_header_content print(py_header_content)
# %% top_export
def a_decorator(func):
def wrapper(*args, **kwargs):
print("Function is being called")
result = func(*args, **kwargs)
print("Function has been called")
return result
return wrapper
= get_nb_directives(root_path / 'nbs' / 'func_notebook.ipynb')
directives for directive in directives:
print(f"#|{directive['directive']} {directive['args']}")
#|default_exp test_func_nb
#|export_as_func true
#|hide
#|top_export
#|set_func_signature
#|export
#|func_return
= lookup_directive(get_nb_directives(root_path / 'nbs' / 'func_notebook.ipynb'), 'set_func_signature')
directive = directive['cell']['source_without_directives'].strip() func_signature_str
export_to_lib_as_func
str, lib_path: str, nb_format: str) export_to_lib_as_func(nb_path:
/ 'nbs' / 'func_notebook.ipynb', root_path / 'my_module'); export_to_lib_as_func(root_path