nbdev 3.3.29__tar.gz → 3.3.31__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.3.29/nbdev.egg-info → nbdev-3.3.31}/PKG-INFO +2 -2
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/__init__.py +1 -1
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/_modidx.py +2 -1
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/config.py +18 -12
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/diff_core.py +5 -67
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/doclinks.py +2 -4
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/maker.py +9 -8
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/quarto.py +2 -2
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/skill.py +1 -0
- {nbdev-3.3.29 → nbdev-3.3.31/nbdev.egg-info}/PKG-INFO +2 -2
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev.egg-info/requires.txt +1 -1
- {nbdev-3.3.29 → nbdev-3.3.31}/pyproject.toml +1 -1
- {nbdev-3.3.29 → nbdev-3.3.31}/tests/test_diff.py +1 -29
- {nbdev-3.3.29 → nbdev-3.3.31}/CONTRIBUTING.md +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/LICENSE +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/README.md +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/clean.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/cli.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/diff.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/export.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/extract_attachments.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/frontmatter.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/imports.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/merge.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/migrate.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/moddocs.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/process.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/processors.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/qmd.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/quarto_render.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/readme_filter.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/release.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/scrubmagics.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/serve.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/serve_drv.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/showdoc.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/sync.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev/test.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev.egg-info/SOURCES.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev.egg-info/entry_points.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/setup.cfg +0 -0
- {nbdev-3.3.29 → nbdev-3.3.31}/tests/test_quarto_render.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdev
|
|
3
|
-
Version: 3.3.
|
|
3
|
+
Version: 3.3.31
|
|
4
4
|
Summary: Create delightful software with Jupyter Notebooks
|
|
5
5
|
Author-email: "Jeremy Howard and the fast.ai community" <j@fast.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
15
15
|
Requires-Python: >=3.11
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: fastcore>=2.2.
|
|
18
|
+
Requires-Dist: fastcore>=2.2.45
|
|
19
19
|
Requires-Dist: execnb>=0.3.3
|
|
20
20
|
Requires-Dist: astunparse
|
|
21
21
|
Requires-Dist: ghapi>=2.0.2
|
|
@@ -6,7 +6,7 @@ Modules:
|
|
|
6
6
|
- `nbdev.moddocs`: # Module docs: creating them from existing notebooks
|
|
7
7
|
- `nbdev.skill`: Write, read and review nbdev notebooks as source, documentation, examples and tests. You MUST read this before any work on a project with notebooks."""
|
|
8
8
|
|
|
9
|
-
__version__ = "3.3.
|
|
9
|
+
__version__ = "3.3.31"
|
|
10
10
|
|
|
11
11
|
from .doclinks import nbdev_export
|
|
12
12
|
from .showdoc import show_doc
|
|
@@ -78,7 +78,8 @@ d = { 'settings': { 'branch': 'main',
|
|
|
78
78
|
'nbdev.config.update_llms_txt': ('api/config.html#update_llms_txt', 'nbdev/config.py'),
|
|
79
79
|
'nbdev.config.update_proj': ('api/config.html#update_proj', 'nbdev/config.py'),
|
|
80
80
|
'nbdev.config.update_version': ('api/config.html#update_version', 'nbdev/config.py'),
|
|
81
|
-
'nbdev.config.write_cells': ('api/config.html#write_cells', 'nbdev/config.py')
|
|
81
|
+
'nbdev.config.write_cells': ('api/config.html#write_cells', 'nbdev/config.py'),
|
|
82
|
+
'nbdev.config.write_if_changed': ('api/config.html#write_if_changed', 'nbdev/config.py')},
|
|
82
83
|
'nbdev.diff': { 'nbdev.diff._cell_changes': ('api/diff.html#_cell_changes', 'nbdev/diff.py'),
|
|
83
84
|
'nbdev.diff._diff_order': ('api/diff.html#_diff_order', 'nbdev/diff.py'),
|
|
84
85
|
'nbdev.diff._dtag': ('api/diff.html#_dtag', 'nbdev/diff.py'),
|
|
@@ -6,9 +6,9 @@ Docs: https://nbdev.fast.ai/api/config.html.md"""
|
|
|
6
6
|
|
|
7
7
|
# %% auto #0
|
|
8
8
|
__all__ = ['pyproject_nm', 'pyproject_tmpl', 'nbdev_defaults', 'pyproj_tmpl', 'nbdev_create_config', 'ConfigToml', 'get_config',
|
|
9
|
-
'is_nbdev', 'create_output', 'show_src', 'nbpath2html', 'nbpath2docurl', 'read_version',
|
|
10
|
-
'bump_version', 'update_version', 'update_proj', 'add_init', 'pkg_mdoc', 'update_init_mdoc',
|
|
11
|
-
'update_llms_txt', 'import_obj', 'write_cells']
|
|
9
|
+
'is_nbdev', 'write_if_changed', 'create_output', 'show_src', 'nbpath2html', 'nbpath2docurl', 'read_version',
|
|
10
|
+
'set_version', 'bump_version', 'update_version', 'update_proj', 'add_init', 'pkg_mdoc', 'update_init_mdoc',
|
|
11
|
+
'pkg_llms', 'update_llms_txt', 'import_obj', 'write_cells']
|
|
12
12
|
|
|
13
13
|
# %% ../nbs/api/01_config.ipynb #6fd14ecd
|
|
14
14
|
from fastcore.docments import *
|
|
@@ -246,6 +246,14 @@ def get_config(path=None, also_settings=False):
|
|
|
246
246
|
# %% ../nbs/api/01_config.ipynb #6939b40e
|
|
247
247
|
def is_nbdev(path=None): return _find_nbdev_pyproject(path) is not None
|
|
248
248
|
|
|
249
|
+
# %% ../nbs/api/01_config.ipynb #e3552092
|
|
250
|
+
def write_if_changed(p, txt, encoding='utf-8'):
|
|
251
|
+
"Write `txt` to `p` only if missing or content differs; return whether written"
|
|
252
|
+
p = Path(p)
|
|
253
|
+
if p.exists() and p.read_text(encoding=encoding) == txt: return False
|
|
254
|
+
p.write_text(txt, encoding=encoding)
|
|
255
|
+
return True
|
|
256
|
+
|
|
249
257
|
# %% ../nbs/api/01_config.ipynb #6e89fe6c
|
|
250
258
|
def create_output(txt, mime):
|
|
251
259
|
"Add a cell output containing `txt` of the `mime` text MIME sub-type"
|
|
@@ -306,12 +314,11 @@ def set_version(path, version):
|
|
|
306
314
|
path = Path(path)
|
|
307
315
|
path.mkdir(exist_ok=True, parents=True)
|
|
308
316
|
fname = path/_init
|
|
309
|
-
if not fname.exists(): fname.touch()
|
|
310
317
|
ver_line = f'__version__ = "{version}"'
|
|
311
|
-
code = fname.read_text()
|
|
318
|
+
code = fname.read_text(encoding='utf-8') if fname.exists() else ''
|
|
312
319
|
if _re_version.search(code) is None: code = ver_line + "\n" + code
|
|
313
320
|
else: code = _re_version.sub(ver_line, code)
|
|
314
|
-
fname
|
|
321
|
+
write_if_changed(fname, code)
|
|
315
322
|
|
|
316
323
|
# %% ../nbs/api/01_config.ipynb #d00889e5
|
|
317
324
|
def bump_version(v, part=None, unbump=False):
|
|
@@ -341,11 +348,10 @@ def _has_py(fs): return any(1 for f in fs if f.endswith('.py'))
|
|
|
341
348
|
def update_proj(path):
|
|
342
349
|
"Create or update `pyproject.toml` in the project root."
|
|
343
350
|
fname = path/_pyproj
|
|
344
|
-
|
|
345
|
-
txt = fname.read_text()
|
|
351
|
+
txt = fname.read_text(encoding='utf-8') if fname.exists() else pyproj_tmpl
|
|
346
352
|
txt = _re_proj.sub(rf'\1name = "{get_config().lib_name}"', txt)
|
|
347
353
|
txt = _re_reqpy.sub(f'requires-python = ">={get_config().min_python}"', txt)
|
|
348
|
-
fname
|
|
354
|
+
write_if_changed(fname, txt)
|
|
349
355
|
|
|
350
356
|
# %% ../nbs/api/01_config.ipynb #bdf57184
|
|
351
357
|
def add_init(path=None):
|
|
@@ -357,7 +363,7 @@ def add_init(path=None):
|
|
|
357
363
|
for r,ds,fs in os.walk(path, topdown=False):
|
|
358
364
|
r = Path(r)
|
|
359
365
|
subds = (os.listdir(r/d) for d in ds)
|
|
360
|
-
if _has_py(fs) or any(filter(_has_py, subds)) and not (r/_init).exists(): (r/_init).touch()
|
|
366
|
+
if (_has_py(fs) or any(filter(_has_py, subds))) and not (r/_init).exists(): (r/_init).touch()
|
|
361
367
|
if get_config().get('put_version_in_init', True): update_version(path)
|
|
362
368
|
if get_config().get('update_pyproject', True): update_proj(get_config().config_path)
|
|
363
369
|
update_init_mdoc(path)
|
|
@@ -434,7 +440,7 @@ def update_init_mdoc(path=None, desc=None):
|
|
|
434
440
|
mdoc = desc if desc is not None else get_config().description
|
|
435
441
|
res = f'"""{mdoc}"""\n'
|
|
436
442
|
if rest.strip(): res += '\n'+rest.lstrip('\n')
|
|
437
|
-
fn
|
|
443
|
+
write_if_changed(fn, res)
|
|
438
444
|
|
|
439
445
|
# %% ../nbs/api/01_config.ipynb #f9912ef7
|
|
440
446
|
_llms_marker = '<!-- Generated by nbdev-export; edit the index notebook, not this file -->'
|
|
@@ -462,7 +468,7 @@ def update_llms_txt(path=None, fn=None, desc=None, index_nb=None):
|
|
|
462
468
|
if not txt:
|
|
463
469
|
if fn.exists(): fn.unlink()
|
|
464
470
|
return
|
|
465
|
-
fn
|
|
471
|
+
write_if_changed(fn, txt)
|
|
466
472
|
|
|
467
473
|
# %% ../nbs/api/01_config.ipynb #95cebda6
|
|
468
474
|
def import_obj(s):
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"Word-level terminal diffs of plain text, shared by file and notebook rendering."
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from fastcore.diff import MIN_RATIO, source_diff, diff_lines
|
|
4
4
|
from fastcore.utils import *
|
|
5
5
|
|
|
6
6
|
__all__ = ['MAXLEN', 'MIN_RATIO', 'truncate', 'render_line', 'source_diff', 'render_source_diff']
|
|
7
7
|
|
|
8
8
|
MAXLEN = 180 # Most visible characters per displayed line; 0 means unlimited
|
|
9
|
-
MIN_RATIO = 0.5 # Minimum shared-word similarity for merging a changed line pair
|
|
10
9
|
_dcolors = {'## …':'\x1b[34m', '# ':'\x1b[1;7m', '#':'\x1b[1m', '-':'\x1b[31m', '+':'\x1b[32m', '@':'\x1b[36m'}
|
|
11
10
|
_wcolors = {'-':'\x1b[31;9m', '+':'\x1b[32m'}
|
|
12
11
|
_wmarks = {'-':('[-','-]'), '+':('{+','+}')}
|
|
@@ -29,67 +28,6 @@ def render_line(
|
|
|
29
28
|
return f'{c}{line}\x1b[0m' if c else line
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
def _source_lines(old, new, context, final_newline):
|
|
33
|
-
def lines(s): return s.splitlines(keepends=True) if final_newline else [l+'\n' for l in s.splitlines()]
|
|
34
|
-
return list(unified_diff(lines(old), lines(new), n=context))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def source_diff(
|
|
38
|
-
old_source, # Original source string
|
|
39
|
-
new_source, # New source string
|
|
40
|
-
context=3, # Unchanged lines shown either side of a change
|
|
41
|
-
final_newline=True # Distinguish a missing final newline (unnecessary for notebook cells)?
|
|
42
|
-
):
|
|
43
|
-
"Unified source diff, including missing-final-newline markers."
|
|
44
|
-
lines = _source_lines(old_source, new_source, context, final_newline)
|
|
45
|
-
return '\n'.join(l.removesuffix('\n') + ('' if l.endswith('\n') else '\n\') for l in lines)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def _word_diff(a, b):
|
|
49
|
-
if a==b: return None
|
|
50
|
-
if SequenceMatcher(None, re.findall(r'\w+', a), re.findall(r'\w+', b), autojunk=False).ratio()<MIN_RATIO: return None
|
|
51
|
-
ta,tb = (re.findall(r'\w+|\s+|[^\w\s]', s) for s in (a,b))
|
|
52
|
-
ops = SequenceMatcher(lambda t: t.isspace(), ta, tb, autojunk=False).get_opcodes()
|
|
53
|
-
def width(op): return max(sum(map(len, ta[op[1]:op[2]])), sum(map(len, tb[op[3]:op[4]])))
|
|
54
|
-
groups = []
|
|
55
|
-
for i,(tag,i1,i2,j1,j2) in enumerate(ops):
|
|
56
|
-
# Short coincidences inside a rewrite should not split it into alternating words.
|
|
57
|
-
if tag=='equal' and 0<i<len(ops)-1 and width(ops[i])<min(width(ops[i-1]),width(ops[i+1])): tag = 'replace'
|
|
58
|
-
if tag!='equal' and groups and groups[-1][0]!='equal':
|
|
59
|
-
_,i1,_,j1,_ = groups.pop()
|
|
60
|
-
tag = 'replace'
|
|
61
|
-
groups.append((tag,i1,i2,j1,j2))
|
|
62
|
-
res = []
|
|
63
|
-
for tag,i1,i2,j1,j2 in groups:
|
|
64
|
-
if tag=='equal': res.append((' ', ''.join(ta[i1:i2])))
|
|
65
|
-
else:
|
|
66
|
-
if i2>i1: res.append(('-', ''.join(ta[i1:i2])))
|
|
67
|
-
if j2>j1: res.append(('+', ''.join(tb[j1:j2])))
|
|
68
|
-
return res
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def _refine(lines):
|
|
72
|
-
res,i = [],0
|
|
73
|
-
while i<len(lines):
|
|
74
|
-
if not lines[i].startswith('-'):
|
|
75
|
-
res.append(lines[i])
|
|
76
|
-
i += 1
|
|
77
|
-
continue
|
|
78
|
-
j = i
|
|
79
|
-
while j<len(lines) and lines[j].startswith('-'): j += 1
|
|
80
|
-
k = j
|
|
81
|
-
while k<len(lines) and lines[k].startswith('+'): k += 1
|
|
82
|
-
olds,news = lines[i:j],lines[j:k]
|
|
83
|
-
bo,bn = [],[]
|
|
84
|
-
for o,n in zip(olds,news):
|
|
85
|
-
w = _word_diff(o[1:], n[1:])
|
|
86
|
-
if w: res,bo,bn = res+bo+bn+[w],[],[]
|
|
87
|
-
else: bo,bn = bo+[o],bn+[n]
|
|
88
|
-
res += bo+olds[len(news):]+bn+news[len(olds):]
|
|
89
|
-
i = k
|
|
90
|
-
return res
|
|
91
|
-
|
|
92
|
-
|
|
93
31
|
def _slice_spans(spans, start, end):
|
|
94
32
|
res,pos = [],0
|
|
95
33
|
for k,t in spans:
|
|
@@ -138,10 +76,10 @@ def render_source_diff(
|
|
|
138
76
|
final_newline=True # Distinguish a missing final newline (unnecessary for notebook cells)?
|
|
139
77
|
):
|
|
140
78
|
"Render source changes, cropping long word-diff lines around the first change."
|
|
141
|
-
|
|
142
|
-
if not
|
|
143
|
-
|
|
144
|
-
|
|
79
|
+
rows = diff_lines(old_source, new_source, context=context, final_newline=final_newline, min_ratio=MIN_RATIO)
|
|
80
|
+
if not rows: return ''
|
|
81
|
+
res = [_render_spans(spans, maxlen, color) if kind=='!' else render_line(kind+''.join(t for _,t in spans), maxlen, color)
|
|
82
|
+
for kind,spans in rows]
|
|
145
83
|
if final_newline:
|
|
146
84
|
for name,text in (('old',old_source), ('new',new_source)):
|
|
147
85
|
if text and not text.endswith('\n'): res.append(render_line(fr'\ No newline at end of {name} file', maxlen, color))
|
|
@@ -103,15 +103,13 @@ def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
|
|
|
103
103
|
if os.environ.get('IN_TEST',0): return
|
|
104
104
|
idxfile = dest/'_modidx.py'
|
|
105
105
|
if skip_exists and idxfile.exists(): return
|
|
106
|
-
|
|
107
|
-
if idxfile.exists(): res = exec_local(idxfile.read_text(encoding='utf-8'), 'd')
|
|
108
|
-
else: res = dict(syms={}, settings={})
|
|
106
|
+
res = dict(syms={}, settings={})
|
|
109
107
|
res['settings'] = {k:v for k,v in get_config().d.items() if k in ('doc_host','doc_baseurl','lib_path','git_url','branch')}
|
|
110
108
|
code_root = dest.parent.resolve()
|
|
111
109
|
for file in globtastic(dest, file_glob="*.py", skip_file_re='^_', skip_folder_re=r"\.ipynb_checkpoints"):
|
|
112
110
|
try: res['syms'].update(_get_modidx((dest.parent/file).resolve(), code_root, nbs_path=nbs_path))
|
|
113
111
|
except ValueError: pass
|
|
114
|
-
idxfile
|
|
112
|
+
write_if_changed(idxfile, "# Autogenerated by nbdev\n\nd = "+pformat(res, width=140, indent=2, compact=True)+'\n')
|
|
115
113
|
|
|
116
114
|
# %% ../nbs/api/05_doclinks.ipynb #0b3e1605
|
|
117
115
|
@delegates(globtastic)
|
|
@@ -57,7 +57,7 @@ def update_var(varname, func, fn=None, code=None):
|
|
|
57
57
|
del(lines[start:end])
|
|
58
58
|
lines.insert(start, f"{varname} = {res}")
|
|
59
59
|
code = '\n'.join(lines)
|
|
60
|
-
if fn: fn
|
|
60
|
+
if fn: write_if_changed(fn, code)
|
|
61
61
|
else: return code
|
|
62
62
|
|
|
63
63
|
# %% ../nbs/api/02_maker.ipynb #a676a7ea
|
|
@@ -214,13 +214,14 @@ def make(self:ModuleMaker, cells, all_cells=None, lib_path=None):
|
|
|
214
214
|
last_future = self._last_future(cells) if len(all_cells)>0 else 0
|
|
215
215
|
tw = TextWrapper(width=120, initial_indent='', subsequent_indent=' '*11, break_long_words=False)
|
|
216
216
|
all_str = '\n'.join(tw.wrap(str(_all)))
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
217
|
+
buf = io.StringIO()
|
|
218
|
+
buf.write(_retr_mdoc(cells, self.nb_path))
|
|
219
|
+
buf.write(f"# AUTOGENERATED! DO NOT EDIT! File to edit: {self.dest2nb}.")
|
|
220
|
+
if last_future > 0: write_cells(cells[:last_future], self.hdr, buf)
|
|
221
|
+
if self.parse and not self.solo_nb: buf.write(f"\n\n# %% auto #0\n__all__ = {all_str}")
|
|
222
|
+
write_cells(cells[last_future:], self.hdr, buf, solo_nb=self.solo_nb)
|
|
223
|
+
buf.write('\n')
|
|
224
|
+
write_if_changed(self.fname, buf.getvalue())
|
|
224
225
|
|
|
225
226
|
# %% ../nbs/api/02_maker.ipynb #6515a9d7
|
|
226
227
|
@patch
|
|
@@ -139,7 +139,7 @@ def nbdev_sidebar(
|
|
|
139
139
|
yml = yaml.dump(parsed_struct, Dumper=IndentDumper, sort_keys=False)
|
|
140
140
|
|
|
141
141
|
if printit: return print(yml)
|
|
142
|
-
|
|
142
|
+
write_if_changed(yml_path, yml)
|
|
143
143
|
|
|
144
144
|
# %% ../nbs/api/14_quarto.ipynb #aabf2f15
|
|
145
145
|
_quarto_yml="""project:
|
|
@@ -191,7 +191,7 @@ def refresh_quarto_yml():
|
|
|
191
191
|
vals['doc_path'] = cfg.doc_path.name
|
|
192
192
|
if 'title' not in vals: vals['title'] = vals['lib_name']
|
|
193
193
|
text = _nbdev_yml.format(**vals)
|
|
194
|
-
|
|
194
|
+
write_if_changed(ny, text)
|
|
195
195
|
qy = cfg.nbs_path/'_quarto.yml'
|
|
196
196
|
if 'custom_quarto_yml' in cfg: print("NB: `_quarto.yml` is no longer auto-updated. Remove `custom_quarto_yml` from `pyproject.toml`")
|
|
197
197
|
if qy.exists() and not str2bool(cfg.get('custom_quarto_yml', True)): qy.unlink()
|
|
@@ -8,6 +8,7 @@ notation: /why
|
|
|
8
8
|
- published library notebooks: implementation, explanation, examples, outputs, failure demos interleaved /read top to bottom; internal project: match neighbours
|
|
9
9
|
- per file: `# AUTOGENERATED! DO NOT EDIT!` → edit its notebook (`# %% ../nbs/04_usage.ipynb #a45f753a` names the cell), never module, `__all__`, `_modidx.py`, module docstring /`nbdev-export` regenerates them; unmarked: hand-written
|
|
10
10
|
- understand and review through notebooks and their git diff, not generated modules /no prose, examples, tests there
|
|
11
|
+
- `info_md` or traceback `.py` paths in nbdev packages (siblings too): `nbrg` in `nbs/`, not exported `.py`
|
|
11
12
|
- notebooks teach APIs, lessons are the tests; plain `.py`, tested by `tests/*.py`: rare dense mechanism iterated under pytest; never add pytests to a project lacking them unless asked
|
|
12
13
|
- project questions: `nbs/index.ipynb`, README's source; after editing it: `nbdev-readme`
|
|
13
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdev
|
|
3
|
-
Version: 3.3.
|
|
3
|
+
Version: 3.3.31
|
|
4
4
|
Summary: Create delightful software with Jupyter Notebooks
|
|
5
5
|
Author-email: "Jeremy Howard and the fast.ai community" <j@fast.ai>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
15
15
|
Requires-Python: >=3.11
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: fastcore>=2.2.
|
|
18
|
+
Requires-Dist: fastcore>=2.2.45
|
|
19
19
|
Requires-Dist: execnb>=0.3.3
|
|
20
20
|
Requires-Dist: astunparse
|
|
21
21
|
Requires-Dist: ghapi>=2.0.2
|
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
|
18
18
|
"Programming Language :: Python :: 3 :: Only",
|
|
19
19
|
]
|
|
20
20
|
dynamic = ["version"]
|
|
21
|
-
dependencies = [ "fastcore>=2.2.
|
|
21
|
+
dependencies = [ "fastcore>=2.2.45", "execnb>=0.3.3", "astunparse", "ghapi>=2.0.2", "watchdog", "asttokens",
|
|
22
22
|
"setuptools", "build", "fastgit>=0.0.7", "pyyaml", ]
|
|
23
23
|
|
|
24
24
|
[project.optional-dependencies]
|
|
@@ -1,32 +1,6 @@
|
|
|
1
1
|
import os, re, shlex, subprocess, sys
|
|
2
2
|
from fastcore.nbio import new_nb, write_nb
|
|
3
|
-
from nbdev.diff_core import render_source_diff
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def test_source_changes():
|
|
7
|
-
old = 'x=1\ny=2\nz=3\nk=4\n'
|
|
8
|
-
new = 'x = 100\ny=2\nw=5\nq=6\n'
|
|
9
|
-
result = render_source_diff(old, new)
|
|
10
|
-
assert '!x{+ +}=[-1-]{+ 100+}' in result
|
|
11
|
-
assert '-z=3\n-k=4\n+w=5\n+q=6' in result
|
|
12
|
-
assert '+hello' in render_source_diff('', 'hello\n')
|
|
13
|
-
assert '-hello' in render_source_diff('hello\n', '')
|
|
14
|
-
assert not render_source_diff(old, old)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def test_phrase_changes():
|
|
18
|
-
old = 'selects the fields, shown by the vectors'
|
|
19
|
-
new = 'reverses the coordinates, arranged in two columns'
|
|
20
|
-
suffix = '. Dragging either point redraws both points.\n'
|
|
21
|
-
for color in (False, True):
|
|
22
|
-
result = render_source_diff('The model '+old+suffix, 'The model '+new+suffix, color=color)
|
|
23
|
-
phrase = f'\x1b[31;9m{old}\x1b[0m\x1b[32m{new}\x1b[0m' if color else f'[-{old}-]{{+{new}+}}'
|
|
24
|
-
assert phrase in result and suffix.rstrip() in result
|
|
25
|
-
shared = ' while both points retain their positions '
|
|
26
|
-
result = render_source_diff('We select fields'+shared+'using the old formula.\n',
|
|
27
|
-
'We reverse coordinates'+shared+'using the new expression.\n')
|
|
28
|
-
assert '[-select fields-]{+reverse coordinates+}' in result and shared in result
|
|
29
|
-
assert '[-old formula-]{+new expression+}' in result
|
|
3
|
+
from nbdev.diff_core import render_source_diff
|
|
30
4
|
|
|
31
5
|
|
|
32
6
|
def test_long_line_changes():
|
|
@@ -49,10 +23,8 @@ def test_long_line_changes():
|
|
|
49
23
|
|
|
50
24
|
|
|
51
25
|
def test_final_newline():
|
|
52
|
-
assert r'' in source_diff('hello\n', 'hello')
|
|
53
26
|
assert 'new file' in render_source_diff('hello\n', 'hello')
|
|
54
27
|
assert 'old file' in render_source_diff('hello', 'hello\n')
|
|
55
|
-
assert not render_source_diff('hello\n', 'hello', final_newline=False)
|
|
56
28
|
|
|
57
29
|
|
|
58
30
|
def test_git_driver(tmp_path):
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|