Skip to content

Commit efd44e4

Browse files
committed
fixes #1059
1 parent 9e559ad commit efd44e4

File tree

4 files changed

+53
-53
lines changed

4 files changed

+53
-53
lines changed

nbdev/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _apply_defaults(
6464
jupyter_hooks=True, # Run Jupyter hooks?
6565
clean_ids=True, # Remove ids from plaintext reprs?
6666
clear_all=False, # Remove all cell metadata and cell outputs?
67-
custom_quarto_yml=False, # Use a custom _quarto.yml?
6867
put_version_in_init=True, # Add the version to the main __init__.py in nbdev_export
6968
):
7069
"Apply default settings where missing in `cfg`."
@@ -144,8 +143,8 @@ def _cfg2txt(cfg, head, sections, tail=''):
144143
145144
'''
146145
_nbdev_cfg_sections = {'Python library': 'repo lib_name version min_python license',
147-
'nbdev': 'doc_path lib_path nbs_path recursive tst_flags',
148-
'Docs': 'branch custom_sidebar doc_host doc_baseurl git_url title custom_quarto_yml',
146+
'nbdev': 'doc_path lib_path nbs_path recursive tst_flags put_version_in_init',
147+
'Docs': 'branch custom_sidebar doc_host doc_baseurl git_url title',
149148
'PyPI': 'audience author author_email copyright description keywords language status user'}
150149
_nbdev_cfg_tail = '''### Optional ###
151150
# requirements = fastcore pandas

