nbdev 3.3.29__tar.gz → 3.3.30__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.30}/PKG-INFO +2 -2
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/__init__.py +1 -1
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/diff_core.py +5 -67
- {nbdev-3.3.29 → nbdev-3.3.30/nbdev.egg-info}/PKG-INFO +2 -2
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev.egg-info/requires.txt +1 -1
- {nbdev-3.3.29 → nbdev-3.3.30}/pyproject.toml +1 -1
- {nbdev-3.3.29 → nbdev-3.3.30}/tests/test_diff.py +1 -29
- {nbdev-3.3.29 → nbdev-3.3.30}/CONTRIBUTING.md +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/LICENSE +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/README.md +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/_modidx.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/clean.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/cli.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/config.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/diff.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/doclinks.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/export.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/extract_attachments.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/frontmatter.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/imports.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/maker.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/merge.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/migrate.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/moddocs.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/process.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/processors.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/qmd.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/quarto.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/quarto_render.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/readme_filter.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/release.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/scrubmagics.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/serve.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/serve_drv.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/showdoc.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/skill.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/sync.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev/test.py +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev.egg-info/SOURCES.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev.egg-info/entry_points.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/setup.cfg +0 -0
- {nbdev-3.3.29 → nbdev-3.3.30}/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.30
|
|
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.30"
|
|
10
10
|
|
|
11
11
|
from .doclinks import nbdev_export
|
|
12
12
|
from .showdoc import show_doc
|
|
@@ -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))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdev
|
|
3
|
-
Version: 3.3.
|
|
3
|
+
Version: 3.3.30
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|