Skip to content

Commit d6eddc2

Browse files
committed
Clean up, addressing PR suggestions
1 parent b6cf608 commit d6eddc2

File tree

3 files changed

+18
-104
lines changed

3 files changed

+18
-104
lines changed

nbdev/_modidx.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,13 @@
231231
'nbdev.qmd.meta': ('api/qmd.html#meta', 'nbdev/qmd.py'),
232232
'nbdev.qmd.tbl_row': ('api/qmd.html#tbl_row', 'nbdev/qmd.py'),
233233
'nbdev.qmd.tbl_sep': ('api/qmd.html#tbl_sep', 'nbdev/qmd.py')},
234-
'nbdev.quarto': { 'nbdev.quarto.SidebarYmlRemoved': ('api/quarto.html#sidebarymlremoved', 'nbdev/quarto.py'),
235-
'nbdev.quarto.SidebarYmlRemoved.__enter__': ( 'api/quarto.html#sidebarymlremoved.__enter__',
234+
'nbdev.quarto': { 'nbdev.quarto._SidebarYmlRemoved': ('api/quarto.html#_sidebarymlremoved', 'nbdev/quarto.py'),
235+
'nbdev.quarto._SidebarYmlRemoved.__enter__': ( 'api/quarto.html#_sidebarymlremoved.__enter__',
236+
'nbdev/quarto.py'),
237+
'nbdev.quarto._SidebarYmlRemoved.__exit__': ( 'api/quarto.html#_sidebarymlremoved.__exit__',
238+
'nbdev/quarto.py'),
239+
'nbdev.quarto._SidebarYmlRemoved.__init__': ( 'api/quarto.html#_sidebarymlremoved.__init__',
236240
'nbdev/quarto.py'),
237-
'nbdev.quarto.SidebarYmlRemoved.__exit__': ('api/quarto.html#sidebarymlremoved.__exit__', 'nbdev/quarto.py'),
238-
'nbdev.quarto.SidebarYmlRemoved.__init__': ('api/quarto.html#sidebarymlremoved.__init__', 'nbdev/quarto.py'),
239241
'nbdev.quarto._copytree': ('api/quarto.html#_copytree', 'nbdev/quarto.py'),
240242
'nbdev.quarto._ensure_quarto': ('api/quarto.html#_ensure_quarto', 'nbdev/quarto.py'),
241243
'nbdev.quarto._install_linux': ('api/quarto.html#_install_linux', 'nbdev/quarto.py'),

nbdev/quarto.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# %% auto 0
2020
__all__ = ['BASE_QUARTO_URL', 'install_quarto', 'install', 'nbdev_sidebar', 'refresh_quarto_yml', 'nbdev_proc_nbs',
21-
'SidebarYmlRemoved', 'nbdev_readme', 'nbdev_docs', 'prepare', 'fs_watchdog', 'nbdev_preview']
21+
'nbdev_readme', 'nbdev_docs', 'prepare', 'fs_watchdog', 'nbdev_preview']
2222

2323
# %% ../nbs/api/14_quarto.ipynb 5
2424
def _sprun(cmd):
@@ -189,7 +189,8 @@ def _readme_not_out_of_date(readme_path, readme_nb_path):
189189
return readme_path.exists() and readme_path.stat().st_mtime>=readme_nb_path.stat().st_mtime
190190

191191
# %% ../nbs/api/14_quarto.ipynb 22
192-
class SidebarYmlRemoved:
192+
class _SidebarYmlRemoved:
193+
"Context manager for `nbdev_readme` to avoid rendering whole docs website"
193194
def __init__(self,path): self._path=path
194195
def __enter__(self):
195196
self._yml_path = self._path/'sidebar.yml'
@@ -227,13 +228,13 @@ def nbdev_readme(
227228
path = Path(path) if path else cfg.nbs_path
228229
if chk_time and _readme_not_out_of_date(cfg.config_path/'README.md', path/cfg.readme_nb): return
229230

230-
with SidebarYmlRemoved(path): # to avoid rendering whole website
231+
with _SidebarYmlRemoved(path): # to avoid rendering whole website
231232
cache = proc_nbs(path)
232233
_sprun(f'cd "{cache}" && quarto render "{cache/cfg.readme_nb}" -o README.md -t gfm --no-execute')
233234

234235
_save_cached_readme(cache, cfg)
235236

236-
# %% ../nbs/api/14_quarto.ipynb 29
237+
# %% ../nbs/api/14_quarto.ipynb 28
237238
@call_parse
238239
@delegates(_nbglob_docs)
239240
def nbdev_docs(
@@ -247,7 +248,7 @@ def nbdev_docs(
247248
shutil.rmtree(cfg.doc_path, ignore_errors=True)
248249
move(cache/cfg.doc_path.name, cfg.config_path)
249250

250-
# %% ../nbs/api/14_quarto.ipynb 31
251+
# %% ../nbs/api/14_quarto.ipynb 30
251252
@call_parse
252253
def prepare():
253254
"Export, test, and clean notebooks, and render README if needed"
@@ -258,7 +259,7 @@ def prepare():
258259
refresh_quarto_yml()
259260
nbdev_readme.__wrapped__(chk_time=True)
260261

261-
# %% ../nbs/api/14_quarto.ipynb 33
262+
# %% ../nbs/api/14_quarto.ipynb 32
262263
@contextmanager
263264
def fs_watchdog(func, path, recursive:bool=True):
264265
"File system watchdog dispatching to `func`"
@@ -274,7 +275,7 @@ class _ProcessHandler(FileSystemEventHandler): dispatch=func
274275
observer.stop()
275276
observer.join()
276277

277-
# %% ../nbs/api/14_quarto.ipynb 34
278+
# %% ../nbs/api/14_quarto.ipynb 33
278279
@call_parse
279280
@delegates(_nbglob_docs)
280281
def nbdev_preview(

nbs/api/14_quarto.ipynb

Lines changed: 4 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@
382382
"source": [
383383
"#|hide\n",
384384
"#|export\n",
385-
"class SidebarYmlRemoved:\n",
385+
"class _SidebarYmlRemoved:\n",
386+
" \"Context manager for `nbdev_readme` to avoid rendering whole docs website\"\n",
386387
" def __init__(self,path): self._path=path\n",
387388
" def __enter__(self):\n",
388389
" self._yml_path = self._path/'sidebar.yml'\n",
@@ -444,7 +445,7 @@
444445
" path = Path(path) if path else cfg.nbs_path\n",
445446
" if chk_time and _readme_not_out_of_date(cfg.config_path/'README.md', path/cfg.readme_nb): return\n",
446447
"\n",
447-
" with SidebarYmlRemoved(path): # to avoid rendering whole website\n",
448+
" with _SidebarYmlRemoved(path): # to avoid rendering whole website\n",
448449
" cache = proc_nbs(path)\n",
449450
" _sprun(f'cd \"{cache}\" && quarto render \"{cache/cfg.readme_nb}\" -o README.md -t gfm --no-execute')\n",
450451
" \n",
@@ -459,102 +460,12 @@
459460
"`nbdev_readme` calls \"quarto render,\" which is explained in the Quarto guide [here](https://quarto.org/docs/projects/code-execution.html)."
460461
]
461462
},
462-
{
463-
"cell_type": "code",
464-
"execution_count": null,
465-
"id": "fe22d431",
466-
"metadata": {},
467-
"outputs": [
468-
{
469-
"name": "stdout",
470-
"output_type": "stream",
471-
"text": [
472-
"\r\n",
473-
" Usage: quarto render [input] [args...]\r\n",
474-
" Version: 1.2.269 \r\n",
475-
"\r\n",
476-
" Description:\r\n",
477-
"\r\n",
478-
" Render files or projects to various document types.\r\n",
479-
"\r\n",
480-
" Options:\r\n",
481-
"\r\n",
482-
" -h, --help - Show this help. \r\n",
483-
" -t, --to - Specify output format(s). \r\n",
484-
" -o, --output - Write output to FILE (use '--output -' for stdout). \r\n",
485-
" --output-dir - Write project output to DIR (path is project relative) \r\n",
486-
" -M, --metadata - Metadata value (KEY:VALUE). \r\n",
487-
" --site-url - Override site-url for website or book output \r\n",
488-
" --execute - Execute code (--no-execute to skip execution). \r\n",
489-
" -P, --execute-param - Execution parameter (KEY:VALUE). \r\n",
490-
" --execute-params - YAML file with execution parameters. \r\n",
491-
" --execute-dir - Working directory for code execution. \r\n",
492-
" --execute-daemon - Keep Jupyter kernel alive (defaults to 300 seconds). \r\n",
493-
" --execute-daemon-restart - Restart keepalive Jupyter kernel before render. \r\n",
494-
" --execute-debug - Show debug output for Jupyter kernel. \r\n",
495-
" --use-freezer - Force use of frozen computations for an incremental file render. \r\n",
496-
" --cache - Cache execution output (--no-cache to prevent cache). \r\n",
497-
" --cache-refresh - Force refresh of execution cache. \r\n",
498-
" --no-clean - Do not clean project output-dir prior to render \r\n",
499-
" --debug - Leave intermediate files in place after render. \r\n",
500-
" pandoc-args... - Additional pandoc command line arguments. \r\n",
501-
" --log <level> - Path to log file \r\n",
502-
" --log-level <level> - Log level (info, warning, error, critical) \r\n",
503-
" --log-format <format> - Log format (plain, json-stream) \r\n",
504-
" --quiet - Suppress console output. \r\n",
505-
" --profile - Active project profile(s) \r\n",
506-
"\r\n",
507-
" Commands:\r\n",
508-
"\r\n",
509-
" help [command] - Show this help or the help of a sub-command.\r\n",
510-
"\r\n",
511-
" Examples:\r\n",
512-
"\r\n",
513-
" Render Markdown: quarto render document.qmd \r\n",
514-
" quarto render document.qmd --to html \r\n",
515-
" quarto render document.qmd --to pdf --toc \r\n",
516-
" Render Notebook: quarto render notebook.ipynb \r\n",
517-
" quarto render notebook.ipynb --to docx \r\n",
518-
" quarto render notebook.ipynb --to pdf --toc \r\n",
519-
" Render Project: quarto render \r\n",
520-
" quarto render projdir \r\n",
521-
" Render w/ Metadata: quarto render document.qmd -M echo:false \r\n",
522-
" quarto render document.qmd -M code-fold:true\r\n",
523-
" Render to Stdout: quarto render document.qmd --output - \r\n",
524-
"\r\n"
525-
]
526-
}
527-
],
528-
"source": [
529-
"!quarto render --help"
530-
]
531-
},
532463
{
533464
"cell_type": "code",
534465
"execution_count": null,
535466
"id": "f1e1cf1b",
536467
"metadata": {},
537-
"outputs": [
538-
{
539-
"name": "stderr",
540-
"output_type": "stream",
541-
"text": [
542-
"\u001b[1mpandoc -o README.md\u001b[22m\n",
543-
" to: >-\n",
544-
" commonmark+autolink_bare_uris+emoji+footnotes+gfm_auto_identifiers+pipe_tables+strikeout+task_lists+tex_math_dollars\n",
545-
" output-file: getting_started.html\n",
546-
" standalone: true\n",
547-
" default-image-extension: png\n",
548-
" \n",
549-
"\u001b[1mmetadata\u001b[22m\n",
550-
" description: Create delightful software with Jupyter Notebooks\n",
551-
" title: Getting Started\n",
552-
" \n",
553-
"Output created: _docs/README.md\n",
554-
"\n"
555-
]
556-
}
557-
],
468+
"outputs": [],
558469
"source": [
559470
"#|hide\n",
560471
"# nbdev_readme.__wrapped__(chk_time=False)"

0 commit comments

Comments
 (0)