export.export_as_func

import nblite.export.export_as_func as this_module
from nblite.export.export_as_func import get_nb_as_py_file, get_top_exports
show_doc(get_nb_as_py_file)

get_nb_as_py_file

get_nb_as_py_file(nb_path: str, lib_name: str, nb_format)

root_path = Path('../../../test_proj/')
py_content = get_nb_as_py_file(root_path / 'nbs' / 'func_notebook.ipynb', 'my_module')
show_doc(get_top_exports)

get_top_exports

get_top_exports(nb_path: str, nb_format)

Get the content of the notebook as a python file


py_header_content = get_top_exports(root_path / 'nbs' / 'func_notebook.ipynb')
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
directives = get_nb_directives(root_path / 'nbs' / 'func_notebook.ipynb')
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 
directive = lookup_directive(get_nb_directives(root_path / 'nbs' / 'func_notebook.ipynb'), 'set_func_signature')
func_signature_str = directive['cell']['source_without_directives'].strip()    

export_to_lib_as_func

export_to_lib_as_func(nb_path: str, lib_path: str, nb_format: str)

export_to_lib_as_func(root_path / 'nbs' / 'func_notebook.ipynb', root_path / 'my_module');