nbdev 2.3.15__py3-none-any.whl → 2.3.16__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 +1 -0
- nbdev/processors.py +23 -16
- {nbdev-2.3.15.dist-info → nbdev-2.3.16.dist-info}/METADATA +1 -1
- {nbdev-2.3.15.dist-info → nbdev-2.3.16.dist-info}/RECORD +9 -9
- {nbdev-2.3.15.dist-info → nbdev-2.3.16.dist-info}/LICENSE +0 -0
- {nbdev-2.3.15.dist-info → nbdev-2.3.16.dist-info}/WHEEL +0 -0
- {nbdev-2.3.15.dist-info → nbdev-2.3.16.dist-info}/entry_points.txt +0 -0
- {nbdev-2.3.15.dist-info → nbdev-2.3.16.dist-info}/top_level.txt +0 -0
nbdev/__init__.py
CHANGED
nbdev/_modidx.py
CHANGED
|
@@ -198,6 +198,7 @@ d = { 'settings': { 'branch': 'master',
|
|
|
198
198
|
'nbdev.processors._re_hideline': ('api/processors.html#_re_hideline', 'nbdev/processors.py'),
|
|
199
199
|
'nbdev.processors._show_docs': ('api/processors.html#_show_docs', 'nbdev/processors.py'),
|
|
200
200
|
'nbdev.processors._want_doc': ('api/processors.html#_want_doc', 'nbdev/processors.py'),
|
|
201
|
+
'nbdev.processors.add_fold': ('api/processors.html#add_fold', 'nbdev/processors.py'),
|
|
201
202
|
'nbdev.processors.add_links': ('api/processors.html#add_links', 'nbdev/processors.py'),
|
|
202
203
|
'nbdev.processors.add_show_docs': ('api/processors.html#add_show_docs', 'nbdev/processors.py'),
|
|
203
204
|
'nbdev.processors.add_show_docs.begin': ( 'api/processors.html#add_show_docs.begin',
|
nbdev/processors.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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', 'strip_ansi',
|
|
4
|
+
__all__ = ['populate_language', 'insert_warning', 'cell_lang', 'add_show_docs', 'add_links', 'add_fold', 'strip_ansi',
|
|
5
5
|
'strip_hidden_metadata', 'hide_', 'hide_line', 'filter_stream_', 'clean_magics', 'rm_header_dash',
|
|
6
6
|
'rm_export', 'clean_show_doc', 'exec_show_docs', 'FilterDefaults']
|
|
7
7
|
|
|
@@ -75,7 +75,8 @@ class add_show_docs(Processor):
|
|
|
75
75
|
shown_docs = {_get_nm(t) for t in _show_docs(trees)}
|
|
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
80
|
nb.has_docs_ = shown_docs or exports
|
|
80
81
|
|
|
81
82
|
# %% ../nbs/api/10_processors.ipynb 17
|
|
@@ -96,7 +97,13 @@ def add_links(cell):
|
|
|
96
97
|
if hasattr(o, 'data') and hasattr(o['data'], 'text/markdown'):
|
|
97
98
|
o.data['text/markdown'] = [nl.link_line(s) for s in o.data['text/markdown']]
|
|
98
99
|
|
|
99
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
100
|
+
# %% ../nbs/api/10_processors.ipynb 21
|
|
101
|
+
def add_fold(cell):
|
|
102
|
+
"Add `code-fold` to `exports` cells"
|
|
103
|
+
if cell.cell_type != 'code' or 'exports' not in cell.directives_: return
|
|
104
|
+
cell.source = f'#| code-fold: show\n#| code-summary: "Exported source"\n{cell.source}'
|
|
105
|
+
|
|
106
|
+
# %% ../nbs/api/10_processors.ipynb 24
|
|
100
107
|
_re_ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
101
108
|
|
|
102
109
|
def strip_ansi(cell):
|
|
@@ -104,17 +111,17 @@ def strip_ansi(cell):
|
|
|
104
111
|
for outp in cell.get('outputs', []):
|
|
105
112
|
if outp.get('name')=='stdout': outp['text'] = [_re_ansi_escape.sub('', o) for o in outp.text]
|
|
106
113
|
|
|
107
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
114
|
+
# %% ../nbs/api/10_processors.ipynb 26
|
|
108
115
|
def strip_hidden_metadata(cell):
|
|
109
116
|
'''Strips "hidden" metadata property from code cells so it doesn't interfere with docs rendering'''
|
|
110
117
|
if cell.cell_type == 'code' and 'metadata' in cell: cell.metadata.pop('hidden',None)
|
|
111
118
|
|
|
112
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
119
|
+
# %% ../nbs/api/10_processors.ipynb 27
|
|
113
120
|
def hide_(cell):
|
|
114
121
|
"Hide cell from output"
|
|
115
122
|
del(cell['source'])
|
|
116
123
|
|
|
117
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
124
|
+
# %% ../nbs/api/10_processors.ipynb 29
|
|
118
125
|
def _re_hideline(lang=None): return re.compile(fr'{langs[lang]}\|\s*hide_line\s*$', re.MULTILINE)
|
|
119
126
|
|
|
120
127
|
def hide_line(cell):
|
|
@@ -123,7 +130,7 @@ def hide_line(cell):
|
|
|
123
130
|
if cell.cell_type == 'code' and _re_hideline(lang).search(cell.source):
|
|
124
131
|
cell.source = '\n'.join([c for c in cell.source.splitlines() if not _re_hideline(lang).search(c)])
|
|
125
132
|
|
|
126
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
133
|
+
# %% ../nbs/api/10_processors.ipynb 32
|
|
127
134
|
def filter_stream_(cell, *words):
|
|
128
135
|
"Remove output lines containing any of `words` in `cell` stream output"
|
|
129
136
|
if not words: return
|
|
@@ -131,14 +138,14 @@ def filter_stream_(cell, *words):
|
|
|
131
138
|
if outp.output_type == 'stream':
|
|
132
139
|
outp['text'] = [l for l in outp.text if not re.search('|'.join(words), l)]
|
|
133
140
|
|
|
134
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
141
|
+
# %% ../nbs/api/10_processors.ipynb 34
|
|
135
142
|
_magics_pattern = re.compile(r'^\s*(%%|%).*', re.MULTILINE)
|
|
136
143
|
|
|
137
144
|
def clean_magics(cell):
|
|
138
145
|
"A preprocessor to remove cell magic commands"
|
|
139
146
|
if cell.cell_type == 'code': cell.source = _magics_pattern.sub('', cell.source).strip()
|
|
140
147
|
|
|
141
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
148
|
+
# %% ../nbs/api/10_processors.ipynb 36
|
|
142
149
|
_re_hdr_dash = re.compile(r'^#+\s+.*\s+-\s*$', re.MULTILINE)
|
|
143
150
|
|
|
144
151
|
def rm_header_dash(cell):
|
|
@@ -147,14 +154,14 @@ def rm_header_dash(cell):
|
|
|
147
154
|
src = cell.source.strip()
|
|
148
155
|
if cell.cell_type == 'markdown' and src.startswith('#') and src.endswith(' -'): del(cell['source'])
|
|
149
156
|
|
|
150
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
157
|
+
# %% ../nbs/api/10_processors.ipynb 38
|
|
151
158
|
_hide_dirs = {'export','exporti', 'hide','default_exp'}
|
|
152
159
|
|
|
153
160
|
def rm_export(cell):
|
|
154
161
|
"Remove cells that are exported or hidden"
|
|
155
162
|
if cell.directives_ and (cell.directives_.keys() & _hide_dirs): del(cell['source'])
|
|
156
163
|
|
|
157
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
164
|
+
# %% ../nbs/api/10_processors.ipynb 40
|
|
158
165
|
_re_showdoc = re.compile(r'^show_doc', re.MULTILINE)
|
|
159
166
|
def _is_showdoc(cell): return cell['cell_type'] == 'code' and _re_showdoc.search(cell.source)
|
|
160
167
|
def _add_directives(cell, d):
|
|
@@ -166,7 +173,7 @@ def clean_show_doc(cell):
|
|
|
166
173
|
if not _is_showdoc(cell): return
|
|
167
174
|
_add_directives(cell, {'output':'asis','echo':'false'})
|
|
168
175
|
|
|
169
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
176
|
+
# %% ../nbs/api/10_processors.ipynb 41
|
|
170
177
|
def _ast_contains(trees, types):
|
|
171
178
|
for tree in trees:
|
|
172
179
|
for node in ast.walk(tree):
|
|
@@ -187,7 +194,7 @@ def _do_eval(cell):
|
|
|
187
194
|
return True
|
|
188
195
|
if _show_docs(trees): return True
|
|
189
196
|
|
|
190
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
197
|
+
# %% ../nbs/api/10_processors.ipynb 42
|
|
191
198
|
class exec_show_docs(Processor):
|
|
192
199
|
"Execute cells needed for `show_docs` output, including exported cells and imports"
|
|
193
200
|
def begin(self):
|
|
@@ -214,13 +221,13 @@ class exec_show_docs(Processor):
|
|
|
214
221
|
widgets = {**old, **new, 'state': {**old.get('state', {}), **new['state']}}
|
|
215
222
|
self.nb.metadata['widgets'] = {mimetype: widgets}
|
|
216
223
|
|
|
217
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
224
|
+
# %% ../nbs/api/10_processors.ipynb 44
|
|
218
225
|
def _import_obj(s):
|
|
219
226
|
mod_nm, obj_nm = s.split(':')
|
|
220
227
|
mod = importlib.import_module(mod_nm)
|
|
221
228
|
return getattr(mod, obj_nm)
|
|
222
229
|
|
|
223
|
-
# %% ../nbs/api/10_processors.ipynb
|
|
230
|
+
# %% ../nbs/api/10_processors.ipynb 45
|
|
224
231
|
class FilterDefaults:
|
|
225
232
|
"Override `FilterDefaults` to change which notebook processors are used"
|
|
226
233
|
def xtra_procs(self):
|
|
@@ -230,7 +237,7 @@ class FilterDefaults:
|
|
|
230
237
|
def base_procs(self):
|
|
231
238
|
return [FrontmatterProc, populate_language, add_show_docs, insert_warning,
|
|
232
239
|
strip_ansi, hide_line, filter_stream_, rm_header_dash,
|
|
233
|
-
clean_show_doc, exec_show_docs, rm_export, clean_magics, hide_, add_links, strip_hidden_metadata]
|
|
240
|
+
clean_show_doc, exec_show_docs, rm_export, clean_magics, hide_, add_links, add_fold, strip_hidden_metadata]
|
|
234
241
|
|
|
235
242
|
def procs(self):
|
|
236
243
|
"Processors for export"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
nbdev/__init__.py,sha256=
|
|
2
|
-
nbdev/_modidx.py,sha256=
|
|
1
|
+
nbdev/__init__.py,sha256=cR2CXJXv4hmEFBCEdnpa-u00ZIqy8-iis3aigQ6n7XE,90
|
|
2
|
+
nbdev/_modidx.py,sha256=NF3X3yYWR2T86nBSc-2FC5hdaV7fRa_u6Q5dA6VErvY,39829
|
|
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=XAHa7emkuA5XGcyySwvjBDOMn90OcWs4WfTULSmML4g,10361
|
|
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.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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|