nbdev 2.3.16__py3-none-any.whl → 2.3.17__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.16"
1
+ __version__ = "2.3.17"
2
2
 
3
3
  from .doclinks import nbdev_export
4
4
  from .showdoc import show_doc
nbdev/_modidx.py CHANGED
@@ -218,6 +218,8 @@ d = { 'settings': { 'branch': 'master',
218
218
  'nbdev.processors.insert_warning': ('api/processors.html#insert_warning', 'nbdev/processors.py'),
219
219
  'nbdev.processors.insert_warning.begin': ( 'api/processors.html#insert_warning.begin',
220
220
  'nbdev/processors.py'),
221
+ 'nbdev.processors.mv_exports': ('api/processors.html#mv_exports', 'nbdev/processors.py'),
222
+ 'nbdev.processors.mv_exports.begin': ('api/processors.html#mv_exports.begin', 'nbdev/processors.py'),
221
223
  'nbdev.processors.populate_language': ('api/processors.html#populate_language', 'nbdev/processors.py'),
222
224
  'nbdev.processors.populate_language.begin': ( 'api/processors.html#populate_language.begin',
223
225
  'nbdev/processors.py'),
nbdev/processors.py CHANGED
@@ -1,9 +1,9 @@
1
1
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/10_processors.ipynb.
2
2
 
3
3
  # %% auto 0
4
- __all__ = ['populate_language', 'insert_warning', 'cell_lang', 'add_show_docs', 'add_links', 'add_fold', 'strip_ansi',
5
- 'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_', 'clean_magics', 'rm_header_dash',
6
- 'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
4
+ __all__ = ['populate_language', 'insert_warning', 'cell_lang', 'add_show_docs', 'mv_exports', 'add_links', 'add_fold',
5
+ 'strip_ansi', 'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_', 'clean_magics',
6
+ 'rm_header_dash', 'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
7
7
 
8
8
  # %% ../nbs/api/10_processors.ipynb 2
9
9
  import ast
@@ -76,10 +76,22 @@ class add_show_docs(Processor):
76
76
  for cell in reversed(exports):
77
77
  if cell_lang(cell) != 'python': raise ValueError(f"{cell.metadata.language} can't export:\n{cell.source}")
78
78
  nms = _def_names(cell, shown_docs)
79
- for nm in nms: nb.cells.insert(cell.idx_+1, mk_cell(f'show_doc({nm})'))
79
+ for nm in nms:
80
+ new_cell = mk_cell(f'show_doc({nm})')
81
+ new_cell.has_sd = True
82
+ nb.cells.insert(cell.idx_+1, new_cell)
80
83
  nb.has_docs_ = shown_docs or exports
81
84
 
82
85
  # %% ../nbs/api/10_processors.ipynb 17
86
+ class mv_exports(Processor):
87
+ "Move `exports` cells to after the `show_doc`"
88
+ def begin(self):
89
+ cells = self.nb.cells
90
+ exports = L(c for c in cells if c.cell_type=='code' and 'exports' in c.directives_)
91
+ for cell in reversed(exports):
92
+ if getattr(cells[cell.idx_+1], 'has_sd', 0): cells.insert(cell.idx_+1, cells.pop(cell.idx_))
93
+
94
+ # %% ../nbs/api/10_processors.ipynb 18
83
95
  _re_defaultexp = re.compile(r'^\s*#\|\s*default_exp\s+(\S+)', flags=re.MULTILINE)
84
96
 
85
97
  def _default_exp(nb):
@@ -88,7 +100,7 @@ def _default_exp(nb):
88
100
  default_exp = first(code_src.filter().map(_re_defaultexp.search).filter())
89
101
  return default_exp.group(1) if default_exp else None
90
102
 
91
- # %% ../nbs/api/10_processors.ipynb 19
103
+ # %% ../nbs/api/10_processors.ipynb 20
92
104
  def add_links(cell):
93
105
  "Add links to markdown cells"
94
106
  nl = NbdevLookup()
@@ -97,13 +109,13 @@ def add_links(cell):
97
109
  if hasattr(o, 'data') and hasattr(o['data'], 'text/markdown'):
98
110
  o.data['text/markdown'] = [nl.link_line(s) for s in o.data['text/markdown']]
99
111
 
100
- # %% ../nbs/api/10_processors.ipynb 21
112
+ # %% ../nbs/api/10_processors.ipynb 22
101
113
  def add_fold(cell):
102
114
  "Add `code-fold` to `exports` cells"
103
115
  if cell.cell_type != 'code' or 'exports' not in cell.directives_: return
104
116
  cell.source = f'#| code-fold: show\n#| code-summary: "Exported source"\n{cell.source}'
105
117
 
106
- # %% ../nbs/api/10_processors.ipynb 24
118
+ # %% ../nbs/api/10_processors.ipynb 25
107
119
  _re_ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
108
120
 
109
121
  def strip_ansi(cell):
@@ -111,17 +123,17 @@ def strip_ansi(cell):
111
123
  for outp in cell.get('outputs', []):
112
124
  if outp.get('name')=='stdout': outp['text'] = [_re_ansi_escape.sub('', o) for o in outp.text]
113
125
 
114
- # %% ../nbs/api/10_processors.ipynb 26
126
+ # %% ../nbs/api/10_processors.ipynb 27
115
127
  def strip_hidden_metadata(cell):
116
128
  '''Strips "hidden" metadata property from code cells so it doesn't interfere with docs rendering'''
117
129
  if cell.cell_type == 'code' and 'metadata' in cell: cell.metadata.pop('hidden',None)
118
130
 
119
- # %% ../nbs/api/10_processors.ipynb 27
131
+ # %% ../nbs/api/10_processors.ipynb 28
120
132
  def hide_(cell):
121
133
  "Hide cell from output"
122
134
  del(cell['source'])
123
135
 
124
- # %% ../nbs/api/10_processors.ipynb 29
136
+ # %% ../nbs/api/10_processors.ipynb 30
125
137
  def _re_hideline(lang=None): return re.compile(fr'{langs[lang]}\|\s*hide_line\s*$', re.MULTILINE)
126
138
 
127
139
  def hide_line(cell):
@@ -130,7 +142,7 @@ def hide_line(cell):
130
142
  if cell.cell_type == 'code' and _re_hideline(lang).search(cell.source):
131
143
  cell.source = '\n'.join([c for c in cell.source.splitlines() if not _re_hideline(lang).search(c)])
132
144
 
133
- # %% ../nbs/api/10_processors.ipynb 32
145
+ # %% ../nbs/api/10_processors.ipynb 33
134
146
  def filter_stream_(cell, *words):
135
147
  "Remove output lines containing any of `words` in `cell` stream output"
136
148
  if not words: return
@@ -138,14 +150,14 @@ def filter_stream_(cell, *words):
138
150
  if outp.output_type == 'stream':
139
151
  outp['text'] = [l for l in outp.text if not re.search('|'.join(words), l)]
140
152
 
141
- # %% ../nbs/api/10_processors.ipynb 34
153
+ # %% ../nbs/api/10_processors.ipynb 35
142
154
  _magics_pattern = re.compile(r'^\s*(%%|%).*', re.MULTILINE)
143
155
 
144
156
  def clean_magics(cell):
145
157
  "A preprocessor to remove cell magic commands"
146
158
  if cell.cell_type == 'code': cell.source = _magics_pattern.sub('', cell.source).strip()
147
159
 
148
- # %% ../nbs/api/10_processors.ipynb 36
160
+ # %% ../nbs/api/10_processors.ipynb 37
149
161
  _re_hdr_dash = re.compile(r'^#+\s+.*\s+-\s*$', re.MULTILINE)
150
162
 
151
163
  def rm_header_dash(cell):
@@ -154,14 +166,14 @@ def rm_header_dash(cell):
154
166
  src = cell.source.strip()
155
167
  if cell.cell_type == 'markdown' and src.startswith('#') and src.endswith(' -'): del(cell['source'])
156
168
 
157
- # %% ../nbs/api/10_processors.ipynb 38
169
+ # %% ../nbs/api/10_processors.ipynb 39
158
170
  _hide_dirs = {'export','exporti', 'hide','default_exp'}
159
171
 
160
172
  def rm_export(cell):
161
173
  "Remove cells that are exported or hidden"
162
174
  if cell.directives_ and (cell.directives_.keys() & _hide_dirs): del(cell['source'])
163
175
 
164
- # %% ../nbs/api/10_processors.ipynb 40
176
+ # %% ../nbs/api/10_processors.ipynb 41
165
177
  _re_showdoc = re.compile(r'^show_doc', re.MULTILINE)
166
178
  def _is_showdoc(cell): return cell['cell_type'] == 'code' and _re_showdoc.search(cell.source)
167
179
  def _add_directives(cell, d):
@@ -173,7 +185,7 @@ def clean_show_doc(cell):
173
185
  if not _is_showdoc(cell): return
174
186
  _add_directives(cell, {'output':'asis','echo':'false'})
175
187
 
176
- # %% ../nbs/api/10_processors.ipynb 41
188
+ # %% ../nbs/api/10_processors.ipynb 42
177
189
  def _ast_contains(trees, types):
178
190
  for tree in trees:
179
191
  for node in ast.walk(tree):
@@ -194,7 +206,7 @@ def _do_eval(cell):
194
206
  return True
195
207
  if _show_docs(trees): return True
196
208
 
197
- # %% ../nbs/api/10_processors.ipynb 42
209
+ # %% ../nbs/api/10_processors.ipynb 43
198
210
  class exec_show_docs(Processor):
199
211
  "Execute cells needed for `show_docs` output, including exported cells and imports"
200
212
  def begin(self):
@@ -221,13 +233,13 @@ class exec_show_docs(Processor):
221
233
  widgets = {**old, **new, 'state': {**old.get('state', {}), **new['state']}}
222
234
  self.nb.metadata['widgets'] = {mimetype: widgets}
223
235
 
224
- # %% ../nbs/api/10_processors.ipynb 44
236
+ # %% ../nbs/api/10_processors.ipynb 45
225
237
  def _import_obj(s):
226
238
  mod_nm, obj_nm = s.split(':')
227
239
  mod = importlib.import_module(mod_nm)
228
240
  return getattr(mod, obj_nm)
229
241
 
230
- # %% ../nbs/api/10_processors.ipynb 45
242
+ # %% ../nbs/api/10_processors.ipynb 46
231
243
  class FilterDefaults:
232
244
  "Override `FilterDefaults` to change which notebook processors are used"
233
245
  def xtra_procs(self):
@@ -237,7 +249,7 @@ class FilterDefaults:
237
249
  def base_procs(self):
238
250
  return [FrontmatterProc, populate_language, add_show_docs, insert_warning,
239
251
  strip_ansi, hide_line, filter_stream_, rm_header_dash,
240
- clean_show_doc, exec_show_docs, rm_export, clean_magics, hide_, add_links, add_fold, strip_hidden_metadata]
252
+ clean_show_doc, exec_show_docs, rm_export, clean_magics, hide_, add_links, add_fold, mv_exports, strip_hidden_metadata]
241
253
 
242
254
  def procs(self):
243
255
  "Processors for export"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nbdev
3
- Version: 2.3.16
3
+ Version: 2.3.17
4
4
  Summary: Create delightful software with Jupyter Notebooks
5
5
  Home-page: https://github.com/fastai/nbdev
6
6
  Author: Jeremy Howard and Hamel Husain
@@ -1,5 +1,5 @@
1
- nbdev/__init__.py,sha256=cR2CXJXv4hmEFBCEdnpa-u00ZIqy8-iis3aigQ6n7XE,90
2
- nbdev/_modidx.py,sha256=NF3X3yYWR2T86nBSc-2FC5hdaV7fRa_u6Q5dA6VErvY,39829
1
+ nbdev/__init__.py,sha256=hl8Rf4Q4MjvVQmZ99WcJr1-dmru464QS4ftgcYPs2N4,90
2
+ nbdev/_modidx.py,sha256=ms9KsDxzkirwdpNbT_ZWL876mvQnSL2DKjUgR7boDrU,40089
3
3
  nbdev/clean.py,sha256=lLtfhCLjkDBqf8MvIG9lDSWSmA9vUDvn2QhS6LPprHI,9284
4
4
  nbdev/cli.py,sha256=nn9UxmpJaA_NorxDwP6jlFl5XnmWQdFqJHt0XAaKfbM,5637
5
5
  nbdev/config.py,sha256=fTTtYCQHyp8sXCFAyGN93eLOr3N3uOkv4LJ5-9Bclxs,12235
@@ -12,7 +12,7 @@ nbdev/maker.py,sha256=1hmOlElYhREqaJEc5jimiZ2Q5kkFUtQ9MNR05B-3L6c,9729
12
12
  nbdev/merge.py,sha256=QrP8tdlPRfZZ-TH5dTRwj9jXr7jWEsrLwgcIVPSHJSs,4319
13
13
  nbdev/migrate.py,sha256=l2hO2Ymkjm1C3_JmFDsM-DN6bxgFeLjj-pBr1xNqunI,7317
14
14
  nbdev/process.py,sha256=7dl9U7JLL9wbJta-KKTTnkMktBVsK5s-y8OBxtfk68I,5863
15
- nbdev/processors.py,sha256=XAHa7emkuA5XGcyySwvjBDOMn90OcWs4WfTULSmML4g,10361
15
+ nbdev/processors.py,sha256=tTN9M58CIXDJnhje2cGADZaBOz1CfCHner7VMZ0U9ms,10885
16
16
  nbdev/qmd.py,sha256=3Cskd8ynm25Hh7bo-_t0hxCMF6jqXxgq_VfkpLBKu_w,2958
17
17
  nbdev/quarto.py,sha256=uPburjx-OG9ruNTI08Ku_iOV5gerUUGNQUXDeOGmAco,12017
18
18
  nbdev/release.py,sha256=1rqBx77XPWSfb9JW8X7rTyaHz7wc4aRd3BHIkJafcKI,14229
@@ -21,9 +21,9 @@ nbdev/serve_drv.py,sha256=IZ2acem_KKsXYYe0iUECiR_orkYLBkT1ZG_258ZS7SQ,657
21
21
  nbdev/showdoc.py,sha256=sWkpTLpWLUMQBsysHqyvS7czIVcmfkJ_pjSU3zcp-AI,9150
22
22
  nbdev/sync.py,sha256=ZKcWRJd49EaYJXeIB8hSa8oWHDrqRWoyRbGUGHDYxJg,2898
23
23
  nbdev/test.py,sha256=74db-sK_rnc69Q3beztibXDSZUeOk6M9nIiIORLHzlo,4397
24
- nbdev-2.3.16.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
25
- nbdev-2.3.16.dist-info/METADATA,sha256=tvbByjiuZNqvmDEUGdNprXdpEeNBimbnoN8nVj4yLOc,10147
26
- nbdev-2.3.16.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
- nbdev-2.3.16.dist-info/entry_points.txt,sha256=lFZD1JQyZQI8x8PuaaSqbfnhInHhpm56nCR6n84nFKk,1272
28
- nbdev-2.3.16.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
29
- nbdev-2.3.16.dist-info/RECORD,,
24
+ nbdev-2.3.17.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
25
+ nbdev-2.3.17.dist-info/METADATA,sha256=zWQRL3G0WP0Z7SjfSbi4s1Zz2WGTs7FDFC7M3cmx8DE,10147
26
+ nbdev-2.3.17.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
+ nbdev-2.3.17.dist-info/entry_points.txt,sha256=lFZD1JQyZQI8x8PuaaSqbfnhInHhpm56nCR6n84nFKk,1272
28
+ nbdev-2.3.17.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
29
+ nbdev-2.3.17.dist-info/RECORD,,
File without changes