nbdev 3.3.2__tar.gz → 3.3.4__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.
Files changed (39) hide show
  1. {nbdev-3.3.2/nbdev.egg-info → nbdev-3.3.4}/PKG-INFO +1 -1
  2. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/__init__.py +1 -1
  3. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/config.py +9 -10
  4. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/quarto.py +9 -5
  5. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/serve.py +1 -1
  6. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/skill.py +11 -1
  7. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/test.py +2 -2
  8. {nbdev-3.3.2 → nbdev-3.3.4/nbdev.egg-info}/PKG-INFO +1 -1
  9. {nbdev-3.3.2 → nbdev-3.3.4}/CONTRIBUTING.md +0 -0
  10. {nbdev-3.3.2 → nbdev-3.3.4}/LICENSE +0 -0
  11. {nbdev-3.3.2 → nbdev-3.3.4}/MANIFEST.in +0 -0
  12. {nbdev-3.3.2 → nbdev-3.3.4}/README.md +0 -0
  13. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/_modidx.py +0 -0
  14. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/clean.py +0 -0
  15. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/cli.py +0 -0
  16. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/diff.py +0 -0
  17. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/doclinks.py +0 -0
  18. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/export.py +0 -0
  19. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/extract_attachments.py +0 -0
  20. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/frontmatter.py +0 -0
  21. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/imports.py +0 -0
  22. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/maker.py +0 -0
  23. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/merge.py +0 -0
  24. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/migrate.py +0 -0
  25. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/process.py +0 -0
  26. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/processors.py +0 -0
  27. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/qmd.py +0 -0
  28. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/release.py +0 -0
  29. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/scrubmagics.py +0 -0
  30. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/serve_drv.py +0 -0
  31. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/showdoc.py +0 -0
  32. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev/sync.py +0 -0
  33. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev.egg-info/SOURCES.txt +0 -0
  34. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev.egg-info/dependency_links.txt +0 -0
  35. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev.egg-info/entry_points.txt +0 -0
  36. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev.egg-info/requires.txt +0 -0
  37. {nbdev-3.3.2 → nbdev-3.3.4}/nbdev.egg-info/top_level.txt +0 -0
  38. {nbdev-3.3.2 → nbdev-3.3.4}/pyproject.toml +0 -0
  39. {nbdev-3.3.2 → nbdev-3.3.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 3.3.2
3
+ Version: 3.3.4
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: Apache-2.0
@@ -5,7 +5,7 @@ Modules:
5
5
  - `nbdev.extract_attachments`: A preprocessor that extracts all of the attachments from the notebook file. The extracted attachments are returned in the 'resources' dictionary.
6
6
  - `nbdev.skill`: Author clear, executable nbdev notebooks where code, prose, examples, outputs, and tests form one coherent narrative."""
7
7
 
8
- __version__ = "3.3.2"
8
+ __version__ = "3.3.4"
9
9
 
10
10
  from .doclinks import nbdev_export
11
11
  from .showdoc import show_doc
@@ -11,7 +11,6 @@ __all__ = ['pyproject_nm', 'pyproject_tmpl', 'nbdev_defaults', 'pyproj_tmpl', 'n
11
11
  'update_llms_txt', 'import_obj', 'write_cells']
12
12
 
13
13
  # %% ../nbs/api/01_config.ipynb #6fd14ecd
14
- from datetime import datetime
15
14
  from fastcore.docments import *
16
15
  from fastcore.utils import *
17
16
  from fastcore.meta import *
@@ -19,10 +18,9 @@ from fastcore.script import *
19
18
  from fastcore.style import *
20
19
  from fastcore.xdg import *
21
20
 
22
- import ast,importlib,re,warnings
21
+ import ast,importlib,re
23
22
  from IPython.display import Markdown
24
23
  from fastcore.nbio import read_nb,NbCell
25
- from urllib.error import HTTPError
26
24
 
27
25
  try: import tomllib
28
26
  except ImportError: import tomli as tomllib
@@ -42,6 +40,7 @@ def _get_info(owner, repo, default_branch='main', default_kw='nbdev'):
42
40
  from ghapi.all import call_gh, APIError
43
41
  try: r = call_gh('repos.get', owner=owner, repo=repo)
44
42
  except APIError:
43
+ # chkstyle: ignore-node
45
44
  msg= [f"""Could not access repo: {owner}/{repo} to find your default branch - `{default_branch}` assumed.
46
45
  Edit `pyproject.toml` if this is incorrect.
47
46
  In the future, you can allow nbdev to see private repos by setting the environment variable GITHUB_TOKEN as described here:
@@ -205,8 +204,7 @@ class ConfigToml(AttrDict):
205
204
  if 'lib_path' not in self: self['lib_path'] = self.lib_name.replace('-', '_')
206
205
 
207
206
  @property
208
- def version(self):
209
- return read_version(self.config_path / self['lib_path']) or '0.0.1'
207
+ def version(self): return read_version(self.config_path / self['lib_path']) or '0.0.1'
210
208
 
211
209
  @property
212
210
  def d(self): return {k:v for k,v in super().items()}
@@ -253,7 +251,7 @@ def is_nbdev(path=None): return _find_nbdev_pyproject(path) is not None
253
251
  def create_output(txt, mime):
254
252
  "Add a cell output containing `txt` of the `mime` text MIME sub-type"
255
253
  return [dict(data={f"text/{mime}": str(txt).splitlines(True)},
256
- execution_count=1, metadata={}, output_type="execute_result")]
254
+ execution_count=1, metadata={}, output_type="execute_result")]
257
255
 
