# quarto


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Helpful background on how Quarto fits in here:
<https://nbdev.fast.ai/explanations/docs.html>

## Install

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L48"
target="_blank" style="float:right; font-size:smaller">source</a>

### install_quarto

``` python
def install_quarto():
```

*Install latest Quarto on macOS or Linux, prints instructions for
Windows*

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L63"
target="_blank" style="float:right; font-size:smaller">source</a>

### install

``` python
def install():
```

*Install Quarto and the current library*

## Sidebar

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L105"
target="_blank" style="float:right; font-size:smaller">source</a>

### IndentDumper

``` python
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
):
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L112"
target="_blank" style="float:right; font-size:smaller">source</a>

### nbdev_sidebar

``` python
def nbdev_sidebar(
    path:str=None, # Path to notebooks
    printit:bool=False, # Print YAML for debugging
    force:bool=False, # Create sidebar even if custom_sidebar=false in pyproject.toml
    skip_folder_re:str='(?:^[_.]|^www\\$)', # Skip folders matching regex
    *, file_glob:str=None, # Only include files matching glob
    file_re:str='\\.(?:ipynb|qmd|html)$', # Only include files matching regex
    symlinks:bool=False, # Follow symlinks?
    path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)
    path_re:str=None, # Only include files whose full paths match regex
    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
):
```

*Create sidebar.yml*

``` python
# nbdev_sidebar(printit=True, force=True)
```

## Render docs

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L186"
target="_blank" style="float:right; font-size:smaller">source</a>

### refresh_quarto_yml

``` python
def refresh_quarto_yml():
```

*Generate `_quarto.yml` from `pyproject.toml`.*

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L228"
target="_blank" style="float:right; font-size:smaller">source</a>

### nbdev_proc_nbs

``` python
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?
    path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)
    path_re:str=None, # Only include files whose full paths match regex
    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*

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L276"
target="_blank" style="float:right; font-size:smaller">source</a>

### nbdev_readme

``` python
def nbdev_readme(
    path:str=None, # Path to notebooks (or project root)
    chk_time:bool=False, # Only build if out of date
):
```

*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](https://quarto.org/docs/projects/code-execution.html).

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.

Relative `.ipynb`, `.qmd`, `.html`, and `.txt` links point to the hosted
docs using `[project.urls].Documentation` when configured; notebook and
Quarto source links become `.html`. Other links, images, and code
examples are unchanged.

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.

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L312"
target="_blank" style="float:right; font-size:smaller">source</a>

### nbdev_contributing

``` python
def nbdev_contributing(
    path:str=None, # Path to notebooks
    chk_time:bool=False, # Only build if out-of-date
):
```

*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](https://github.com/quarto-dev/quarto-cli/issues/14667)).
[`_fix_quarto_nav`](https://nbdev.fast.ai/api/quarto.html#_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.

``` python
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(?=[?#]|$)/, "/");')
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L339"
target="_blank" style="float:right; font-size:smaller">source</a>

### nbdev_docs

``` python
def nbdev_docs(
    path:str=None, # Path to notebooks
    n_workers:int=4, # Preprocessing and Quarto workers (0 or 1: serial)
    *, file_glob:str=None, # Only include files matching glob
    file_re:str='\\.(?:ipynb|qmd|html)$', # Only include files matching regex
    symlinks:bool=False, # Follow symlinks?
    path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)
    path_re:str=None, # Only include files whose full paths match regex
    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
):
```

*Create Quarto docs*

`nbdev-docs` renders website pages in parallel. `--n-workers` defaults
to the CPU count; use `--n-workers 1` for serial rendering. Each worker
renders a batch in its own project copy. The combined site retains page
assets, navigation, search and sitemap entries. Books, Quarto-generated
`llms.txt`, and projects with pre/post-render hooks use a single Quarto
process.

The renderer lives in the hand-written `nbdev/quarto_render.py`. Its
integration test uses real Quarto to compare serial and parallel sites
and check incremental updates.

`nbdev-docs` builds only the website. It never regenerates README.md or
CONTRIBUTING.md. Rendering the readme notebook again, as GitHub
Markdown, would leave the site’s homepage without its HTML figures.
`nbdev-prepare`, `nbdev-readme` and `nbdev-contributing` regenerate
those files.

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L352"
target="_blank" style="float:right; font-size:smaller">source</a>

### prepare

``` python
def prepare():
```

*Export, test, and clean notebooks, and render README if needed*

## Preview

`nbdev-preview` keeps its own copy of the site in the `_proc` cache,
rendering new or changed pages on startup and as you edit; it doesn’t
change `doc_path`. When the cache has no site it starts from a copy of
the one in `doc_path`, so unchanged pages from the last `nbdev-docs` run
aren’t rendered again. If any processed page has missing or older HTML
output, it rebuilds the site in parallel using the same `--n-workers`
setting as `nbdev-docs`, then starts Quarto’s usual preview and input
watching. Use `nbdev-preview --render` to rebuild everything, including
changes to shared configuration or filters.

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L364"
target="_blank" style="float:right; font-size:smaller">source</a>

### fs_watchdog

``` python
def fs_watchdog(
    func, path, recursive:bool=True
):
```

*File system watchdog dispatching to `func`*

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/nbdev/blob/main/nbdev/quarto.py#L381"
target="_blank" style="float:right; font-size:smaller">source</a>

### nbdev_preview

``` python
def nbdev_preview(
    path:str=None, # Path to notebooks
    port:int=None, # The port on which to run preview
    host:str=None, # The host on which to run preview
    no_browser:bool=False, # Do not open a browser
    render:bool=False, # Render all pages before previewing
    n_workers:int=4, # Preprocessing and Quarto workers (0 or 1: serial)
    *, file_glob:str=None, # Only include files matching glob
    file_re:str='\\.(?:ipynb|qmd|html)$', # Only include files matching regex
    symlinks:bool=False, # Follow symlinks?
    path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)
    path_re:str=None, # Only include files whose full paths match regex
    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
):
```

*Preview docs locally*

By default, nbdev-docs, nbdev-preview, and nbdev-sidebar discover
notebooks (.ipynb), Quarto documents (.qmd), and HTML pages (.html). Use
–file-glob to restrict that selection by filename pattern, or –file-re
by regular expression.
