{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": false }, "outputs": [], "source": [ "#hide\n", "#default_exp cli\n", "from nbdev.showdoc import show_doc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Command line functions\n", "\n", "> Console commands added by the nbdev library" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#export\n", "from nbdev.imports import *\n", "from nbdev.export import *\n", "from nbdev.sync import *\n", "from nbdev.merge import *\n", "from nbdev.export2html import *\n", "from nbdev.clean import *\n", "from nbdev.test import *\n", "from fastcore.script import *\n", "from ghapi.all import GhApi\n", "from urllib.error import HTTPError\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`nbdev` comes with the following commands. To use any of them, you must be in one of the subfolders of your project: they will search for the `settings.ini` recursively in the parent directory but need to access it to be able to work. Their names all begin with nbdev so you can easily get a list with tab completion.\n", "- `nbdev_build_docs` builds the documentation from the notebooks\n", "- `nbdev_build_lib` builds the library from the notebooks\n", "- `nbdev_bump_version` increments version in `settings.py` by one\n", "- `nbdev_clean_nbs` removes all superfluous metadata form the notebooks, to avoid merge conflicts\n", "- `nbdev_detach` exports cell attachments to `dest` and updates references\n", "- `nbdev_diff_nbs` gives you the diff between the notebooks and the exported library\n", "- `nbdev_fix_merge` will fix merge conflicts in a notebook file\n", "- `nbdev_install_git_hooks` installs the git hooks that use the last two command automatically on each commit/merge\n", "- `nbdev_nb2md` converts a notebook to a markdown file\n", "- `nbdev_new` creates a new nbdev project\n", "- `nbdev_read_nbs` reads all notebooks to make sure none are broken\n", "- `nbdev_test_nbs` runs tests in notebooks\n", "- `nbdev_trust_nbs` trusts all notebooks (so that the HTML content is shown)\n", "- `nbdev_update_lib` propagates any change in the library back to the notebooks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Navigating from notebooks to script and back" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "
nbdev_build_lib
[source]nbdev_build_lib
(**`fname`**:\"A notebook name or glob to convert\"=*`None`*, **`bare`**:\"Omit nbdev annotation comments (may break some functionality).\"=*`False`*)\n",
"\n",
"Export notebooks matching `fname` to python modules"
],
"text/plain": [
"nbdev_update_lib
[source]nbdev_update_lib
(**`fname`**:\"A python filename or glob to convert\"=*`None`*, **`silent`**:\"Don't print results\"=*`False`*)\n",
"\n",
"Propagates any change in the modules matching `fname` to the notebooks that created them"
],
"text/plain": [
"nbdev_diff_nbs
[source]nbdev_diff_nbs
()\n",
"\n",
"Prints the diff between an export of the library in notebooks and the actual modules"
],
"text/plain": [
"nbdev_test_nbs
[source]nbdev_test_nbs
(**`fname`**:\"A notebook name or glob to convert\"=*`None`*, **`flags`**:\"Space separated list of flags\"=*`None`*, **`n_workers`**:\"Number of workers to use\"=*`None`*, **`verbose`**:\"Print errors along the way\"=*`True`*, **`timing`**:\"Timing each notebook to see the ones are slow\"=*`False`*, **`pause`**:\"Pause time (in secs) between notebooks to avoid race conditions\"=*`0.5`*)\n",
"\n",
"Test in parallel the notebooks matching `fname`, passing along `flags`"
],
"text/plain": [
"nbdev_build_docs
[source]nbdev_build_docs
(**`fname`**:\"A notebook name or glob to convert\"=*`None`*, **`force_all`**:\"Rebuild even notebooks that haven't changed\"=*`False`*, **`mk_readme`**:\"Also convert the index notebook to README\"=*`True`*, **`n_workers`**:\"Number of workers to use\"=*`None`*, **`pause`**:\"Pause time (in secs) between notebooks to avoid race conditions\"=*`0.5`*)\n",
"\n",
"Build the documentation by converting notebooks matching `fname` to html"
],
"text/plain": [
"nbdev_nb2md
[source]nbdev_nb2md
(**`fname`**:\"A notebook file name to convert\", **`dest`**:\"The destination folder\"=*`'.'`*, **`img_path`**:\"Folder to export images to\"=*`''`*, **`jekyll`**:\"To use jekyll metadata for your markdown file or not\"=*`False`*)\n",
"\n",
"Convert the notebook in `fname` to a markdown file"
],
"text/plain": [
"nbdev_detach
[source]nbdev_detach
(**`path_nb`**:\"Path to notebook\", **`dest`**:\"Destination folder\"=*`''`*, **`use_img`**:\"Convert markdown images to img tags\"=*`False`*, **`replace`**:\"Write replacement notebook back to `path_bn`\"=*`True`*)\n",
"\n",
"Export cell attachments to `dest` and update references"
],
"text/plain": [
"nbdev_read_nbs
[source]nbdev_read_nbs
(**`fname`**:\"A notebook name or glob to convert\"=*`None`*)\n",
"\n",
"Check all notebooks matching `fname` can be opened"
],
"text/plain": [
"nbdev_trust_nbs
[source]nbdev_trust_nbs
(**`fname`**:\"A notebook name or glob to convert\"=*`None`*, **`force_all`**:\"Trust even notebooks that haven't changed\"=*`False`*)\n",
"\n",
"Trust notebooks matching `fname`"
],
"text/plain": [
"nbdev_fix_merge
[source]nbdev_fix_merge
(**`fname`**:\"A notebook filename to fix\", **`fast`**:\"Fast fix: automatically fix the merge conflicts in outputs or metadata\"=*`True`*, **`trust_us`**:\"Use local outputs/metadata when fast merging\"=*`True`*)\n",
"\n",
"Fix merge conflicts in notebook `fname`"
],
"text/plain": [
"