Skip to content

Commit 570e80c

Browse files
committed
fixes #1558
1 parent 26e4db4 commit 570e80c

36 files changed

+1078
-892
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
dlgs/
12
archived/
23
SOLVEIT.ipynb
34
_publish.yml

nbdev/__init__.py

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

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

nbdev/_modidx.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,27 @@
2828
'nbdev.cli.nbdev_new': ('api/cli.html#nbdev_new', 'nbdev/cli.py'),
2929
'nbdev.cli.nbdev_update_license': ('api/cli.html#nbdev_update_license', 'nbdev/cli.py'),
3030
'nbdev.cli.watch_export': ('api/cli.html#watch_export', 'nbdev/cli.py')},
31-
'nbdev.config': { 'nbdev.config._apply_defaults': ('api/config.html#_apply_defaults', 'nbdev/config.py'),
31+
'nbdev.config': { 'nbdev.config.ConfigToml': ('api/config.html#configtoml', 'nbdev/config.py'),
32+
'nbdev.config.ConfigToml.__getattr__': ('api/config.html#configtoml.__getattr__', 'nbdev/config.py'),
33+
'nbdev.config.ConfigToml.__init__': ('api/config.html#configtoml.__init__', 'nbdev/config.py'),
34+
'nbdev.config.ConfigToml.get': ('api/config.html#configtoml.get', 'nbdev/config.py'),
3235
'nbdev.config._basic_export_nb': ('api/config.html#_basic_export_nb', 'nbdev/config.py'),
33-
'nbdev.config._cfg2txt': ('api/config.html#_cfg2txt', 'nbdev/config.py'),
3436
'nbdev.config._fetch_from_git': ('api/config.html#_fetch_from_git', 'nbdev/config.py'),
37+
'nbdev.config._find_nbdev_pyproject': ('api/config.html#_find_nbdev_pyproject', 'nbdev/config.py'),
3538
'nbdev.config._get_info': ('api/config.html#_get_info', 'nbdev/config.py'),
3639
'nbdev.config._git_repo': ('api/config.html#_git_repo', 'nbdev/config.py'),
40+
'nbdev.config._has_nbdev': ('api/config.html#_has_nbdev', 'nbdev/config.py'),
3741
'nbdev.config._has_py': ('api/config.html#_has_py', 'nbdev/config.py'),
38-
'nbdev.config._nbdev_config_file': ('api/config.html#_nbdev_config_file', 'nbdev/config.py'),
39-
'nbdev.config._prompt_user': ('api/config.html#_prompt_user', 'nbdev/config.py'),
40-
'nbdev.config._type': ('api/config.html#_type', 'nbdev/config.py'),
41-
'nbdev.config._xdg_config_paths': ('api/config.html#_xdg_config_paths', 'nbdev/config.py'),
42+
'nbdev.config._load_toml': ('api/config.html#_load_toml', 'nbdev/config.py'),
43+
'nbdev.config._user_config': ('api/config.html#_user_config', 'nbdev/config.py'),
4244
'nbdev.config.add_init': ('api/config.html#add_init', 'nbdev/config.py'),
43-
'nbdev.config.config_key': ('api/config.html#config_key', 'nbdev/config.py'),
45+
'nbdev.config.bump_version': ('api/config.html#bump_version', 'nbdev/config.py'),
4446
'nbdev.config.create_output': ('api/config.html#create_output', 'nbdev/config.py'),
4547
'nbdev.config.get_config': ('api/config.html#get_config', 'nbdev/config.py'),
4648
'nbdev.config.is_nbdev': ('api/config.html#is_nbdev', 'nbdev/config.py'),
4749
'nbdev.config.nbdev_create_config': ('api/config.html#nbdev_create_config', 'nbdev/config.py'),
50+
'nbdev.config.read_version': ('api/config.html#read_version', 'nbdev/config.py'),
51+
'nbdev.config.set_version': ('api/config.html#set_version', 'nbdev/config.py'),
4852
'nbdev.config.show_src': ('api/config.html#show_src', 'nbdev/config.py'),
4953
'nbdev.config.update_proj': ('api/config.html#update_proj', 'nbdev/config.py'),
5054
'nbdev.config.update_version': ('api/config.html#update_version', 'nbdev/config.py'),
@@ -165,7 +169,8 @@
165169
'nbdev.migrate.fp_md_fm': ('api/migrate.html#fp_md_fm', 'nbdev/migrate.py'),
166170
'nbdev.migrate.migrate_md': ('api/migrate.html#migrate_md', 'nbdev/migrate.py'),
167171
'nbdev.migrate.migrate_nb': ('api/migrate.html#migrate_nb', 'nbdev/migrate.py'),
168-
'nbdev.migrate.nbdev_migrate': ('api/migrate.html#nbdev_migrate', 'nbdev/migrate.py')},
172+
'nbdev.migrate.nbdev_migrate': ('api/migrate.html#nbdev_migrate', 'nbdev/migrate.py'),
173+
'nbdev.migrate.nbdev_migrate_config': ('api/migrate.html#nbdev_migrate_config', 'nbdev/migrate.py')},
169174
'nbdev.process': { 'nbdev.process.NBProcessor': ('api/process.html#nbprocessor', 'nbdev/process.py'),
170175
'nbdev.process.NBProcessor.__init__': ('api/process.html#nbprocessor.__init__', 'nbdev/process.py'),
171176
'nbdev.process.NBProcessor._proc': ('api/process.html#nbprocessor._proc', 'nbdev/process.py'),
@@ -303,7 +308,6 @@
303308
'nbdev.release._run': ('api/release.html#_run', 'nbdev/release.py'),
304309
'nbdev.release._write_yaml': ('api/release.html#_write_yaml', 'nbdev/release.py'),
305310
'nbdev.release.anaconda_upload': ('api/release.html#anaconda_upload', 'nbdev/release.py'),
306-
'nbdev.release.bump_version': ('api/release.html#bump_version', 'nbdev/release.py'),
307311
'nbdev.release.changelog': ('api/release.html#changelog', 'nbdev/release.py'),
308312
'nbdev.release.chk_conda_rel': ('api/release.html#chk_conda_rel', 'nbdev/release.py'),
309313
'nbdev.release.conda_output_path': ('api/release.html#conda_output_path', 'nbdev/release.py'),

nbdev/clean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def process_write(warn_msg, proc_nb, f_in, f_out=None, disp=False):
125125
def _nbdev_clean(nb, path=None, clear_all=None):
126126
cfg = get_config(path=path)
127127
clear_all = clear_all or cfg.clear_all
128-
allowed_metadata_keys = cfg.get("allowed_metadata_keys").split()
129-
allowed_cell_metadata_keys = cfg.get("allowed_cell_metadata_keys").split()
128+
allowed_metadata_keys = cfg.get("allowed_metadata_keys") or []
129+
allowed_cell_metadata_keys = cfg.get("allowed_cell_metadata_keys") or []
130130
clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)
131131
if path: nbdev_trust.__wrapped__(path)
132132