nbdev/quarto.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -128,53 +128,50 @@ def _ensure_quarto():
128128
# %% ../nbs/api/quarto.ipynb 14
129129
_quarto_yml="""project:
130130
type: website
131-
output-dir: {doc_path}
132-
preview:
133-
port: 3000
134-
browser: false
135131
136132
format:
137133
html:
138134
theme: cosmo
139135
css: styles.css
140136
toc: true
141-
toc-depth: 4
142137
143138
website:
144-
title: "{title}"
145-
site-url: "{doc_host}{doc_baseurl}"
146-
description: "{description}"
147139
twitter-card: true
148140
open-graph: true
149-
repo-branch: {branch}
150-
repo-url: "{git_url}"
151141
repo-actions: [issue]
152142
navbar:
153143
background: primary
154144
search: true
155-
right:
156-
- icon: github
157-
href: "{git_url}"
158145
sidebar:
159-
style: "floating"
146+
style: floating
160147
161-
metadata-files:
162-
- sidebar.yml
163-
- custom.yml
164-
"""
148+
metadata-files: [nbdev.yml, sidebar.yml]"""
165149

166150
# %% ../nbs/api/quarto.ipynb 15
151+
_nbdev_yml="""project:
152+
output-dir: {doc_path}
153+
154+
website:
155+
title: "{title}"
156+
site-url: "{doc_host}{doc_baseurl}"
157+
description: "{description}"
158+
repo-branch: {branch}
159+
repo-url: "{git_url}"
160+
"""
161+
162+
# %% ../nbs/api/quarto.ipynb 16
167163
def refresh_quarto_yml():
168164
"Generate `_quarto.yml` from `settings.ini`."
169165
cfg = get_config()
170-
if cfg.get('custom_quarto_yml', False): return
171-
p = cfg.nbs_path/'_quarto.yml'
166+
ny = cfg.nbs_path/'nbdev.yml'
172167
vals = {k:cfg[k] for k in ['title', 'description', 'branch', 'git_url', 'doc_host', 'doc_baseurl']}
173168
vals['doc_path'] = cfg.doc_path.name
174169
if 'title' not in vals: vals['title'] = vals['lib_name']
175-
p.write_text(_quarto_yml.format(**vals))
170+
ny.write_text(_nbdev_yml.format(**vals))
171+
qy = cfg.nbs_path/'_quarto.yml'
172+
if not qy.exists(): qy.write_text(_quarto_yml)
176173

177-
# %% ../nbs/api/quarto.ipynb 16
174+
# %% ../nbs/api/quarto.ipynb 17
178175
@call_parse
179176
def nbdev_readme(
180177
path:str=None, # Path to notebooks
@@ -208,7 +205,7 @@ def nbdev_readme(
208205
move(readme, cfg_path)
209206
if _rdmi.exists(): copytree(_rdmi, cfg_path/_rdmi.name) # Move Supporting files for README
210207

211-
# %% ../nbs/api/quarto.ipynb 18
208+
# %% ../nbs/api/quarto.ipynb 19
212209
@call_parse
213210
@delegates(_nbglob_docs)
214211
def nbdev_docs(
@@ -222,7 +219,7 @@ def nbdev_docs(
222219
shutil.rmtree(cfg.doc_path, ignore_errors=True)
223220
move(cache/cfg.doc_path.name, cfg.config_path)
224221

225-
# %% ../nbs/api/quarto.ipynb 20
222+
# %% ../nbs/api/quarto.ipynb 21
226223
@call_parse
227224
@delegates(nbdev_docs)
228225
def deploy(
@@ -235,7 +232,7 @@ def deploy(
235232
except: return warnings.warn('Please install ghp-import with `pip install ghp-import`')
236233
ghp_import(get_config().doc_path, push=True, stderr=True, no_history=True)
237234

238-
# %% ../nbs/api/quarto.ipynb 21
235+
# %% ../nbs/api/quarto.ipynb 22
239236
@call_parse
240237
def prepare():
241238
"Export, test, and clean notebooks, and render README if needed"
@@ -246,7 +243,7 @@ def prepare():
246243
refresh_quarto_yml()
247244
nbdev_readme.__wrapped__(chk_time=True)
248245

249-
# %% ../nbs/api/quarto.ipynb 23
246+
# %% ../nbs/api/quarto.ipynb 24
250247
@contextmanager
251248
def fs_watchdog(func, path, recursive:bool=True):
252249
"File system watchdog dispatching to `func`"
@@ -262,7 +259,7 @@ class _ProcessHandler(FileSystemEventHandler): dispatch=func
262259
observer.stop()
263260
observer.join()
264261

265-
# %% ../nbs/api/quarto.ipynb 24
262+
# %% ../nbs/api/quarto.ipynb 25
266263
@call_parse
267264
@delegates(_nbglob_docs)
268265
def nbdev_preview(

nbs/api/config.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
" jupyter_hooks=True, # Run Jupyter hooks?\n",
173173
" clean_ids=True, # Remove ids from plaintext reprs?\n",
174174
" clear_all=False, # Remove all cell metadata and cell outputs?\n",
175-
" custom_quarto_yml=False, # Use a custom _quarto.yml?\n",
176175
" put_version_in_init=True, # Add the version to the main __init__.py in nbdev_export\n",
177176
"):\n",
178177
" \"Apply default settings where missing in `cfg`.\"\n",
@@ -346,8 +345,8 @@
346345
"\n",
347346
"'''\n",
348347
"_nbdev_cfg_sections = {'Python library': 'repo lib_name version min_python license',\n",
349-
" 'nbdev': 'doc_path lib_path nbs_path recursive tst_flags',\n",
350-
" 'Docs': 'branch custom_sidebar doc_host doc_baseurl git_url title custom_quarto_yml',\n",
348+
" 'nbdev': 'doc_path lib_path nbs_path recursive tst_flags put_version_in_init',\n",
349+
" 'Docs': 'branch custom_sidebar doc_host doc_baseurl git_url title',\n",
351350
" 'PyPI': 'audience author author_email copyright description keywords language status user'}\n",
352351
"_nbdev_cfg_tail = '''### Optional ###\n",
353352
"# requirements = fastcore pandas\n",

nbs/api/quarto.ipynb

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -253,39 +253,43 @@
253253
"#|export\n",
254254
"_quarto_yml=\"\"\"project:\n",
255255
" type: website\n",
256-
" output-dir: {doc_path}\n",
257-
" preview:\n",
258-
" port: 3000\n",
259-
" browser: false\n",
260256
"\n",
261257
"format:\n",
262258
" html:\n",
263259
" theme: cosmo\n",
264260
" css: styles.css\n",
265261
" toc: true\n",
266-
" toc-depth: 4\n",
267262
"\n",
268263
"website:\n",
269-
" title: \"{title}\"\n",
270-
" site-url: \"{doc_host}{doc_baseurl}\"\n",
271-
" description: \"{description}\"\n",
272264
" twitter-card: true\n",
273265
" open-graph: true\n",
274-
" repo-branch: {branch}\n",
275-
" repo-url: \"{git_url}\"\n",
276266
" repo-actions: [issue]\n",
277267
" navbar:\n",
278268
" background: primary\n",
279269
" search: true\n",
280-
" right:\n",
281-
" - icon: github\n",
282-
" href: \"{git_url}\"\n",
283270
" sidebar:\n",
284-
" style: \"floating\"\n",
271+
" style: floating\n",
285272
"\n",
286-
"metadata-files: \n",
287-
" - sidebar.yml\n",
288-
" - custom.yml\n",
273+
"metadata-files: [nbdev.yml, sidebar.yml]\"\"\""
274+
]
275+
},
276+
{
277+
"cell_type": "code",
278+
"execution_count": null,
279+
"id": "faabf6e6",
280+
"metadata": {},
281+
"outputs": [],
282+
"source": [
283+
"#|export\n",
284+
"_nbdev_yml=\"\"\"project:\n",
285+
" output-dir: {doc_path}\n",
286+
"\n",
287+
"website:\n",
288+
" title: \"{title}\"\n",
289+
" site-url: \"{doc_host}{doc_baseurl}\"\n",
290+
" description: \"{description}\"\n",
291+
" repo-branch: {branch}\n",
292+
" repo-url: \"{git_url}\"\n",
289293
"\"\"\""
290294
]
291295
},
@@ -300,12 +304,13 @@
300304
"def refresh_quarto_yml():\n",
301305
" \"Generate `_quarto.yml` from `settings.ini`.\"\n",
302306
" cfg = get_config()\n",
303-
" if cfg.get('custom_quarto_yml', False): return\n",
304-
" p = cfg.nbs_path/'_quarto.yml'\n",
307+
" ny = cfg.nbs_path/'nbdev.yml'\n",
305308
" vals = {k:cfg[k] for k in ['title', 'description', 'branch', 'git_url', 'doc_host', 'doc_baseurl']}\n",
306309
" vals['doc_path'] = cfg.doc_path.name\n",
307310
" if 'title' not in vals: vals['title'] = vals['lib_name']\n",
308-
" p.write_text(_quarto_yml.format(**vals))"
311+
" ny.write_text(_nbdev_yml.format(**vals))\n",
312+
" qy = cfg.nbs_path/'_quarto.yml'\n",
313+
" if not qy.exists(): qy.write_text(_quarto_yml)"
309314
]
310315
},
311316
{

0 commit comments

Comments
 (0)