nbdev 2.3.17__py3-none-any.whl → 2.3.18__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 +1 -1
- nbdev/_modidx.py +2 -0
- nbdev/processors.py +37 -20
- {nbdev-2.3.17.dist-info → nbdev-2.3.18.dist-info}/METADATA +1 -1
- {nbdev-2.3.17.dist-info → nbdev-2.3.18.dist-info}/RECORD +9 -9
- {nbdev-2.3.17.dist-info → nbdev-2.3.18.dist-info}/LICENSE +0 -0
- {nbdev-2.3.17.dist-info → nbdev-2.3.18.dist-info}/WHEEL +0 -0
- {nbdev-2.3.17.dist-info → nbdev-2.3.18.dist-info}/entry_points.txt +0 -0
- {nbdev-2.3.17.dist-info → nbdev-2.3.18.dist-info}/top_level.txt +0 -0
nbdev/__init__.py
CHANGED
nbdev/_modidx.py
CHANGED
|
@@ -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,6 +213,7 @@ 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'),
|
nbdev/processors.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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_ansi', 'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_', 'clean_magics',
|
|
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
6
|
'rm_header_dash', 'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
|
|
7
7
|
|
|
8
8
|
# %% ../nbs/api/10_processors.ipynb 2
|
|
@@ -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]
|
|
@@ -83,15 +83,32 @@ class add_show_docs(Processor):
|
|
|
83
83
|
nb.has_docs_ = shown_docs or exports
|
|
84
84
|
|
|
85
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
|
|
86
99
|
class mv_exports(Processor):
|
|
87
100
|
"Move `exports` cells to after the `show_doc`"
|
|
88
101
|
def begin(self):
|
|
89
102
|
cells = self.nb.cells
|
|
90
103
|
exports = L(c for c in cells if c.cell_type=='code' and 'exports' in c.directives_)
|
|
91
104
|
for cell in reversed(exports):
|
|
92
|
-
|
|
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])
|
|
93
110
|
|
|
94
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
111
|
+
# %% ../nbs/api/10_processors.ipynb 21
|
|
95
112
|
_re_defaultexp = re.compile(r'^\s*#\|\s*default_exp\s+(\S+)', flags=re.MULTILINE)
|
|
96
113
|
|
|
97
114
|
def _default_exp(nb):
|
|
@@ -100,7 +117,7 @@ def _default_exp(nb):
|
|
|
100
117
|
default_exp = first(code_src.filter().map(_re_defaultexp.search).filter())
|
|
101
118
|
return default_exp.group(1) if default_exp else None
|
|
102
119
|
|
|
103
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
120
|
+
# %% ../nbs/api/10_processors.ipynb 23
|
|
104
121
|
def add_links(cell):
|
|
105
122
|
"Add links to markdown cells"
|
|
106
123
|
nl = NbdevLookup()
|
|
@@ -109,13 +126,13 @@ def add_links(cell):
|
|
|
109
126
|
if hasattr(o, 'data') and hasattr(o['data'], 'text/markdown'):
|
|
110
127
|
o.data['text/markdown'] = [nl.link_line(s) for s in o.data['text/markdown']]
|
|
111
128
|
|
|
112
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
129
|
+
# %% ../nbs/api/10_processors.ipynb 25
|
|
113
130
|
def add_fold(cell):
|
|
114
131
|
"Add `code-fold` to `exports` cells"
|
|
115
132
|
if cell.cell_type != 'code' or 'exports' not in cell.directives_: return
|
|
116
133
|
cell.source = f'#| code-fold: show\n#| code-summary: "Exported source"\n{cell.source}'
|
|
117
134
|
|
|
118
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
135
|
+
# %% ../nbs/api/10_processors.ipynb 28
|
|
119
136
|
_re_ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
120
137
|
|
|
121
138
|
def strip_ansi(cell):
|
|
@@ -123,17 +140,17 @@ def strip_ansi(cell):
|
|
|
123
140
|
for outp in cell.get('outputs', []):
|
|
124
141
|
if outp.get('name')=='stdout': outp['text'] = [_re_ansi_escape.sub('', o) for o in outp.text]
|
|
125
142
|
|
|
126
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
143
|
+
# %% ../nbs/api/10_processors.ipynb 30
|
|
127
144
|
def strip_hidden_metadata(cell):
|
|
128
145
|
'''Strips "hidden" metadata property from code cells so it doesn't interfere with docs rendering'''
|
|
129
146
|
if cell.cell_type == 'code' and 'metadata' in cell: cell.metadata.pop('hidden',None)
|
|
130
147
|
|
|
131
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
148
|
+
# %% ../nbs/api/10_processors.ipynb 31
|
|
132
149
|
def hide_(cell):
|
|
133
150
|
"Hide cell from output"
|
|
134
151
|
del(cell['source'])
|
|
135
152
|
|
|
136
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
153
|
+
# %% ../nbs/api/10_processors.ipynb 33
|
|
137
154
|
def _re_hideline(lang=None): return re.compile(fr'{langs[lang]}\|\s*hide_line\s*$', re.MULTILINE)
|
|
138
155
|
|
|
139
156
|
def hide_line(cell):
|
|
@@ -142,7 +159,7 @@ def hide_line(cell):
|
|
|
142
159
|
if cell.cell_type == 'code' and _re_hideline(lang).search(cell.source):
|
|
143
160
|
cell.source = '\n'.join([c for c in cell.source.splitlines() if not _re_hideline(lang).search(c)])
|
|
144
161
|
|
|
145
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
162
|
+
# %% ../nbs/api/10_processors.ipynb 36
|
|
146
163
|
def filter_stream_(cell, *words):
|
|
147
164
|
"Remove output lines containing any of `words` in `cell` stream output"
|
|
148
165
|
if not words: return
|
|
@@ -150,14 +167,14 @@ def filter_stream_(cell, *words):
|
|
|
150
167
|
if outp.output_type == 'stream':
|
|
151
168
|
outp['text'] = [l for l in outp.text if not re.search('|'.join(words), l)]
|
|
152
169
|
|
|
153
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
170
|
+
# %% ../nbs/api/10_processors.ipynb 38
|
|
154
171
|
_magics_pattern = re.compile(r'^\s*(%%|%).*', re.MULTILINE)
|
|
155
172
|
|
|
156
173
|
def clean_magics(cell):
|
|
157
174
|
"A preprocessor to remove cell magic commands"
|
|
158
175
|
if cell.cell_type == 'code': cell.source = _magics_pattern.sub('', cell.source).strip()
|
|
159
176
|
|
|
160
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
177
|
+
# %% ../nbs/api/10_processors.ipynb 40
|
|
161
178
|
_re_hdr_dash = re.compile(r'^#+\s+.*\s+-\s*$', re.MULTILINE)
|
|
162
179
|
|
|
163
180
|
def rm_header_dash(cell):
|
|
@@ -166,14 +183,14 @@ def rm_header_dash(cell):
|
|
|
166
183
|
src = cell.source.strip()
|
|
167
184
|
if cell.cell_type == 'markdown' and src.startswith('#') and src.endswith(' -'): del(cell['source'])
|
|
168
185
|
|
|
169
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
186
|
+
# %% ../nbs/api/10_processors.ipynb 42
|
|
170
187
|
_hide_dirs = {'export','exporti', 'hide','default_exp'}
|
|
171
188
|
|
|
172
189
|
def rm_export(cell):
|
|
173
190
|
"Remove cells that are exported or hidden"
|
|
174
191
|
if cell.directives_ and (cell.directives_.keys() & _hide_dirs): del(cell['source'])
|
|
175
192
|
|
|
176
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
193
|
+
# %% ../nbs/api/10_processors.ipynb 44
|
|
177
194
|
_re_showdoc = re.compile(r'^show_doc', re.MULTILINE)
|
|
178
195
|
def _is_showdoc(cell): return cell['cell_type'] == 'code' and _re_showdoc.search(cell.source)
|
|
179
196
|
def _add_directives(cell, d):
|
|
@@ -185,7 +202,7 @@ def clean_show_doc(cell):
|
|
|
185
202
|
if not _is_showdoc(cell): return
|
|
186
203
|
_add_directives(cell, {'output':'asis','echo':'false'})
|
|
187
204
|
|
|
188
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
205
|
+
# %% ../nbs/api/10_processors.ipynb 45
|
|
189
206
|
def _ast_contains(trees, types):
|
|
190
207
|
for tree in trees:
|
|
191
208
|
for node in ast.walk(tree):
|
|
@@ -206,7 +223,7 @@ def _do_eval(cell):
|
|
|
206
223
|
return True
|
|
207
224
|
if _show_docs(trees): return True
|
|
208
225
|
|
|
209
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
226
|
+
# %% ../nbs/api/10_processors.ipynb 46
|
|
210
227
|
class exec_show_docs(Processor):
|
|
211
228
|
"Execute cells needed for `show_docs` output, including exported cells and imports"
|
|
212
229
|
def begin(self):
|
|
@@ -233,13 +250,13 @@ class exec_show_docs(Processor):
|
|
|
233
250
|
widgets = {**old, **new, 'state': {**old.get('state', {}), **new['state']}}
|
|
234
251
|
self.nb.metadata['widgets'] = {mimetype: widgets}
|
|
235
252
|
|
|
236
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
253
|
+
# %% ../nbs/api/10_processors.ipynb 48
|
|
237
254
|
def _import_obj(s):
|
|
238
255
|
mod_nm, obj_nm = s.split(':')
|
|
239
256
|
mod = importlib.import_module(mod_nm)
|
|
240
257
|
return getattr(mod, obj_nm)
|
|
241
258
|
|
|
242
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
259
|
+
# %% ../nbs/api/10_processors.ipynb 49
|
|
243
260
|
class FilterDefaults:
|
|
244
261
|
"Override `FilterDefaults` to change which notebook processors are used"
|
|
245
262
|
def xtra_procs(self):
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
nbdev/__init__.py,sha256=
|
|
2
|
-
nbdev/_modidx.py,sha256=
|
|
1
|
+
nbdev/__init__.py,sha256=i9k9vBUwaGmfbscm1LCehBge6qxX8zZBItJCCkZ6ixA,90
|
|
2
|
+
nbdev/_modidx.py,sha256=cfvhKryWwys106hchXzhcUqC37lQHHAKJKk6vrUiRAs,40317
|
|
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=
|
|
15
|
+
nbdev/processors.py,sha256=3dyoh-6Zr4KeohuAPgfskRpfgQySZoOzknEC-HH9L2Y,11500
|
|
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.
|
|
25
|
-
nbdev-2.3.
|
|
26
|
-
nbdev-2.3.
|
|
27
|
-
nbdev-2.3.
|
|
28
|
-
nbdev-2.3.
|
|
29
|
-
nbdev-2.3.
|
|
24
|
+
nbdev-2.3.18.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
25
|
+
nbdev-2.3.18.dist-info/METADATA,sha256=2rkbU7V8sIwbhkJgTB8v4XS31iQtC4di4epYe32pRwI,10147
|
|
26
|
+
nbdev-2.3.18.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
27
|
+
nbdev-2.3.18.dist-info/entry_points.txt,sha256=lFZD1JQyZQI8x8PuaaSqbfnhInHhpm56nCR6n84nFKk,1272
|
|
28
|
+
nbdev-2.3.18.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
|
|
29
|
+
nbdev-2.3.18.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|