Skip to content

Commit 5531feb

Browse files
committed
update style
1 parent f90a71d commit 5531feb

File tree

2 files changed

+16
-54
lines changed

2 files changed

+16
-54
lines changed

nbdev/quarto.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -275,48 +275,29 @@ def _save_cached_contributing(cache, cfg, contrib_nb):
275275
contrib_file = tmp_doc_path / 'CONTRIBUTING.md'
276276
if contrib_file.exists():
277277
final_path = cfg.config_path / 'CONTRIBUTING.md'
278-
if final_path.exists(): final_path.unlink() # Py3.7 doesn't have missing_ok
278+
if final_path.exists(): final_path.unlink() # py37 doesn't have `missing_ok`
279279
move(contrib_file, final_path)
280-
# Move any supporting files folder
281-
assets_folder = tmp_doc_path / (Path(contrib_nb).stem + '_files')
282-
if assets_folder.exists():
283-
_copytree(assets_folder, cfg.config_path / assets_folder.name)
280+
assets_folder = tmp_doc_path / (Path(contrib_nb).stem + '_files') # Supporting files for CONTRIBUTING
281+
if assets_folder.exists(): _copytree(assets_folder, cfg.config_path / assets_folder.name)
284282

285283
# %% ../nbs/api/14_quarto.ipynb
286284
@call_parse
287285
def nbdev_contributing(
288-
path:str=None, # Path to notebooks (defaults to nbs_path)
286+
path:str=None, # Path to notebooks
289287
chk_time:bool=False # Only build if out-of-date
290288
):
291-
"""
292-
Create CONTRIBUTING.md from contributing_nb (defaults to 'contributing.ipynb' if present).
293-
Skips if the file doesn't exist.
294-
"""
289+
"""Create CONTRIBUTING.md from contributing_nb (defaults to 'contributing.ipynb' if present). Skips if the file doesn't exist."""
295290
cfg = get_config()
296291
path = Path(path) if path else cfg.nbs_path
297-
298-
# Decide which notebook is your "contributing" NB (you can hardcode or add to settings.ini)
299292
contrib_nb_name = cfg.get('contributing_nb', 'contributing.ipynb')
300293
contrib_nb_path = path / contrib_nb_name
294+
if not contrib_nb_path.exists(): return
295+
if chk_time and _doc_mtime_not_older(cfg.config_path / 'CONTRIBUTING.md' , contrib_nb_path): return
301296

302-
contrib_md = cfg.config_path / 'CONTRIBUTING.md'
303-
304-
# If out of date check is requested, skip if up-to-date or missing
305-
if chk_time and _doc_mtime_not_older(contrib_md, contrib_nb_path):
306-
return
307-
308-
# If there's no contributing notebook, do nothing
309-
if not contrib_nb_path.exists():
310-
return
311-
312-
# Temporarily remove sidebar.yml so Quarto doesn't try to build the entire site
313-
with _SidebarYmlRemoved(path):
297+
with _SidebarYmlRemoved(path): # to avoid rendering whole website
314298
cache = proc_nbs(path)
315-
316-
# Render a single .ipynb -> .md in GFM
317299
_sprun(f'cd "{cache}" && quarto render "{cache/contrib_nb_name}" -o CONTRIBUTING.md -t gfm --no-execute')
318300

319-
# Copy the newly created CONTRIBUTING.md and _files folder back to the repo root
320301
_save_cached_contributing(cache, cfg, contrib_nb_name)
321302

322303

nbs/api/14_quarto.ipynb

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,10 @@
524524
" contrib_file = tmp_doc_path / 'CONTRIBUTING.md'\n",
525525
" if contrib_file.exists():\n",
526526
" final_path = cfg.config_path / 'CONTRIBUTING.md'\n",
527-
" if final_path.exists(): final_path.unlink() # Py3.7 doesn't have missing_ok\n",
527+
" if final_path.exists(): final_path.unlink() # py37 doesn't have `missing_ok`\n",
528528
" move(contrib_file, final_path)\n",
529-
" # Move any supporting files folder\n",
530-
" assets_folder = tmp_doc_path / (Path(contrib_nb).stem + '_files')\n",
531-
" if assets_folder.exists():\n",
532-
" _copytree(assets_folder, cfg.config_path / assets_folder.name)"
529+
" assets_folder = tmp_doc_path / (Path(contrib_nb).stem + '_files') # Supporting files for CONTRIBUTING\n",
530+
" if assets_folder.exists(): _copytree(assets_folder, cfg.config_path / assets_folder.name)"
533531
]
534532
},
535533
{
@@ -542,38 +540,21 @@
542540
"#|export\n",
543541
"@call_parse\n",
544542
"def nbdev_contributing(\n",
545-
" path:str=None, # Path to notebooks (defaults to nbs_path)\n",
543+
" path:str=None, # Path to notebooks\n",
546544
" chk_time:bool=False # Only build if out-of-date\n",
547545
"):\n",
548-
" \"\"\"\n",
549-
" Create CONTRIBUTING.md from contributing_nb (defaults to 'contributing.ipynb' if present).\n",
550-
" Skips if the file doesn't exist.\n",
551-
" \"\"\"\n",
546+
" \"\"\"Create CONTRIBUTING.md from contributing_nb (defaults to 'contributing.ipynb' if present). Skips if the file doesn't exist.\"\"\"\n",
552547
" cfg = get_config()\n",
553548
" path = Path(path) if path else cfg.nbs_path\n",
554-
" \n",
555-
" # Decide which notebook is your \"contributing\" NB (you can hardcode or add to settings.ini)\n",
556549
" contrib_nb_name = cfg.get('contributing_nb', 'contributing.ipynb')\n",
557550
" contrib_nb_path = path / contrib_nb_name\n",
551+
" if not contrib_nb_path.exists(): return\n",
552+
" if chk_time and _doc_mtime_not_older(cfg.config_path / 'CONTRIBUTING.md' , contrib_nb_path): return\n",
558553
" \n",
559-
" contrib_md = cfg.config_path / 'CONTRIBUTING.md'\n",
560-
" \n",
561-
" # If out of date check is requested, skip if up-to-date or missing\n",
562-
" if chk_time and _doc_mtime_not_older(contrib_md, contrib_nb_path):\n",
563-
" return\n",
564-
" \n",
565-
" # If there's no contributing notebook, do nothing\n",
566-
" if not contrib_nb_path.exists():\n",
567-
" return\n",
568-
" \n",
569-
" # Temporarily remove sidebar.yml so Quarto doesn't try to build the entire site\n",
570-
" with _SidebarYmlRemoved(path):\n",
554+
" with _SidebarYmlRemoved(path): # to avoid rendering whole website\n",
571555
" cache = proc_nbs(path)\n",
572-
" \n",
573-
" # Render a single .ipynb -> .md in GFM\n",
574556
" _sprun(f'cd \"{cache}\" && quarto render \"{cache/contrib_nb_name}\" -o CONTRIBUTING.md -t gfm --no-execute')\n",
575557
" \n",
576-
" # Copy the newly created CONTRIBUTING.md and _files folder back to the repo root\n",
577558
" _save_cached_contributing(cache, cfg, contrib_nb_name)\n"
578559
]
579560
},

0 commit comments

Comments
 (0)