# Modular nbdev


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

While `nbdev-new` gets you started with everything you need to create a
delightful Python package, **you can also use each of nbdev’s components
listed below on their own**. You might find this useful if you’re
porting a large system over to nbdev, documenting an existing code base,
or if you’d like to customize the nbdev workflow for your own project.
Note that all of the commands below work without a `pyproject.toml` file
unless otherwise noted.

## Document existing code: [`show_doc`](https://nbdev.fast.ai/api/showdoc.html#show_doc)

nbdev allows you to document existing code, even code that is not
written in nbdev!
[`nbdev.showdoc.show_doc`](https://nbdev.fast.ai/api/showdoc.html#show_doc)
allows you to render beautiful API documentation in notebooks and on
Quarto sites. For example, you can render API documentation for
[`numpy.all`](https://numpy.org/doc/stable/reference/generated/numpy.all.html#numpy.all)
like this:

<div class="py-2 px-3 mb-4 border rounded shadow-sm" fig-align="center">

``` python
from nbdev.showdoc import show_doc
from numpy import all
show_doc(all)
```

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

### all

>  all (a, axis=None, out=None, keepdims=<no value>, where=<no value>)

Test whether all array elements along a given axis evaluate to True.

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>array_like</td>
<td></td>
<td>Input array or object that can be converted to an array.</td>
</tr>
<tr>
<td>axis</td>
<td>NoneType</td>
<td>None</td>
<td>Axis or axes along which a logical AND reduction is
performed.<br>The default (<code>axis=None</code>) is to perform a
logical AND over all<br>the dimensions of the input array.
<code>axis</code> may be negative, in<br>which case it counts from the
last to the first axis.<br><br>.. versionadded:: 1.7.0<br><br>If this is
a tuple of ints, a reduction is performed on multiple<br>axes, instead
of a single axis or all the axes as before.</td>
</tr>
<tr>
<td>out</td>
<td>NoneType</td>
<td>None</td>
<td>Alternate output array in which to place the result.<br>It must have
the same shape as the expected output and its<br>type is preserved
(e.g., if <code>dtype(out)</code> is float, the result<br>will consist
of 0.0’s and 1.0’s). See :ref:<code>ufuncs-output-type</code> for
more<br>details.</td>
</tr>
<tr>
<td>keepdims</td>
<td>_NoValueType</td>
<td><no value></td>
<td>If this is set to True, the axes which are reduced are left<br>in
the result as dimensions with size one. With this option,<br>the result
will broadcast correctly against the input array.<br><br>If the default
value is passed, then <code>keepdims</code> will not be<br>passed
through to the <code>all</code> method of sub-classes
of<br><code>ndarray</code>, however any non-default value will be. If
the<br>sub-class’ method does not implement <code>keepdims</code>
any<br>exceptions will be raised.</td>
</tr>
<tr>
<td>where</td>
<td>_NoValueType</td>
<td><no value></td>
<td>Elements to include in checking for all <code>True</code>
values.<br>See <code>~numpy.ufunc.reduce</code> for details.<br><br>..
versionadded:: 1.20.0</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>ndarray, bool</strong></td>
<td></td>
<td><strong>A new boolean or array is returned unless <code>out</code>
is specified,<br>in which case a reference to <code>out</code> is
returned.</strong></td>
</tr>
</tbody>
</table>

</div>

<div>

> **Note**
>
> [`show_doc`](https://nbdev.fast.ai/api/showdoc.html#show_doc)
> automatically parses docstrings that are written in the numpy style.
> For more information [read
> here](../api/showdoc.ipynb#numpy-docstrings).

</div>

## Testing notebooks: `nbdev-test`

Testing notebooks can be very useful outside of nbdev, especially if you
are documenting an existing code base and want to incorporate tests for
your docs. The `nbdev-test` CLI utility allows you to accomplish this:

You can test an individual notebook with the terminal command:

``` sh
nbdev-test --path notebook.ipynb
```

…or a folder of notebooks:

``` sh
nbdev-test --path tests/
```

## Export code to modules: [`nb_export`](https://nbdev.fast.ai/api/export.html#nb_export)

You can export a notebook to a module with the Python function:

``` python
nb_export('notebook.ipynb', 'pkg')
```

…provided the notebook specifies a `default_exp` directive at the top,
and `export` directives above each cell to be exported. We recommend
including this in a code cell at the bottom of your notebook for
convenience.

## Jupyter-git integration

Jupyter and Git don’t normally play well together, especially for things
like merge conflicts. We have outlined all of these problems, and our
solutions in [this blog
post](../blog/posts/2022-08-25-jupyter-git/index.qmd). You can install
our merge driver and hooks with the following command:

``` bash
nbdev-install-hooks
```

We describe what `nbdev-install-hooks` does in detail on [this
page](git_friendly_jupyter.ipynb).

You can also directly use any of its underlying commands, for example,
to implement your own hooks or extensions:

- `nbdev-clean`
- `nbdev-fix`
- `nbdev-merge`
- `nbdev-trust`

To configure your own hooks, Check out the [pre-commit hooks
tutorial](../tutorials/pre_commit.ipynb).

## Python packaging

`nbdev.release`provides utlities for easy packaging on PyPI, conda, and
GitHub. Check out the [`nbdev.release`](../api/release.html) docs for
more information. Note that this functionality requires a
`pyproject.toml` with `[tool.nbdev]`.
