Skip to content

Commit 3208e39

Browse files
committed
Merge branch 'master' of github.com:deven367/nbdev
2 parents 04fb8f6 + b263f6b commit 3208e39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+962
-610
lines changed

.github/workflows/deploy-manual.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy to GitHub Pages (Manual)
22
on:
33
workflow_dispatch:
44
jobs:

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
fail-fast: true
1212
matrix:
1313
os: [ubuntu, macos]
14-
version: ["3.8", "3.9", "3.10", "3.11"]
14+
version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1515
runs-on: ${{ matrix.os }}-latest
1616
steps:
1717
- uses: fastai/workflows/nbdev-ci@master
1818
with:
1919
version: ${{ matrix.version }}
2020
pre: 1
2121
- name: test docs build
22-
if: ${{ (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') && matrix.version == '3.9' && matrix.os == 'ubuntu' }}
22+
if: ${{ (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') && matrix.version == '3.10' && matrix.os == 'ubuntu' }}
2323
run: |
2424
set -ux
2525
wget -q $(curl https://latest.fast.ai/pre/quarto-dev/quarto-cli/linux-amd64.deb)

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,54 @@
22

33
<!-- do not remove -->
44

5+
## 2.3.31
6+
7+
### New Features
8+
9+
- test if in `nbdev_repo` & improve `nbdev_export` err message ([#1448](https://github.com/fastai/nbdev/pull/1448)), thanks to [@hamelsmu](https://github.com/hamelsmu)
10+
11+
12+
## 2.3.30
13+
14+
### New Features
15+
16+
- add `skip_procs` to `settings.ini` ([#1445](https://github.com/fastai/nbdev/pull/1445)), thanks to [@hamelsmu](https://github.com/hamelsmu)
17+
18+
19+
## 2.3.29
20+
21+
### New Features
22+
23+
- Add `ai_magics` preprocessor ([#1442](https://github.com/fastai/nbdev/issues/1442))
24+
25+
26+
## 2.3.28
27+
28+
### New Features
29+
30+
- Generate module docstrings from markdown meta summary ([#1440](https://github.com/fastai/nbdev/issues/1440))
31+
- By default create markdown versions of docs too ([#1439](https://github.com/fastai/nbdev/issues/1439))
32+
- add markdown to doc output ([#1438](https://github.com/fastai/nbdev/issues/1438))
33+
34+
35+
## 2.3.27
36+
37+
- No new features or fixes---just an update to the pypi status since we forgot about it!
38+
39+
## 2.3.26
40+
41+
### New Features
42+
43+
- add enable/disable cell number in .py files ([#1428](https://github.com/fastai/nbdev/pull/1428)), thanks to [@dienhoa](https://github.com/dienhoa)
44+
- When exporting a notebook to a .py file, we currently have something like `# %% {nb_path} {cell_number}` at the beginning of each exported cell.
45+
- This PR adds one new setting in the setting.ini: `cell_number`. When set to False, we disable the `cell_number` discussed above.
46+
- Side effect: The `cell_number` is used to update the changes from .py back to the notebook, so disabling it also disables this feature.
47+
48+
### Bugs Squashed
49+
50+
- showdoc: SyntaxWarning: invalid escape sequence with Python 3.12 ([#1396](https://github.com/fastai/nbdev/issues/1396))
51+
52+
553
## 2.3.25
654

755
### New Features

nbdev/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.3.26"
1+
__version__ = "2.3.32"
22

33
from .doclinks import nbdev_export
44
from .showdoc import show_doc

nbdev/_modidx.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
'nbdev.cli._update_repo_meta': ('api/cli.html#_update_repo_meta', 'nbdev/cli.py'),
2424
'nbdev.cli.chelp': ('api/cli.html#chelp', 'nbdev/cli.py'),
2525
'nbdev.cli.extract_tgz': ('api/cli.html#extract_tgz', 'nbdev/cli.py'),
26+
'nbdev.cli.nb_export_cli': ('api/cli.html#nb_export_cli', 'nbdev/cli.py'),
2627
'nbdev.cli.nbdev_filter': ('api/cli.html#nbdev_filter', 'nbdev/cli.py'),
2728
'nbdev.cli.nbdev_new': ('api/cli.html#nbdev_new', 'nbdev/cli.py'),
28-
'nbdev.cli.nbdev_update_license': ('api/cli.html#nbdev_update_license', 'nbdev/cli.py')},
29+
'nbdev.cli.nbdev_update_license': ('api/cli.html#nbdev_update_license', 'nbdev/cli.py'),
30+
'nbdev.cli.watch_export': ('api/cli.html#watch_export', 'nbdev/cli.py')},
2931
'nbdev.config': { 'nbdev.config._apply_defaults': ('api/config.html#_apply_defaults', 'nbdev/config.py'),
3032
'nbdev.config._basic_export_nb': ('api/config.html#_basic_export_nb', 'nbdev/config.py'),
3133
'nbdev.config._cfg2txt': ('api/config.html#_cfg2txt', 'nbdev/config.py'),
@@ -41,6 +43,7 @@
4143
'nbdev.config.config_key': ('api/config.html#config_key', 'nbdev/config.py'),
4244
'nbdev.config.create_output': ('api/config.html#create_output', 'nbdev/config.py'),
4345
'nbdev.config.get_config': ('api/config.html#get_config', 'nbdev/config.py'),
46+
'nbdev.config.is_nbdev': ('api/config.html#is_nbdev', 'nbdev/config.py'),
4447
'nbdev.config.nbdev_create_config': ('api/config.html#nbdev_create_config', 'nbdev/config.py'),
4548
'nbdev.config.show_src': ('api/config.html#show_src', 'nbdev/config.py'),
4649
'nbdev.config.update_version': ('api/config.html#update_version', 'nbdev/config.py'),
@@ -71,6 +74,7 @@
7174
'nbdev.doclinks.nbglob_cli': ('api/doclinks.html#nbglob_cli', 'nbdev/doclinks.py'),
7275
'nbdev.doclinks.patch_name': ('api/doclinks.html#patch_name', 'nbdev/doclinks.py')},
7376
'nbdev.export': { 'nbdev.export.ExportModuleProc': ('api/export.html#exportmoduleproc', 'nbdev/export.py'),
77+
'nbdev.export.ExportModuleProc.__call__': ('api/export.html#exportmoduleproc.__call__', 'nbdev/export.py'),
7478
'nbdev.export.ExportModuleProc._default_exp_': ( 'api/export.html#exportmoduleproc._default_exp_',
7579
'nbdev/export.py'),
7680
'nbdev.export.ExportModuleProc._export_': ('api/export.html#exportmoduleproc._export_', 'nbdev/export.py'),
@@ -203,6 +207,7 @@
203207
'nbdev.processors.add_show_docs': ('api/processors.html#add_show_docs', 'nbdev/processors.py'),
204208
'nbdev.processors.add_show_docs.begin': ( 'api/processors.html#add_show_docs.begin',
205209
'nbdev/processors.py'),
210+
'nbdev.processors.ai_magics': ('api/processors.html#ai_magics', 'nbdev/processors.py'),
206211
'nbdev.processors.boxify': ('api/processors.html#boxify', 'nbdev/processors.py'),
207212
'nbdev.processors.cell_lang': ('api/processors.html#cell_lang', 'nbdev/processors.py'),
208213
'nbdev.processors.clean_magics': ('api/processors.html#clean_magics', 'nbdev/processors.py'),
@@ -329,6 +334,7 @@
329334
'nbdev.showdoc.ShowDocRenderer': ('api/showdoc.html#showdocrenderer', 'nbdev/showdoc.py'),
330335
'nbdev.showdoc.ShowDocRenderer.__init__': ('api/showdoc.html#showdocrenderer.__init__', 'nbdev/showdoc.py'),
331336
'nbdev.showdoc._bold': ('api/showdoc.html#_bold', 'nbdev/showdoc.py'),
337+
'nbdev.showdoc._create_html_table': ('api/showdoc.html#_create_html_table', 'nbdev/showdoc.py'),
332338
'nbdev.showdoc._docstring': ('api/showdoc.html#_docstring', 'nbdev/showdoc.py'),
333339
'nbdev.showdoc._escape_markdown': ('api/showdoc.html#_escape_markdown', 'nbdev/showdoc.py'),
334340
'nbdev.showdoc._ext_link': ('api/showdoc.html#_ext_link', 'nbdev/showdoc.py'),

nbdev/clean.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
"""Strip superfluous metadata from notebooks"""
2+
13
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/11_clean.ipynb.
24

35
# %% auto 0
46
__all__ = ['nbdev_trust', 'clean_nb', 'process_write', 'nbdev_clean', 'clean_jupyter', 'nbdev_install_hooks']
57

6-
# %% ../nbs/api/11_clean.ipynb 2
8+
# %% ../nbs/api/11_clean.ipynb
79
import ast,warnings,stat
810
from astunparse import unparse
911
from textwrap import indent
@@ -18,7 +20,7 @@
1820
from .sync import *
1921
from .process import first_code_ln
2022

21-
# %% ../nbs/api/11_clean.ipynb 6
23+
# %% ../nbs/api/11_clean.ipynb
2224
@call_parse
2325
def nbdev_trust(
2426
fname:str=None, # A notebook name or glob to trust
@@ -45,7 +47,7 @@ def nbdev_trust(
4547
if not NotebookNotary().check_signature(nb): NotebookNotary().sign(nb)
4648
check_fname.touch(exist_ok=True)
4749

48-
# %% ../nbs/api/11_clean.ipynb 9
50+
# %% ../nbs/api/11_clean.ipynb
4951
_repr_id_re = re.compile('(<.*?)( at 0x[0-9a-fA-F]+)(>)')
5052

5153
_sub = partial(_repr_id_re.sub, r'\1\3')
@@ -55,7 +57,7 @@ def _skip_or_sub(x): return _sub(x) if "at 0x" in x else x
5557
def _clean_cell_output_id(lines):
5658
return _skip_or_sub(lines) if isinstance(lines,str) else [_skip_or_sub(o) for o in lines]
5759

58-
# %% ../nbs/api/11_clean.ipynb 11
60+
# %% ../nbs/api/11_clean.ipynb
5961
def _clean_cell_output(cell, clean_ids):
6062
"Remove `cell` output execution count and optionally ids from text reprs"
6163
outputs = cell.get('outputs', [])
@@ -69,7 +71,7 @@ def _clean_cell_output(cell, clean_ids):
6971
if 'text' in o and clean_ids: o['text'] = _clean_cell_output_id(o['text'])
7072
o.get('metadata', {}).pop('tags', None)
7173

72-
# %% ../nbs/api/11_clean.ipynb 12
74+
# %% ../nbs/api/11_clean.ipynb
7375
def _clean_cell(cell, clear_all, allowed_metadata_keys, clean_ids):
7476
"Clean `cell` by removing superfluous metadata or everything except the input if `clear_all`"
7577
if 'execution_count' in cell: cell['execution_count'] = None
@@ -80,7 +82,7 @@ def _clean_cell(cell, clear_all, allowed_metadata_keys, clean_ids):
8082
cell['metadata'] = {} if clear_all else {
8183
k:v for k,v in cell['metadata'].items() if k in allowed_metadata_keys}
8284

83-
# %% ../nbs/api/11_clean.ipynb 13
85+
# %% ../nbs/api/11_clean.ipynb
8486
def clean_nb(
8587
nb, # The notebook to clean
8688
clear_all=False, # Remove all cell metadata and cell outputs?
@@ -98,12 +100,12 @@ def clean_nb(
98100
nb['metadata']['kernelspec']['display_name'] = nb["metadata"]["kernelspec"]["name"]
99101
nb['metadata'] = {k:v for k,v in nb['metadata'].items() if k in metadata_keys}
100102

101-
# %% ../nbs/api/11_clean.ipynb 26
103+
# %% ../nbs/api/11_clean.ipynb
102104
def _reconfigure(*strms):
103105
for s in strms:
104106
if hasattr(s,'reconfigure'): s.reconfigure(encoding='utf-8')
105107

106-
# %% ../nbs/api/11_clean.ipynb 27
108+
# %% ../nbs/api/11_clean.ipynb
107109
def process_write(warn_msg, proc_nb, f_in, f_out=None, disp=False):
108110
if not f_out: f_out = f_in
109111
if isinstance(f_in, (str,Path)): f_in = Path(f_in).open(encoding="utf-8")
@@ -116,7 +118,7 @@ def process_write(warn_msg, proc_nb, f_in, f_out=None, disp=False):
116118
warn(f'{warn_msg}')
117119
warn(e)
118120

119-
# %% ../nbs/api/11_clean.ipynb 28
121+
# %% ../nbs/api/11_clean.ipynb
120122
def _nbdev_clean(nb, path=None, clear_all=None):
121123
cfg = get_config(path=path)
122124
clear_all = clear_all or cfg.clear_all
@@ -125,7 +127,7 @@ def _nbdev_clean(nb, path=None, clear_all=None):
125127
clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)
126128
if path: nbdev_trust.__wrapped__(path)
127129

128-
# %% ../nbs/api/11_clean.ipynb 29
130+
# %% ../nbs/api/11_clean.ipynb
129131
@call_parse
130132
def nbdev_clean(
131133
fname:str=None, # A notebook name or glob to clean
@@ -141,15 +143,15 @@ def nbdev_clean(
141143
if fname is None: fname = get_config().nbs_path
142144
for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp)
143145

144-
# %% ../nbs/api/11_clean.ipynb 32
146+
# %% ../nbs/api/11_clean.ipynb
145147
def clean_jupyter(path, model, **kwargs):
146148
"Clean Jupyter `model` pre save to `path`"
147149
if not (model['type']=='notebook' and model['content']['nbformat']==4): return
148150
get_config.cache_clear() # Allow config changes without restarting Jupyter
149151
jupyter_hooks = get_config(path=path).jupyter_hooks
150152
if jupyter_hooks: _nbdev_clean(model['content'], path=path)
151153

152-
# %% ../nbs/api/11_clean.ipynb 35
154+
# %% ../nbs/api/11_clean.ipynb
153155
_pre_save_hook_src = '''
154156
def nbdev_clean_jupyter(**kwargs):
155157
try: from nbdev.clean import clean_jupyter
@@ -159,7 +161,7 @@ def nbdev_clean_jupyter(**kwargs):
159161
c.ContentsManager.pre_save_hook = nbdev_clean_jupyter'''.strip()
160162
_pre_save_hook_re = re.compile(r'c\.(File)?ContentsManager\.pre_save_hook')
161163

162-
# %% ../nbs/api/11_clean.ipynb 36
164+
# %% ../nbs/api/11_clean.ipynb
163165
def _add_jupyter_hooks(src, path):
164166
if _pre_save_hook_src in src: return
165167
mod = ast.parse(src)
@@ -177,12 +179,12 @@ def _add_jupyter_hooks(src, path):
177179
if src: src+='\n\n'
178180
return src+_pre_save_hook_src
179181

180-
# %% ../nbs/api/11_clean.ipynb 40
182+
# %% ../nbs/api/11_clean.ipynb
181183
def _git_root():
182184
try: return Path(run('git rev-parse --show-toplevel'))
183185
except OSError: return None
184186

185-
# %% ../nbs/api/11_clean.ipynb 43
187+
# %% ../nbs/api/11_clean.ipynb
186188
@call_parse
187189
def nbdev_install_hooks():
188190
"Install Jupyter and git hooks to automatically clean, trust, and fix merge conflicts in notebooks"

0 commit comments

Comments
 (0)