nbdev/cli.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _render_nb(fn, cfg):
6565
"Render templated values like `{{lib_name}}` in notebook at `fn` from `cfg`"
6666
txt = fn.read_text()
6767
txt = txt.replace('from your_lib.core', f'from {cfg.lib_path}.core') # for compatibility with old templates
68-
for k,v in cfg.d.items(): txt = txt.replace('{{'+k+'}}', v)
68+
for k,v in cfg.items(): txt = txt.replace('{{'+k+'}}', str(v))
6969
fn.write_text(txt)
7070

7171
# %% ../nbs/api/13_cli.ipynb #dd385911-aa8f-44e7-8d46-7b8a20f3b010
@@ -87,10 +87,11 @@ def nbdev_new(**kwargs):
8787
from ghapi.core import GhApi
8888
nbdev_create_config.__wrapped__(**kwargs)
8989
cfg = get_config()
90-
_update_repo_meta(cfg)
90+
if (Path('.git')).exists(): _update_repo_meta(cfg)
91+
else: print(f"No git repo found. Run: gh repo create {cfg.user}/{cfg.repo} --public --source=.")
9192
path = Path()
9293

93-
_ORG_OR_USR,_REPOSITORY = 'answerdotai','nbdev-template'
94+
_ORG_OR_USR,_REPOSITORY = 'answerdotai','nbdev3-template'
9495
_TEMPLATE = f'{_ORG_OR_USR}/{_REPOSITORY}'
9596
template = kwargs.get('template', _TEMPLATE)
9697
try: org_or_usr, repo = template.split('/')
@@ -143,24 +144,23 @@ def nbdev_update_license(
143144
avail_lic = GhApi().licenses.get_all_commonly_used().map(lambda x: x['key'])
144145

145146
cfg = get_config()
146-
curr_lic = cfg['license']
147+
curr_lic = cfg.license
147148

148149
mapped = mapping.get(to, None)
149-
150150
if mapped not in avail_lic: raise ValueError(f"{to} is not an available license")
151151
body = GhApi().licenses.get(mapped)['body']
152152

153-
body = body.replace('[year], [fullname]', cfg['copyright'])
154-
body = body.replace('[year] [fullname]', cfg['copyright'])
155-
156-
content = open("settings.ini", "r").read()
157-
content = re.sub(r"^(license\s*=\s*).*?$", r"\1 " + to, content, flags=re.MULTILINE)
153+
copyright = f"{datetime.now().year}, {cfg.author}"
154+
body = body.replace('[year], [fullname]', copyright)
155+
body = body.replace('[year] [fullname]', copyright)
158156

159-
config = open("settings.ini", "w")
160-
config.write(content)
157+
# Update pyproject.toml
158+
pyproj = cfg.config_file
159+
content = pyproj.read_text()
160+
content = re.sub(r'^(license\s*=\s*\{text\s*=\s*").*?(")', rf'\g<1>{to}\2', content, flags=re.MULTILINE)
161+
pyproj.write_text(content)
161162

162-
lic = open('LICENSE', 'w')
163-
lic.write(body)
163+
Path('LICENSE').write_text(body)
164164
print(f"License updated from {curr_lic} to {to}")
165165

166166
# %% ../nbs/api/13_cli.ipynb #412b4cd2

0 commit comments

Comments
 (0)