nbdev 2.3.16__tar.gz → 2.3.18__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-2.3.16/nbdev.egg-info → nbdev-2.3.18}/PKG-INFO +1 -1
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/__init__.py +1 -1
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/_modidx.py +4 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/processors.py +50 -21
- {nbdev-2.3.16 → nbdev-2.3.18/nbdev.egg-info}/PKG-INFO +1 -1
- {nbdev-2.3.16 → nbdev-2.3.18}/settings.ini +1 -1
- {nbdev-2.3.16 → nbdev-2.3.18}/CONTRIBUTING.md +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/LICENSE +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/MANIFEST.in +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/README.md +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/clean.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/cli.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/config.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/doclinks.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/export.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/extract_attachments.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/frontmatter.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/imports.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/maker.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/merge.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/migrate.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/process.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/qmd.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/quarto.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/release.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/serve.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/serve_drv.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/showdoc.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/sync.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev/test.py +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev.egg-info/SOURCES.txt +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev.egg-info/dependency_links.txt +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev.egg-info/entry_points.txt +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev.egg-info/not-zip-safe +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev.egg-info/requires.txt +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/nbdev.egg-info/top_level.txt +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/setup.cfg +0 -0
- {nbdev-2.3.16 → nbdev-2.3.18}/setup.py +0 -0
|
@@ -203,6 +203,7 @@ d = { 'settings': { 'branch': 'master',
|
|
|
203
203
|
'nbdev.processors.add_show_docs': ('api/processors.html#add_show_docs', 'nbdev/processors.py'),
|
|
204
204
|
'nbdev.processors.add_show_docs.begin': ( 'api/processors.html#add_show_docs.begin',
|
|
205
205
|
'nbdev/processors.py'),
|
|
206
|
+
'nbdev.processors.boxify': ('api/processors.html#boxify', 'nbdev/processors.py'),
|
|
206
207
|
'nbdev.processors.cell_lang': ('api/processors.html#cell_lang', 'nbdev/processors.py'),
|
|
207
208
|
'nbdev.processors.clean_magics': ('api/processors.html#clean_magics', 'nbdev/processors.py'),
|
|
208
209
|
'nbdev.processors.clean_show_doc': ('api/processors.html#clean_show_doc', 'nbdev/processors.py'),
|
|
@@ -212,12 +213,15 @@ d = { 'settings': { 'branch': 'master',
|
|
|
212
213
|
'nbdev.processors.exec_show_docs.begin': ( 'api/processors.html#exec_show_docs.begin',
|
|
213
214
|
'nbdev/processors.py'),
|
|
214
215
|
'nbdev.processors.exec_show_docs.end': ('api/processors.html#exec_show_docs.end', 'nbdev/processors.py'),
|
|
216
|
+
'nbdev.processors.fdiv': ('api/processors.html#fdiv', 'nbdev/processors.py'),
|
|
215
217
|
'nbdev.processors.filter_stream_': ('api/processors.html#filter_stream_', 'nbdev/processors.py'),
|
|
216
218
|
'nbdev.processors.hide_': ('api/processors.html#hide_', 'nbdev/processors.py'),
|
|
217
219
|
'nbdev.processors.hide_line': ('api/processors.html#hide_line', 'nbdev/processors.py'),
|
|
218
220
|
'nbdev.processors.insert_warning': ('api/processors.html#insert_warning', 'nbdev/processors.py'),
|
|
219
221
|
'nbdev.processors.insert_warning.begin': ( 'api/processors.html#insert_warning.begin',
|
|
220
222
|
'nbdev/processors.py'),
|
|
223
|
+
'nbdev.processors.mv_exports': ('api/processors.html#mv_exports', 'nbdev/processors.py'),
|
|
224
|
+
'nbdev.processors.mv_exports.begin': ('api/processors.html#mv_exports.begin', 'nbdev/processors.py'),
|
|
221
225
|
'nbdev.processors.populate_language': ('api/processors.html#populate_language', 'nbdev/processors.py'),
|
|
222
226
|
'nbdev.processors.populate_language.begin': ( 'api/processors.html#populate_language.begin',
|
|
223
227
|
'nbdev/processors.py'),
|
|
@@ -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', '
|
|
5
|
-
'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_', 'clean_magics',
|
|
6
|
-
'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
|
|
4
|
+
__all__ = ['populate_language', 'insert_warning', 'cell_lang', 'add_show_docs', 'fdiv', 'boxify', 'mv_exports', 'add_links',
|
|
5
|
+
'add_fold', '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
|
|
@@ -47,7 +47,7 @@ _def_types = (ast.FunctionDef,ast.AsyncFunctionDef,ast.ClassDef)
|
|
|
47
47
|
def _def_names(cell, shown):
|
|
48
48
|
cellp = cell.parsed_()
|
|
49
49
|
return [showdoc_nm(o) for o in concat(cellp)
|
|
50
|
-
if isinstance(o,_def_types) and o.name not in shown and o.name[0]!='_'] if cellp else []
|
|
50
|
+
if isinstance(o,_def_types) and o.name not in shown and (o.name[0]!='_' or o.name[:2]=='__')] if cellp else []
|
|
51
51
|
|
|
52
52
|
def _get_nm(tree):
|
|
53
53
|
i = tree.value.args[0]
|
|
@@ -76,10 +76,39 @@ 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:
|
|
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
|
+
def fdiv(attrs=''):
|
|
87
|
+
"Create a fenced div markdown cell in quarto"
|
|
88
|
+
if attrs: attrs = ' {'+attrs+'}'
|
|
89
|
+
return mk_cell(':::'+attrs, cell_type='markdown')
|
|
90
|
+
|
|
91
|
+
# %% ../nbs/api/10_processors.ipynb 19
|
|
92
|
+
def boxify(cells):
|
|
93
|
+
"Add a box around `cells`"
|
|
94
|
+
if not isinstance(cells, list): cells = [cells]
|
|
95
|
+
res = [fdiv('.py-2 .px-3 .mb-4 fig-align="center" .border .rounded .shadow-sm')]
|
|
96
|
+
return res+cells+[fdiv()]
|
|
97
|
+
|
|
98
|
+
# %% ../nbs/api/10_processors.ipynb 20
|
|
99
|
+
class mv_exports(Processor):
|
|
100
|
+
"Move `exports` cells to after the `show_doc`"
|
|
101
|
+
def begin(self):
|
|
102
|
+
cells = self.nb.cells
|
|
103
|
+
exports = L(c for c in cells if c.cell_type=='code' and 'exports' in c.directives_)
|
|
104
|
+
for cell in reversed(exports):
|
|
105
|
+
idx = cell.idx_
|
|
106
|
+
if getattr(cells[idx+1], 'has_sd', 0):
|
|
107
|
+
doccell = cells.pop(idx+1)
|
|
108
|
+
srccell = cells.pop(idx)
|
|
109
|
+
cells[idx:idx] = boxify([doccell,srccell])
|
|
110
|
+
|
|
111
|
+
# %% ../nbs/api/10_processors.ipynb 21
|
|
83
112
|
_re_defaultexp = re.compile(r'^\s*#\|\s*default_exp\s+(\S+)', flags=re.MULTILINE)
|
|
84
113
|
|
|
85
114
|
def _default_exp(nb):
|
|
@@ -88,7 +117,7 @@ def _default_exp(nb):
|
|
|
88
117
|
default_exp = first(code_src.filter().map(_re_defaultexp.search).filter())
|
|
89
118
|
return default_exp.group(1) if default_exp else None
|
|
90
119
|
|
|
91
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
120
|
+
# %% ../nbs/api/10_processors.ipynb 23
|
|
92
121
|
def add_links(cell):
|
|
93
122
|
"Add links to markdown cells"
|
|
94
123
|
nl = NbdevLookup()
|
|
@@ -97,13 +126,13 @@ def add_links(cell):
|
|
|
97
126
|
if hasattr(o, 'data') and hasattr(o['data'], 'text/markdown'):
|
|
98
127
|
o.data['text/markdown'] = [nl.link_line(s) for s in o.data['text/markdown']]
|
|
99
128
|
|
|
100
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
129
|
+
# %% ../nbs/api/10_processors.ipynb 25
|
|
101
130
|
def add_fold(cell):
|
|
102
131
|
"Add `code-fold` to `exports` cells"
|
|
103
132
|
if cell.cell_type != 'code' or 'exports' not in cell.directives_: return
|
|
104
133
|
cell.source = f'#| code-fold: show\n#| code-summary: "Exported source"\n{cell.source}'
|
|
105
134
|
|
|
106
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
135
|
+
# %% ../nbs/api/10_processors.ipynb 28
|
|
107
136
|
_re_ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
108
137
|
|
|
109
138
|
def strip_ansi(cell):
|
|
@@ -111,17 +140,17 @@ def strip_ansi(cell):
|
|
|
111
140
|
for outp in cell.get('outputs', []):
|
|
112
141
|
if outp.get('name')=='stdout': outp['text'] = [_re_ansi_escape.sub('', o) for o in outp.text]
|
|
113
142
|
|
|
114
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
143
|
+
# %% ../nbs/api/10_processors.ipynb 30
|
|
115
144
|
def strip_hidden_metadata(cell):
|
|
116
145
|
'''Strips "hidden" metadata property from code cells so it doesn't interfere with docs rendering'''
|
|
117
146
|
if cell.cell_type == 'code' and 'metadata' in cell: cell.metadata.pop('hidden',None)
|
|
118
147
|
|
|
119
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
148
|
+
# %% ../nbs/api/10_processors.ipynb 31
|
|
120
149
|
def hide_(cell):
|
|
121
150
|
"Hide cell from output"
|
|
122
151
|
del(cell['source'])
|
|
123
152
|
|
|
124
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
153
|
+
# %% ../nbs/api/10_processors.ipynb 33
|
|
125
154
|
def _re_hideline(lang=None): return re.compile(fr'{langs[lang]}\|\s*hide_line\s*$', re.MULTILINE)
|
|
126
155
|
|
|
127
156
|
def hide_line(cell):
|
|
@@ -130,7 +159,7 @@ def hide_line(cell):
|
|
|
130
159
|
if cell.cell_type == 'code' and _re_hideline(lang).search(cell.source):
|
|
131
160
|
cell.source = '\n'.join([c for c in cell.source.splitlines() if not _re_hideline(lang).search(c)])
|
|
132
161
|
|
|
133
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
162
|
+
# %% ../nbs/api/10_processors.ipynb 36
|
|
134
163
|
def filter_stream_(cell, *words):
|
|
135
164
|
"Remove output lines containing any of `words` in `cell` stream output"
|
|
136
165
|
if not words: return
|
|
@@ -138,14 +167,14 @@ def filter_stream_(cell, *words):
|
|
|
138
167
|
if outp.output_type == 'stream':
|
|
139
168
|
outp['text'] = [l for l in outp.text if not re.search('|'.join(words), l)]
|
|
140
169
|
|
|
141
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
170
|
+
# %% ../nbs/api/10_processors.ipynb 38
|
|
142
171
|
_magics_pattern = re.compile(r'^\s*(%%|%).*', re.MULTILINE)
|
|
143
172
|
|
|
144
173
|
def clean_magics(cell):
|
|
145
174
|
"A preprocessor to remove cell magic commands"
|
|
146
175
|
if cell.cell_type == 'code': cell.source = _magics_pattern.sub('', cell.source).strip()
|
|
147
176
|
|
|
148
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
177
|
+
# %% ../nbs/api/10_processors.ipynb 40
|
|
149
178
|
_re_hdr_dash = re.compile(r'^#+\s+.*\s+-\s*$', re.MULTILINE)
|
|
150
179
|
|
|
151
180
|
def rm_header_dash(cell):
|
|
@@ -154,14 +183,14 @@ def rm_header_dash(cell):
|
|
|
154
183
|
src = cell.source.strip()
|
|
155
184
|
if cell.cell_type == 'markdown' and src.startswith('#') and src.endswith(' -'): del(cell['source'])
|
|
156
185
|
|
|
157
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
186
|
+
# %% ../nbs/api/10_processors.ipynb 42
|
|
158
187
|
_hide_dirs = {'export','exporti', 'hide','default_exp'}
|
|
159
188
|
|
|
160
189
|
def rm_export(cell):
|
|
161
190
|
"Remove cells that are exported or hidden"
|
|
162
191
|
if cell.directives_ and (cell.directives_.keys() & _hide_dirs): del(cell['source'])
|
|
163
192
|
|
|
164
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
193
|
+
# %% ../nbs/api/10_processors.ipynb 44
|
|
165
194
|
_re_showdoc = re.compile(r'^show_doc', re.MULTILINE)
|
|
166
195
|
def _is_showdoc(cell): return cell['cell_type'] == 'code' and _re_showdoc.search(cell.source)
|
|
167
196
|
def _add_directives(cell, d):
|
|
@@ -173,7 +202,7 @@ def clean_show_doc(cell):
|
|
|
173
202
|
if not _is_showdoc(cell): return
|
|
174
203
|
_add_directives(cell, {'output':'asis','echo':'false'})
|
|
175
204
|
|
|
176
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
205
|
+
# %% ../nbs/api/10_processors.ipynb 45
|
|
177
206
|
def _ast_contains(trees, types):
|
|
178
207
|
for tree in trees:
|
|
179
208
|
for node in ast.walk(tree):
|
|
@@ -194,7 +223,7 @@ def _do_eval(cell):
|
|
|
194
223
|
return True
|
|
195
224
|
if _show_docs(trees): return True
|
|
196
225
|
|
|
197
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
226
|
+
# %% ../nbs/api/10_processors.ipynb 46
|
|
198
227
|
class exec_show_docs(Processor):
|
|
199
228
|
"Execute cells needed for `show_docs` output, including exported cells and imports"
|
|
200
229
|
def begin(self):
|
|
@@ -221,13 +250,13 @@ class exec_show_docs(Processor):
|
|
|
221
250
|
widgets = {**old, **new, 'state': {**old.get('state', {}), **new['state']}}
|
|
222
251
|
self.nb.metadata['widgets'] = {mimetype: widgets}
|
|
223
252
|
|
|
224
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
253
|
+
# %% ../nbs/api/10_processors.ipynb 48
|
|
225
254
|
def _import_obj(s):
|
|
226
255
|
mod_nm, obj_nm = s.split(':')
|
|
227
256
|
mod = importlib.import_module(mod_nm)
|
|
228
257
|
return getattr(mod, obj_nm)
|
|
229
258
|
|
|
230
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
259
|
+
# %% ../nbs/api/10_processors.ipynb 49
|
|
231
260
|
class FilterDefaults:
|
|
232
261
|
"Override `FilterDefaults` to change which notebook processors are used"
|
|
233
262
|
def xtra_procs(self):
|
|
@@ -237,7 +266,7 @@ class FilterDefaults:
|
|
|
237
266
|
def base_procs(self):
|
|
238
267
|
return [FrontmatterProc, populate_language, add_show_docs, insert_warning,
|
|
239
268
|
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]
|
|
269
|
+
clean_show_doc, exec_show_docs, rm_export, clean_magics, hide_, add_links, add_fold, mv_exports, strip_hidden_metadata]
|
|
241
270
|
|
|
242
271
|
def procs(self):
|
|
243
272
|
"Processors for export"
|
|
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
|