nbdev 2.3.32__py3-none-any.whl → 2.3.34__py3-none-any.whl

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/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "2.3.32"
1
+ __version__ = "2.3.34"
2
2
 
3
3
  from .doclinks import nbdev_export
4
4
  from .showdoc import show_doc
nbdev/_modidx.py CHANGED
@@ -3,7 +3,7 @@
3
3
  d = { 'settings': { 'branch': 'master',
4
4
  'doc_baseurl': '/',
5
5
  'doc_host': 'https://nbdev.fast.ai',
6
- 'git_url': 'https://github.com/fastai/nbdev',
6
+ 'git_url': 'https://github.com/AnswerDotAI/nbdev',
7
7
  'lib_path': 'nbdev'},
8
8
  'syms': { 'nbdev.clean': { 'nbdev.clean._add_jupyter_hooks': ('api/clean.html#_add_jupyter_hooks', 'nbdev/clean.py'),
9
9
  'nbdev.clean._clean_cell': ('api/clean.html#_clean_cell', 'nbdev/clean.py'),
@@ -58,6 +58,7 @@ d = { 'settings': { 'branch': 'master',
58
58
  'nbdev.doclinks.NbdevLookup.link_line': ('api/doclinks.html#nbdevlookup.link_line', 'nbdev/doclinks.py'),
59
59
  'nbdev.doclinks.NbdevLookup.linkify': ('api/doclinks.html#nbdevlookup.linkify', 'nbdev/doclinks.py'),
60
60
  'nbdev.doclinks._binop_leafs': ('api/doclinks.html#_binop_leafs', 'nbdev/doclinks.py'),
61
+ 'nbdev.doclinks._build_lookup_table': ('api/doclinks.html#_build_lookup_table', 'nbdev/doclinks.py'),
61
62
  'nbdev.doclinks._build_modidx': ('api/doclinks.html#_build_modidx', 'nbdev/doclinks.py'),
62
63
  'nbdev.doclinks._find_mod': ('api/doclinks.html#_find_mod', 'nbdev/doclinks.py'),
63
64
  'nbdev.doclinks._get_exps': ('api/doclinks.html#_get_exps', 'nbdev/doclinks.py'),
@@ -69,6 +70,7 @@ d = { 'settings': { 'branch': 'master',
69
70
  'nbdev.doclinks._qual_sym': ('api/doclinks.html#_qual_sym', 'nbdev/doclinks.py'),
70
71
  'nbdev.doclinks._qual_syms': ('api/doclinks.html#_qual_syms', 'nbdev/doclinks.py'),
71
72
  'nbdev.doclinks._sym_nm': ('api/doclinks.html#_sym_nm', 'nbdev/doclinks.py'),
73
+ 'nbdev.doclinks.create_index': ('api/doclinks.html#create_index', 'nbdev/doclinks.py'),
72
74
  'nbdev.doclinks.nbdev_export': ('api/doclinks.html#nbdev_export', 'nbdev/doclinks.py'),
73
75
  'nbdev.doclinks.nbglob': ('api/doclinks.html#nbglob', 'nbdev/doclinks.py'),
74
76
  'nbdev.doclinks.nbglob_cli': ('api/doclinks.html#nbglob_cli', 'nbdev/doclinks.py'),
nbdev/config.py CHANGED
@@ -138,7 +138,7 @@ def _cfg2txt(cfg, head, sections, tail=''):
138
138
 
139
139
  # %% ../nbs/api/01_config.ipynb
140
140
  _nbdev_cfg_head = '''# All sections below are required unless otherwise specified.
141
- # See https://github.com/fastai/nbdev/blob/master/settings.ini for examples.
141
+ # See https://github.com/AnswerDotAI/nbdev/blob/main/settings.ini for examples.
142
142
 
143
143
  '''
144
144
  _nbdev_cfg_sections = {'Python library': 'repo lib_name version min_python license black_formatting',
nbdev/doclinks.py CHANGED
@@ -3,7 +3,7 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/05_doclinks.ipynb.
4
4
 
5
5
  # %% auto 0
6
- __all__ = ['patch_name', 'nbglob', 'nbglob_cli', 'nbdev_export', 'NbdevLookup']
6
+ __all__ = ['typs', 'bset', 'patch_name', 'nbglob', 'nbglob_cli', 'nbdev_export', 'create_index', 'NbdevLookup']
7
7
 
8
8
  # %% ../nbs/api/05_doclinks.ipynb
9
9
  from .config import *
@@ -14,14 +14,18 @@ from .imports import *
14
14
  from fastcore.script import *
15
15
  from fastcore.utils import *
16
16
  from fastcore.meta import delegates
17
+ from fastcore.net import urlread
17
18
 
18
- import ast,contextlib
19
+ import ast,builtins,contextlib
19
20
  import pkg_resources,importlib
20
- from astunparse import unparse
21
21
 
22
+ from astunparse import unparse
23
+ from io import BytesIO
24
+ from collections import defaultdict
22
25
  from pprint import pformat
23
26
  from urllib.parse import urljoin
24
27
  from functools import lru_cache
28
+ from types import ModuleType
25
29
 
26
30
  # %% ../nbs/api/05_doclinks.ipynb
27
31
  def _sym_nm(klas, sym): return f'{unparse(klas).strip()}.{sym.name}'
@@ -152,6 +156,28 @@ def nbdev_export(
152
156
  add_init(get_config().lib_path)
153
157
  _build_modidx()
154
158
 
159
+ # %% ../nbs/api/05_doclinks.ipynb
160
+ typs = 'module','class','method','function'
161
+ bset = set(dir(builtins))
162
+
163
+ # %% ../nbs/api/05_doclinks.ipynb
164
+ def create_index(url, pre=None):
165
+ "Create a documentation index from a sphinx inventory file at `url`, with optional prefix `pre`"
166
+ try: from sphinx.util.inventory import InventoryFile
167
+ except ImportError: raise ImportError('`sphinx` is a dependency for building indexes. Run `pip install sphinx` to use `create_index`.')
168
+ pre = ifnone(pre, f"{url}/")
169
+ invs = urlread(f'{url}/objects.inv', decode=False)
170
+ idx = InventoryFile.load(stream=BytesIO(invs), uri=pre, joinfunc=urljoin)
171
+ _get = lambda o: {k:v[2] for k,v in idx[f'py:{o}'].items() if k[0]!='_'}
172
+ d = {o:_get(o) for o in typs}
173
+ syms = defaultdict(dict)
174
+ for o in typs:
175
+ for k,v in d[o].items():
176
+ if k.split('.')[0] in bset: k = 'builtins.' + k
177
+ modparts = k.split(".")[:-2 if o=='method' else -1]
178
+ if modparts: syms['.'.join(modparts)][k] = v
179
+ return syms
180
+
155
181
  # %% ../nbs/api/05_doclinks.ipynb
156
182
  import importlib,ast
157
183
  from functools import lru_cache
@@ -166,6 +192,7 @@ def _find_mod(mod):
166
192
 
167
193
  @lru_cache(None)
168
194
  def _get_exps(mod):
195
+ "Get the line numbers for function and class definitions in module"
169
196
  mf = _find_mod(mod)
170
197
  if not mf: return {}
171
198
  txt = mf.read_text(encoding='utf-8')
@@ -181,6 +208,7 @@ def _lineno(sym, fname): return _get_exps(fname).get(sym, None) if fname else No
181
208
 
182
209
  # %% ../nbs/api/05_doclinks.ipynb
183
210
  def _qual_sym(s, settings):
211
+ "Get qualified nb, py, and github paths for a symbol s"
184
212
  if not isinstance(s,tuple): return s
185
213
  nb,py = s
186
214
  nbbase = urljoin(settings["doc_host"]+'/',settings["doc_baseurl"])
@@ -199,30 +227,41 @@ _re_backticks = re.compile(r'`([^`\s]+?)(?:\(\))?`')
199
227
 
200
228
  # %% ../nbs/api/05_doclinks.ipynb
201
229
  @lru_cache(None)
230
+ def _build_lookup_table(strip_libs=None, incl_libs=None, skip_mods=None):
231
+ cfg = get_config()
232
+ if strip_libs is None:
233
+ try: strip_libs = cfg.get('strip_libs', cfg.get('lib_path', 'nbdev').name).split()
234
+ except FileNotFoundError: strip_libs = 'nbdev'
235
+ skip_mods = setify(skip_mods)
236
+ strip_libs = L(strip_libs)
237
+ if incl_libs is not None: incl_libs = (L(incl_libs)+strip_libs).unique()
238
+ entries = {}
239
+ for o in pkg_resources.iter_entry_points(group='nbdev'):
240
+ if incl_libs is not None and o.dist.key not in incl_libs: continue
241
+ try: entries[o.name] = _qual_syms(o.resolve())
242
+ except Exception: pass
243
+ py_syms = merge(*L(o['syms'].values() for o in entries.values()).concat())
244
+ for m in strip_libs:
245
+ if m in entries:
246
+ _d = entries[m]
247
+ stripped = {remove_prefix(k,f"{mod}."):v
248
+ for mod,dets in _d['syms'].items() if mod not in skip_mods
249
+ for k,v in dets.items()}
250
+ py_syms = merge(stripped, py_syms)
251
+ return entries,py_syms
252
+
253
+ # %% ../nbs/api/05_doclinks.ipynb
202
254
  class NbdevLookup:
203
255
  "Mapping from symbol names to docs and source URLs"
204
- def __init__(self, strip_libs=None, incl_libs=None, skip_mods=None):
205
- cfg = get_config()
206
- if strip_libs is None:
207
- try: strip_libs = cfg.get('strip_libs', cfg.get('lib_path', 'nbdev').name).split()
208
- except FileNotFoundError: strip_libs = 'nbdev'
209
- skip_mods = setify(skip_mods)
210
- strip_libs = L(strip_libs)
211
- if incl_libs is not None: incl_libs = (L(incl_libs)+strip_libs).unique()
212
- # Dict from lib name to _nbdev module for incl_libs (defaults to all)
213
- self.entries = {o.name: _qual_syms(o.resolve()) for o in list(pkg_resources.iter_entry_points(group='nbdev'))
214
- if incl_libs is None or o.dist.key in incl_libs}
215
- py_syms = merge(*L(o['syms'].values() for o in self.entries.values()).concat())
216
- for m in strip_libs:
217
- if m in self.entries:
218
- _d = self.entries[m]
219
- stripped = {remove_prefix(k,f"{mod}."):v
220
- for mod,dets in _d['syms'].items() if mod not in skip_mods
221
- for k,v in dets.items()}
222
- py_syms = merge(stripped, py_syms)
223
- self.syms = py_syms
224
-
225
- def __getitem__(self, s): return self.syms.get(s, None)
256
+ def __init__(self, strip_libs=None, incl_libs=None, skip_mods=None, ns=None):
257
+ self.entries,self.syms = _build_lookup_table(strip_libs, incl_libs, skip_mods)
258
+ self.aliases = {n:o.__name__ for n,o in (ns or {}).items() if isinstance(o, ModuleType)}
259
+
260
+ def __getitem__(self, s):
261
+ if '.' in s:
262
+ pre,post = s.split('.', 1)
263
+ if pre in self.aliases: s = f"{self.aliases[pre]}.{post}"
264
+ return self.syms.get(s, None)
226
265
 
227
266
  def doc(self, sym):
228
267
  "Link to docs for `sym`"
nbdev/processors.py CHANGED
@@ -249,7 +249,7 @@ class exec_show_docs(Processor):
249
249
  if _do_eval(cell): self.k.cell(cell)
250
250
  title = fm.get('title', '')
251
251
  if self.k.exc:
252
- raise Exception(f"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\n{cell.source}") from self.k.exc[1]
252
+ raise Exception(f"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\n{cell.source}") from self.k.exc
253
253
 
254
254
  def end(self):
255
255
  try: from ipywidgets import Widget
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nbdev
3
- Version: 2.3.32
3
+ Version: 2.3.34
4
4
  Summary: Create delightful software with Jupyter Notebooks
5
- Home-page: https://github.com/fastai/nbdev
5
+ Home-page: https://github.com/AnswerDotAI/nbdev
6
6
  Author: Jeremy Howard and Hamel Husain
7
7
  Author-email: j@fast.ai
8
8
  License: Apache Software License 2.0
@@ -41,6 +41,7 @@ Requires-Dist: svg.py ; extra == 'dev'
41
41
  Requires-Dist: nbclassic ; extra == 'dev'
42
42
  Requires-Dist: pysymbol-llm ; extra == 'dev'
43
43
  Requires-Dist: llms-txt ; extra == 'dev'
44
+ Requires-Dist: sphinx ; extra == 'dev'
44
45
 
45
46
  # Getting Started
46
47
 
@@ -1,9 +1,9 @@
1
- nbdev/__init__.py,sha256=Yi4HGTGFuc0G5fWdpRdXjvmn5qNQJiVSA056USVp8MU,90
2
- nbdev/_modidx.py,sha256=WzOr4ZDIJcKGYijdH-9OUIx3Nn0PZg9_-LwarG_SiWc,41011
1
+ nbdev/__init__.py,sha256=ZX6ZpzceYLyy-v7u62yWomGalDXO3B7da54WH-xylnQ,90
2
+ nbdev/_modidx.py,sha256=mquJnE_EgW0V2fUzt93Fn_NkWBG-wZUrvpQl_1NsHo4,41270
3
3
  nbdev/clean.py,sha256=mVgsW2_g7KIXAVh8mwpj86UwMN6QVM-q33PDzA27nWw,9410
4
4
  nbdev/cli.py,sha256=8YWXu9jDiVpTd9mhCealLNAd5Fg3xCpNklpZ6Fc8tD0,7045
5
- nbdev/config.py,sha256=B_LbvyTLi2jDI53MTWypJhgXD8PoyY0ztRzPhYEnG7s,12225
6
- nbdev/doclinks.py,sha256=5Eoeaoo6HmgmsfLl8q95uw4GpkmMhT_igL0ogys7kk4,10670
5
+ nbdev/config.py,sha256=RQGR-zTmsZrjfszDDF0qdAMnyvmMS7Kn0ccMFLrxnh8,12228
6
+ nbdev/doclinks.py,sha256=-ET_sYAiAU2TnyxXFFFoUSqzI7SyqcL5viS_zg_Z6ms,12334
7
7
  nbdev/export.py,sha256=IonpKGYthPgAjEGrm8sK36O2yflQFaxLEXBBrEYe5q4,3955
8
8
  nbdev/extract_attachments.py,sha256=O4mS4EFIOXL_yQ3jmsnBStrWxGR_nPNvxLYXHtLeimw,2208
9
9
  nbdev/frontmatter.py,sha256=i195bhDLWd-WUEzQT9JBoA4Ee3j6gD1dKMT8yk5fF4Y,2761
@@ -12,7 +12,7 @@ nbdev/maker.py,sha256=JrvvtG23_tgT4i-zzDrUF1GmLhdL_9j4S-dcD-GVui4,9801
12
12
  nbdev/merge.py,sha256=xmT7LMY_mQGOGl0ynqkB13M6HwJfUOTis1Xl--YDXR8,4341
13
13
  nbdev/migrate.py,sha256=YJTtWC6TPaZpZTcD0Jex6stOSumjju2QrUozF9rvl0Y,7311
14
14
  nbdev/process.py,sha256=Vb3SN5YW2gB9rYv5ToeveOeL9qM9AGLRPXCyAFiaE3g,5853
15
- nbdev/processors.py,sha256=vtby1GBM-iz6axnhPIVU-HTN8jNYA6CzsT-N_EGcUlE,11976
15
+ nbdev/processors.py,sha256=fS4WrowC8bi6sFJJUVA9r9IRgmk-gffrJ9zNfb7vpIM,11973
16
16
  nbdev/qmd.py,sha256=VAxE-c1sT7y26VdyreB6j9fge-CuLbHWocRE_WbnYXg,2994
17
17
  nbdev/quarto.py,sha256=o-fRR5gqWKvIjr-k4f_XfN3LpMIsO0URC9yEtDOJHLs,12053
18
18
  nbdev/release.py,sha256=K8Q7CU-fM5TyLy5Q8AswpA3vE5CHa8aHaeKU9LHtlv0,14159
@@ -21,9 +21,9 @@ nbdev/serve_drv.py,sha256=IZ2acem_KKsXYYe0iUECiR_orkYLBkT1ZG_258ZS7SQ,657
21
21
  nbdev/showdoc.py,sha256=v7qUzyr5gMN99jZMzal_ulRLsn617BkRMS1XEq9UqjE,10033
22
22
  nbdev/sync.py,sha256=ld-lSOmlX1FdnTOzaSHcxKyIuIguI_SpluqfPSH2BZ8,3201
23
23
  nbdev/test.py,sha256=_ECBd5fvfGEICIfkTI2S8w8YatL5CaPltCeDSsiH6yw,4435
24
- nbdev-2.3.32.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
25
- nbdev-2.3.32.dist-info/METADATA,sha256=i5sRYqowR09nR_av8Pr6E1obUDxR1ByNadiYSWmt00E,10510
26
- nbdev-2.3.32.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
- nbdev-2.3.32.dist-info/entry_points.txt,sha256=P7LtWbUX0nXuV5g7HJtSDdTWjn7cq9a9uv3p6VoYDz8,1400
28
- nbdev-2.3.32.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
29
- nbdev-2.3.32.dist-info/RECORD,,
24
+ nbdev-2.3.34.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
25
+ nbdev-2.3.34.dist-info/METADATA,sha256=gzDkAX7jEZuJZyLf8vYx8bXqDFPLEm8lhX12X5_XkwA,10554
26
+ nbdev-2.3.34.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
+ nbdev-2.3.34.dist-info/entry_points.txt,sha256=P7LtWbUX0nXuV5g7HJtSDdTWjn7cq9a9uv3p6VoYDz8,1400
28
+ nbdev-2.3.34.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
29
+ nbdev-2.3.34.dist-info/RECORD,,
File without changes