install_quarto
def install_quarto():Install latest Quarto on macOS or Linux, prints instructions for Windows
Helpful background on how Quarto fits in here: https://nbdev.fast.ai/explanations/docs.html
Install latest Quarto on macOS or Linux, prints instructions for Windows
def IndentDumper(
stream, default_style:NoneType=None, default_flow_style:bool=False, canonical:NoneType=None,
indent:NoneType=None, width:NoneType=None, allow_unicode:NoneType=None, line_break:NoneType=None,
encoding:NoneType=None, explicit_start:NoneType=None, explicit_end:NoneType=None, version:NoneType=None,
tags:NoneType=None, sort_keys:bool=True
):Create sidebar.yml
def nbdev_proc_nbs(
*, path:str='', # Path to notebooks
n_workers:int=4, # Number of workers
force:bool=False, # Ignore cache and build all
file_glob:str='', # Only process notebooks matching glob (other files are always included)
file_re:str='', # Only process notebooks matching regex (other files are always included)
symlinks:bool=False, # Follow symlinks?
folder_re:str=None, # Only enter folders matching regex
skip_file_glob:str=None, # Skip files matching glob
skip_file_re:str='^[_.]', # Skip files matching regex
skip_folder_re:str='^[_.]', # Skip folders matching regex
):Process notebooks in path for docs rendering
Create README.md from readme_nb (index.ipynb by default). Skips if the file doesn’t exist.
nbdev-readme calls “quarto render,” which is explained in the Quarto guide here.
Pandoc’s gfm writer hard-wraps prose at 72 columns by default; -M wrap:preserve keeps each paragraph’s line breaks exactly as authored in the notebook instead.
Only the readme notebook itself is processed (plus non-notebook assets like images), so building the README never executes code from the project’s other notebooks; and if the readme notebook doesn’t exist, the command just returns.
Create CONTRIBUTING.md from contributing_nb (defaults to ‘contributing.ipynb’ if present). Skips if the file doesn’t exist.
Quarto’s quarto-nav.js rewrites /index.html links to / for clean URLs, but the regex is unanchored, so on a site’s index page it also mangles the “Other Formats” CommonMark link: index.html.md becomes .md (quarto-dev/quarto-cli#14667). _fix_quarto_nav anchors the regex in the rendered site’s copy of the script. Once quarto fixes it upstream, the pattern no longer matches and this becomes a no-op.
with tempfile.TemporaryDirectory() as d:
nav = Path(d)/'site_libs/quarto-nav/quarto-nav.js'
nav.parent.mkdir(parents=True)
nav.write_text(r'x.replace(/\/index\.html/, "/");')
_fix_quarto_nav(d)
test_eq(nav.read_text(), r'x.replace(/\/index\.html(?=[?#]|$)/, "/");')
_fix_quarto_nav(d) # idempotent, and a no-op once quarto fixes the regex upstream
test_eq(nav.read_text(), r'x.replace(/\/index\.html(?=[?#]|$)/, "/");')Create Quarto docs and README.md
File system watchdog dispatching to func
Preview docs locally