258
256
  # %% ../nbs/api/01_config.ipynb #5a4d8e52
259
257
  def show_src(src, lang='python'): return Markdown(f'```{lang}\n{src}\n```')
@@ -318,12 +316,13 @@ def set_version(path, version):
318
316
 
319
317
  # %% ../nbs/api/01_config.ipynb #d00889e5
320
318
  def bump_version(v, part=2, unbump=False):
321
- "Bump semver string `v` at index `part` (0=major, 1=minor, 2=patch)"
319
+ "Bump semver part `part` (0=major, 1=minor, 2=patch), counted from the right"
322
320
  parts = (v or '0.0.0').split('.')
323
321
  parts += ['0'] * (3 - len(parts))
324
- parts[part] = str(int(parts[part]) + (-1 if unbump else 1))
325
- for i in range(part+1, 3): parts[i] = '0'
326
- return '.'.join(parts[:3])
322
+ idx = len(parts) - 3 + part
323
+ parts[idx] = str(int(parts[idx]) + (-1 if unbump else 1))
324
+ for i in range(idx+1, len(parts)): parts[i] = '0'
325
+ return '.'.join(parts)
327
326
 
328
327
  # %% ../nbs/api/01_config.ipynb #e32583e6
329
328
  def update_version(path=None):
@@ -208,8 +208,10 @@ def _chk_nbdev_yml(path):
208
208
 
209
209
  # %% ../nbs/api/14_quarto.ipynb #6b880922
210
210
  def _pre_docs(path=None, n_workers:int=defaults.cpus, **kwargs):
211
- cfg = get_config()
212
- path = Path(path) if path else cfg.nbs_path
211
+ cfg = get_config(path)
212
+ path = Path(path).absolute() if path else cfg.nbs_path
213
+ if not (path/'nbdev.yml').exists(): path = cfg.nbs_path # given a project root, fall back to its configured nbs
214
+ os.chdir(cfg.config_path) # bare `get_config()` runs downstream (including in render workers), so anchor the cwd
213
215
  _chk_nbdev_yml(path)
214
216
  _ensure_quarto()
215
217
  refresh_quarto_yml()
@@ -272,12 +274,14 @@ def _save_cached_readme(cache, cfg):
272
274
  # %% ../nbs/api/14_quarto.ipynb #45d6bb5d
273
275
  @call_parse
274
276
  def nbdev_readme(
275
- path:str=None, # Path to notebooks
277
+ path:str=None, # Path to notebooks (or project root)
276
278
  chk_time:bool=False): # Only build if out of date
277
279
  "Create README.md from readme_nb (index.ipynb by default). Skips if the file doesn't exist."
278
- cfg = get_config()
279
- path = Path(path) if path else cfg.nbs_path
280
+ cfg = get_config(path)
281
+ path = Path(path).absolute() if path else cfg.nbs_path
282
+ if not (path/cfg.readme_nb).exists(): path = cfg.nbs_path # given a project root, fall back to its configured nbs
280
283
  if not (path/cfg.readme_nb).exists(): return
284
+ os.chdir(cfg.config_path) # bare `get_config()` runs downstream (including in render workers), so anchor the cwd
281
285
  _chk_nbdev_yml(path)
282
286
  if chk_time and _doc_mtime_not_older(cfg.config_path/'README.md', path/cfg.readme_nb): return
283
287
 
@@ -70,7 +70,7 @@ def proc_nbs(
70
70
  file_re:str='', # Only process notebooks matching regex (other files are always included)
71
71
  **kwargs):
72
72
  "Process notebooks in `path` for docs rendering"
73
- cfg = get_config()
73
+ cfg = get_config(path or None)
74
74
  cache = cfg.config_path/'_proc'
75
75
  path = Path(path or cfg.nbs_path)
76
76
  files = nbglob(path, func=Path, file_glob='', file_re='', **kwargs)
@@ -32,6 +32,14 @@ Markdown explains what the code cannot: why an abstraction exists, what distinct
32
32
 
33
33
  Keep docstrings to a short statement of what the symbol does. Extended explanation, examples, and warnings go in markdown cells, where they render properly and can include executable results. Document parameters and returns with docments, keeping their docs beside the signature instead of repeating it in the docstring. Backtick symbol names in prose. nbdev links them, so prefer names over hand-maintained URLs.
34
34
 
