nbdev 3.0.7__tar.gz → 3.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nbdev-3.0.7/nbdev.egg-info → nbdev-3.0.8}/PKG-INFO +1 -1
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/__init__.py +1 -1
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/_modidx.py +3 -5
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/config.py +11 -3
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/doclinks.py +5 -5
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/export.py +1 -32
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/processors.py +3 -9
- nbdev-3.0.8/nbdev/scrubmagics.py +13 -0
- {nbdev-3.0.7 → nbdev-3.0.8/nbdev.egg-info}/PKG-INFO +1 -1
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev.egg-info/SOURCES.txt +1 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/CONTRIBUTING.md +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/LICENSE +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/MANIFEST.in +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/README.md +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/clean.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/cli.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/diff.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/extract_attachments.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/frontmatter.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/imports.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/maker.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/merge.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/migrate.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/process.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/qmd.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/quarto.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/release.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/serve.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/serve_drv.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/showdoc.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/sync.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev/test.py +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev.egg-info/entry_points.txt +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev.egg-info/requires.txt +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/pyproject.toml +0 -0
- {nbdev-3.0.7 → nbdev-3.0.8}/setup.cfg +0 -0
|
@@ -49,6 +49,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
49
49
|
'nbdev.config.bump_version': ('api/config.html#bump_version', 'nbdev/config.py'),
|
|
50
50
|
'nbdev.config.create_output': ('api/config.html#create_output', 'nbdev/config.py'),
|
|
51
51
|
'nbdev.config.get_config': ('api/config.html#get_config', 'nbdev/config.py'),
|
|
52
|
+
'nbdev.config.import_obj': ('api/config.html#import_obj', 'nbdev/config.py'),
|
|
52
53
|
'nbdev.config.is_nbdev': ('api/config.html#is_nbdev', 'nbdev/config.py'),
|
|
53
54
|
'nbdev.config.nbdev_create_config': ('api/config.html#nbdev_create_config', 'nbdev/config.py'),
|
|
54
55
|
'nbdev.config.read_version': ('api/config.html#read_version', 'nbdev/config.py'),
|
|
@@ -98,10 +99,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
98
99
|
'nbdev.export.ExportModuleProc._export_': ('api/export.html#exportmoduleproc._export_', 'nbdev/export.py'),
|
|
99
100
|
'nbdev.export.ExportModuleProc._exporti_': ('api/export.html#exportmoduleproc._exporti_', 'nbdev/export.py'),
|
|
100
101
|
'nbdev.export.ExportModuleProc.begin': ('api/export.html#exportmoduleproc.begin', 'nbdev/export.py'),
|
|
101
|
-
'nbdev.export.
|
|
102
|
-
'nbdev.export.nb_export': ('api/export.html#nb_export', 'nbdev/export.py'),
|
|
103
|
-
'nbdev.export.optional_procs': ('api/export.html#optional_procs', 'nbdev/export.py'),
|
|
104
|
-
'nbdev.export.scrub_magics': ('api/export.html#scrub_magics', 'nbdev/export.py')},
|
|
102
|
+
'nbdev.export.nb_export': ('api/export.html#nb_export', 'nbdev/export.py')},
|
|
105
103
|
'nbdev.extract_attachments': {},
|
|
106
104
|
'nbdev.frontmatter': { 'nbdev.frontmatter.FrontmatterProc': ('api/frontmatter.html#frontmatterproc', 'nbdev/frontmatter.py'),
|
|
107
105
|
'nbdev.frontmatter.FrontmatterProc._update': ( 'api/frontmatter.html#frontmatterproc._update',
|
|
@@ -222,7 +220,6 @@ d = { 'settings': { 'branch': 'main',
|
|
|
222
220
|
'nbdev.processors._default_exp': ('api/processors.html#_default_exp', 'nbdev/processors.py'),
|
|
223
221
|
'nbdev.processors._do_eval': ('api/processors.html#_do_eval', 'nbdev/processors.py'),
|
|
224
222
|
'nbdev.processors._get_nm': ('api/processors.html#_get_nm', 'nbdev/processors.py'),
|
|
225
|
-
'nbdev.processors._import_obj': ('api/processors.html#_import_obj', 'nbdev/processors.py'),
|
|
226
223
|
'nbdev.processors._is_showdoc': ('api/processors.html#_is_showdoc', 'nbdev/processors.py'),
|
|
227
224
|
'nbdev.processors._re_hideline': ('api/processors.html#_re_hideline', 'nbdev/processors.py'),
|
|
228
225
|
'nbdev.processors._show_docs': ('api/processors.html#_show_docs', 'nbdev/processors.py'),
|
|
@@ -333,6 +330,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
333
330
|
'nbdev.release.release_pypi': ('api/release.html#release_pypi', 'nbdev/release.py'),
|
|
334
331
|
'nbdev.release.write_conda_meta': ('api/release.html#write_conda_meta', 'nbdev/release.py'),
|
|
335
332
|
'nbdev.release.write_requirements': ('api/release.html#write_requirements', 'nbdev/release.py')},
|
|
333
|
+
'nbdev.scrubmagics': {},
|
|
336
334
|
'nbdev.serve': { 'nbdev.serve._is_qpy': ('api/serve.html#_is_qpy', 'nbdev/serve.py'),
|
|
337
335
|
'nbdev.serve._proc_file': ('api/serve.html#_proc_file', 'nbdev/serve.py'),
|
|
338
336
|
'nbdev.serve.proc_nbs': ('api/serve.html#proc_nbs', 'nbdev/serve.py')},
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# %% auto #0
|
|
6
6
|
__all__ = ['pyproject_nm', 'pyproject_tmpl', 'nbdev_defaults', 'pyproj_tmpl', 'nbdev_create_config', 'ConfigToml', 'get_config',
|
|
7
7
|
'is_nbdev', 'create_output', 'show_src', 'read_version', 'set_version', 'bump_version', 'update_version',
|
|
8
|
-
'update_proj', 'add_init', 'write_cells']
|
|
8
|
+
'update_proj', 'add_init', 'import_obj', 'write_cells']
|
|
9
9
|
|
|
10
10
|
# %% ../nbs/api/01_config.ipynb #6fd14ecd
|
|
11
11
|
from datetime import datetime
|
|
@@ -16,7 +16,7 @@ from fastcore.script import *
|
|
|
16
16
|
from fastcore.style import *
|
|
17
17
|
from fastcore.xdg import *
|
|
18
18
|
|
|
19
|
-
import ast,warnings
|
|
19
|
+
import ast,importlib,warnings
|
|
20
20
|
from IPython.display import Markdown
|
|
21
21
|
from execnb.nbio import read_nb,NbCell
|
|
22
22
|
from urllib.error import HTTPError
|
|
@@ -167,7 +167,8 @@ def _find_nbdev_pyproject(path=None):
|
|
|
167
167
|
|
|
168
168
|
# %% ../nbs/api/01_config.ipynb #3dac70e0
|
|
169
169
|
nbdev_defaults = dict(nbs_path='nbs', doc_path='_docs', tst_flags='notest', recursive=True, readme_nb='index.ipynb',
|
|
170
|
-
clean_ids=True, clear_all=False, put_version_in_init=True, jupyter_hooks=False,
|
|
170
|
+
clean_ids=True, clear_all=False, put_version_in_init=True, jupyter_hooks=False, branch='main',
|
|
171
|
+
doc_procs=[], export_procs=[])
|
|
171
172
|
|
|
172
173
|
_path_keys = 'lib_path', 'nbs_path', 'doc_path'
|
|
173
174
|
|
|
@@ -337,6 +338,13 @@ def add_init(path=None):
|
|
|
337
338
|
if get_config().get('put_version_in_init', True): update_version(path)
|
|
338
339
|
if get_config().get('update_pyproject', True): update_proj(path.parent)
|
|
339
340
|
|
|
341
|
+
# %% ../nbs/api/01_config.ipynb #95cebda6
|
|
342
|
+
def import_obj(s):
|
|
343
|
+
"Import and return `module:obj` string"
|
|
344
|
+
mod_nm, obj_nm = s.split(':')
|
|
345
|
+
mod = importlib.import_module(mod_nm)
|
|
346
|
+
return getattr(mod, obj_nm)
|
|
347
|
+
|
|
340
348
|
# %% ../nbs/api/01_config.ipynb #cdd05b4c
|
|
341
349
|
def write_cells(cells, hdr, file, solo_nb=False):
|
|
342
350
|
"Write `cells` to `file` along with header `hdr` (mainly for nbdev internal use)."
|
|
@@ -143,17 +143,17 @@ def nbglob_cli(
|
|
|
143
143
|
@delegates(nbglob_cli)
|
|
144
144
|
def nbdev_export(
|
|
145
145
|
path:str=None, # Path or filename
|
|
146
|
-
procs:
|
|
146
|
+
procs:str='', # Space-separated `module:name` processors to use (or set `export_procs` in pyproject.toml)
|
|
147
147
|
**kwargs):
|
|
148
148
|
"Export notebooks in `path` to Python modules"
|
|
149
149
|
if os.environ.get('IN_TEST',0): return
|
|
150
150
|
if not is_nbdev(): raise Exception('`nbdev_export` must be called from a directory within a nbdev project.')
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
cfg = get_config()
|
|
152
|
+
procs = procs.split() if procs else cfg.get('export_procs', [])
|
|
153
|
+
procs = [import_obj(p) for p in procs] if procs else None
|
|
154
154
|
files = nbglob(path=path, as_path=True, **kwargs).sorted('name')
|
|
155
155
|
for f in files: nb_export(f, procs=procs)
|
|
156
|
-
add_init(
|
|
156
|
+
add_init(cfg.lib_path)
|
|
157
157
|
_build_modidx()
|
|
158
158
|
|
|
159
159
|
# %% ../nbs/api/05_doclinks.ipynb #3134c22b
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/04_export.ipynb.
|
|
4
4
|
|
|
5
5
|
# %% auto #0
|
|
6
|
-
__all__ = ['ExportModuleProc', '
|
|
6
|
+
__all__ = ['ExportModuleProc', 'nb_export']
|
|
7
7
|
|
|
8
8
|
# %% ../nbs/api/04_export.ipynb #3b932371
|
|
9
9
|
from .config import *
|
|
@@ -33,37 +33,6 @@ class ExportModuleProc:
|
|
|
33
33
|
if cell.cell_type=='markdown' and src.startswith('# '): self.modules['#'].append(cell)
|
|
34
34
|
_exports_=_export_
|
|
35
35
|
|
|
36
|
-
# %% ../nbs/api/04_export.ipynb #6f524839
|
|
37
|
-
def black_format(cell, # Cell to format
|
|
38
|
-
force=False): # Turn black formatting on regardless of pyproject.toml
|
|
39
|
-
"Processor to format code with `black`"
|
|
40
|
-
cfg = get_config()
|
|
41
|
-
if (not cfg.black_formatting and not force) or cell.cell_type != 'code': return
|
|
42
|
-
try: import black
|
|
43
|
-
except: raise ImportError("You must install black: `pip install black` if you wish to use black formatting with nbdev")
|
|
44
|
-
else:
|
|
45
|
-
_format_str = partial(black.format_str, mode = black.Mode())
|
|
46
|
-
try: cell.source = _format_str(cell.source).strip()
|
|
47
|
-
except: pass
|
|
48
|
-
|
|
49
|
-
# %% ../nbs/api/04_export.ipynb #aed6a875
|
|
50
|
-
# includes the newline, because calling .strip() would affect all cells.
|
|
51
|
-
_magics_pattern = re.compile(r'^\s*(%%|%).*\n?', re.MULTILINE)
|
|
52
|
-
|
|
53
|
-
def scrub_magics(cell): # Cell to format
|
|
54
|
-
"Processor to remove cell magics from exported code"
|
|
55
|
-
cfg = get_config()
|
|
56
|
-
if cell.cell_type != 'code': return
|
|
57
|
-
try: cell.source = _magics_pattern.sub('', cell.source)
|
|
58
|
-
except: pass
|
|
59
|
-
|
|
60
|
-
# %% ../nbs/api/04_export.ipynb #d4a5fd8c
|
|
61
|
-
import nbdev.export
|
|
62
|
-
def optional_procs():
|
|
63
|
-
"An explicit list of processors that could be used by `nb_export`"
|
|
64
|
-
return L([p for p in nbdev.export.__all__
|
|
65
|
-
if p not in ["nb_export", "nb_export_cli", "ExportModuleProc", "optional_procs"]])
|
|
66
|
-
|
|
67
36
|
# %% ../nbs/api/04_export.ipynb #76717e36
|
|
68
37
|
def nb_export(nbname:str, # Filename of notebook
|
|
69
38
|
lib_path:str=None, # Path to destination library. If not in a nbdev project, defaults to current directory.
|
|
@@ -9,7 +9,6 @@ __all__ = ['populate_language', 'insert_warning', 'cell_lang', 'add_show_docs',
|
|
|
9
9
|
|
|
10
10
|
# %% ../nbs/api/10_processors.ipynb #2398f5ef-06d3-4890-8a54-7cf4f81f3894
|
|
11
11
|
import ast
|
|
12
|
-
import importlib
|
|
13
12
|
|
|
14
13
|
from .config import *
|
|
15
14
|
from .imports import *
|
|
@@ -261,18 +260,13 @@ class exec_show_docs(Processor):
|
|
|
261
260
|
widgets = {**old, **new, 'state': {**old.get('state', {}), **new['state']}}
|
|
262
261
|
self.nb.metadata['widgets'] = {mimetype: widgets}
|
|
263
262
|
|
|
264
|
-
# %% ../nbs/api/10_processors.ipynb #a761e07c
|
|
265
|
-
def _import_obj(s):
|
|
266
|
-
mod_nm, obj_nm = s.split(':')
|
|
267
|
-
mod = importlib.import_module(mod_nm)
|
|
268
|
-
return getattr(mod, obj_nm)
|
|
269
|
-
|
|
270
263
|
# %% ../nbs/api/10_processors.ipynb #4b450cff
|
|
271
264
|
class FilterDefaults:
|
|
272
265
|
"Override `FilterDefaults` to change which notebook processors are used"
|
|
273
266
|
def xtra_procs(self):
|
|
274
|
-
imps = get_config().get('
|
|
275
|
-
|
|
267
|
+
imps = get_config().get('doc_procs', [])
|
|
268
|
+
if isinstance(imps, str): imps = imps.split()
|
|
269
|
+
return [import_obj(o) for o in imps]
|
|
276
270
|
|
|
277
271
|
def base_procs(self):
|
|
278
272
|
return [FrontmatterProc, populate_language, add_show_docs, insert_warning,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Scrub Jupyter magics from exported code"""
|
|
2
|
+
|
|
3
|
+
__all__ = ['scrub_magics']
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
_magics_pattern = re.compile(r'^\s*(%%|%).*\n?', re.MULTILINE)
|
|
8
|
+
|
|
9
|
+
def scrub_magics(cell):
|
|
10
|
+
"Remove Jupyter magic lines (e.g. %%time, %matplotlib) from exported code cells"
|
|
11
|
+
if cell.cell_type != 'code': return
|
|
12
|
+
try: cell.source = _magics_pattern.sub('', cell.source)
|
|
13
|
+
except: pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|