nbdev 3.3.30__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.30/nbdev.egg-info → nbdev-3.3.31}/PKG-INFO +1 -1
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/__init__.py +1 -1
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/_modidx.py +2 -1
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/config.py +18 -12
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/doclinks.py +2 -4
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/maker.py +9 -8
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/quarto.py +2 -2
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/skill.py +1 -0
- {nbdev-3.3.30 → nbdev-3.3.31/nbdev.egg-info}/PKG-INFO +1 -1
- {nbdev-3.3.30 → nbdev-3.3.31}/CONTRIBUTING.md +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/LICENSE +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/README.md +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/clean.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/cli.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/diff.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/diff_core.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/export.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/extract_attachments.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/frontmatter.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/imports.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/merge.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/migrate.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/moddocs.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/process.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/processors.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/qmd.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/quarto_render.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/readme_filter.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/release.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/scrubmagics.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/serve.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/serve_drv.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/showdoc.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/sync.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev/test.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev.egg-info/SOURCES.txt +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev.egg-info/entry_points.txt +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev.egg-info/requires.txt +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/pyproject.toml +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/setup.cfg +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/tests/test_diff.py +0 -0
- {nbdev-3.3.30 → nbdev-3.3.31}/tests/test_quarto_render.py +0 -0
|
@@ -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):
|
|
@@ -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
|
|
|
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
|