35
+ # Module docstrings
36
+
37
+ `doc(module)` shows the docstring with the API listing, and for an LLM that is usually the whole read. Treat the docstring as the module's TL;DR. Write a short summary under each major section heading and tag it `#| export`, teaching what a reader cannot guess from signatures and leaving per-function detail to the page.
38
+
39
+ `#| exportd` on a code cell puts its source in the docstring as a fenced block and keeps it out of the module code. Use it for a compact runnable demo, placed after the definitions it needs. End the summary before it with a colon so the two read as one. Only exported cells join the docstring, so the pair stays adjacent there even when definition cells sit between them in the notebook.
40
+
41
+ Preview the assembled docstring with `nbdev.export.nb_mdoc`, and run code to check each claim before writing it. `nbdev-export` adds the module to the generated package docstring and `llms.txt` once its docstring says more than the default summary line, so write these cells only for modules meant to be read on their own. For the package intro, tag the opening paragraphs of `index.ipynb` with `#| export`.
42
+
35
43
  # Examples are documentation and tests
36
44
 
37
45
  Write each example as page content first, then make it verify behavior: realistic values, the shortest path to the idea, an informative displayed result, direct assertions that reinforce the lesson, reuse of objects introduced earlier, and important errors demonstrated executably with `expect_fail` (one focused example per contract). Keep test plumbing out of reader-facing cells. Mocks, dense comprehensions, and long setup make poor documentation, so extract a tiny helper or hide the check. Assertions verify, but only the final expression's display teaches. End cells with the value worth showing, and design a compact `_repr_markdown_` or structured summary when it turns later examples into documentation for free. Plots, tables, images, and rich HTML all count as evidence. Stored outputs are part of the explanation. Keep them focused, and never dump a large structure without saying what matters in it. Test helpers come from `fastcore.test` (`test_eq`, `expect_fail`, ...), in plain code cells.
@@ -58,12 +66,14 @@ Keep imports in dedicated import cells, define values near first use, reuse esta
58
66
 
59
67
  # Directives
60
68
 
61
- `#| default_exp` names the module. `#| export` marks exported cells. Underscore-prefixed helpers may export without joining the public API. `#| hide` keeps necessary but distracting material off the page. `#| eval: false` is for cells that genuinely must not run, not for suppressing broken ones, and it cascades. An unevaluated cell cannot create state for later evaluated cells.
69
+ `#| default_exp` names the module. `#| export` marks exported cells. Underscore-prefixed helpers may export without joining the public API. `#| exportd` exports a code cell's source to the module docstring instead of the module. `#| hide` keeps necessary but distracting material off the page. `#| eval: false` is for cells that genuinely must not run, not for suppressing broken ones, and it cascades. An unevaluated cell cannot create state for later evaluated cells.
62
70
 
63
71
  # nbdev v3
64
72
 
65
73
  Everything here describes nbdev v3 (released Jan 2026, possibly after a model's training cutoff). Key user-visible changes from v2: config moved from `settings.ini` to `pyproject.toml`, with standard metadata in `[project]`, nbdev-specific keys in `[tool.nbdev]` (defaults `nbs_path='nbs'`, `doc_path='_docs'`), version in `__init__.py` via `dynamic = ["version"]`, and `_modidx` registered under `[project.entry-points.nbdev]`. CLI commands use hyphens (`nbdev-export`, `nbdev-test`, ...) though Python functions keep underscores. GitHub workflows use the v3 actions (`fastai/workflows/nbdev3-ci`, `quarto-ghp3`).
66
74
 
75
+ Directives can also live in cell *metadata*, under the `nbdev` key (`{"nbdev": {"export": "true"}}`), instead of `#|` comment lines. Export and the rest of the toolchain honor both; `mk_cell(source, metadata=...).directives` is the merged read, with the comment winning when both set the same key. The editing toolkit keeps the meta form visible: summaries show it bracketed after the type char (`id:c[export]:...` in nbio's `CellRow` and aidialog's previews), XML views render it as attrs (a bare `export` on the tag), and aidialog's `Message` offers `exported` (either form, read-only) and `meta_exported` (meta only, assignable), with `export=`/`meta=` params on the add functions.
76
+
67
77
  # Before you finish
68
78
 
69
79
  Each new test cell ran red then green, failing before the change and passing after. Re-read the touched section as a reader would, against the conventions above. Style damage breaks no test and no export, so the harm only shows on the docs page.
@@ -108,8 +108,8 @@ def nbdev_test(
108
108
  if len(files)==0: return print('No files were eligible for testing')
109
109
 
110
110
  if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)
111
- if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' else {'method':'forkserver'}
112
- else: kw = {'method':'forkserver'} if sys.platform=='darwin' else {}
111
+ if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}
112
+ else: kw = {'method':'spawn'} if sys.platform=='darwin' else {}
113
113
  wd_pth = cfg.nbs_path
114
114
  with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):
115
115
  results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 3.3.2
3
+ Version: 3.3.4
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: Apache-2.0
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