|
524 | 524 | " contrib_file = tmp_doc_path / 'CONTRIBUTING.md'\n",
|
525 | 525 | " if contrib_file.exists():\n",
|
526 | 526 | " 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", |
528 | 528 | " 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)" |
533 | 531 | ]
|
534 | 532 | },
|
535 | 533 | {
|
|
542 | 540 | "#|export\n",
|
543 | 541 | "@call_parse\n",
|
544 | 542 | "def nbdev_contributing(\n",
|
545 |
| - " path:str=None, # Path to notebooks (defaults to nbs_path)\n", |
| 543 | + " path:str=None, # Path to notebooks\n", |
546 | 544 | " chk_time:bool=False # Only build if out-of-date\n",
|
547 | 545 | "):\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", |
552 | 547 | " cfg = get_config()\n",
|
553 | 548 | " 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", |
556 | 549 | " contrib_nb_name = cfg.get('contributing_nb', 'contributing.ipynb')\n",
|
557 | 550 | " 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", |
558 | 553 | " \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", |
571 | 555 | " cache = proc_nbs(path)\n",
|
572 |
| - " \n", |
573 |
| - " # Render a single .ipynb -> .md in GFM\n", |
574 | 556 | " _sprun(f'cd \"{cache}\" && quarto render \"{cache/contrib_nb_name}\" -o CONTRIBUTING.md -t gfm --no-execute')\n",
|
575 | 557 | " \n",
|
576 |
| - " # Copy the newly created CONTRIBUTING.md and _files folder back to the repo root\n", |
577 | 558 | " _save_cached_contributing(cache, cfg, contrib_nb_name)\n"
|
578 | 559 | ]
|
579 | 560 | },
|
|
0 commit comments