{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Notebook generation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This module contains the scripts and API to auto-generate or update a documentation notebook skeleton from a fastai module (e.g. - fastai.*) or existing documentation file (e.g. - docs_src/*.ipynb). It is not expected you'd use this skeleton as your final docs - you should add markdown, examples, etc to it. The skeleton just has a minimal list of exported symbols.\n", "\n", "[`tools/build-docs`](https://github.com/fastai/fastai/blob/master/tools/build-docs) contains a command line tool that transforms a given module into a notebook skeleton. It's essentially a wrapper around [`gen_notebooks.update_notebooks`](/gen_doc.gen_notebooks.html#update_notebooks). For usage around the command line tool, please follow instructions at [`gen_doc_main#updating-notebooks`](/gen_doc_main.html#updating-notebooks).\n", "\n", "Alternatively, you can access the same functionality through the module API, documented below.\n", "\n", "**Important note:** The notebooks automatically generated or updated need to be trusted before you can see the results in the output cells. To trust a notebook, click on File, then Trust notebook.\n", "\n", "This module also contains the scripts and API to convert the documentation notebooks into HTML, which is the format used for the final documentation site." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai import gen_doc\n", "from fastai.gen_doc import nbdoc\n", "from fastai.gen_doc.nbdoc import *\n", "from fastai.gen_doc.gen_notebooks import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Installation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This package requires:\n", "- [nbconvert](https://github.com/jupyter/nbconvert): conda install nbconvert\n", "- [nb_extensions](https://github.com/ipython-contrib/jupyter_contrib_nbextensions): conda install -c conda-forge jupyter_contrib_nbextensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once nbextensions is installed, your home page of Jupyter Notebook will look like this:\n", "\n", "![Homepage with nbextension](imgs/nbext.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Click on the Nbextensions tab then make sure the hide inputs extension is activated:\n", "\n", "![Activate hidden input](imgs/hide_input.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As its name suggests, this will allow you to hide input cells and only show their results.\n", "\n", "There is also the `Hide Input all` extension, but don't use it, since it toggles all inputs on/off and once executed it'll be very difficult to restore the notebook to its original state where some inputs are supposed to be hidden and some are not." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Convert modules into notebook skeleton" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The first (optional) step is to create a notebook \"skeleton\" - i.e. a notebook containing all the classes, methods, functions, and other symbols you wish to document. You can create this manually if you prefer, however using the automatic approach can save you some time and ensure you don't miss anything. \n", "\n", "For the initial skeleton, use [`create_module_page`](/gen_doc.gen_notebooks.html#create_module_page), which creates a new module from scratch. To update it later with any newly-added symbols, use [`update_module_page`](/gen_doc.gen_notebooks.html#update_module_page)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
create_module_page
[source][test]create_module_page
(**`mod`**, **`dest_path`**, **`force`**=***`False`***)\n",
"\n",
"No tests found for create_module_page
. To contribute a test please refer to this guide and this discussion.
link_nb
[source][test]link_nb
(**`nb_path`**)\n",
"\n",
"No tests found for link_nb
. To contribute a test please refer to this guide and this discussion.
update_module_page
[source][test]update_module_page
(**`mod`**, **`dest_path`**=***`'.'`***)\n",
"\n",
"No tests found for update_module_page
. To contribute a test please refer to this guide and this discussion.
generate_missing_metadata
[source][test]generate_missing_metadata
(**`dest_file`**)\n",
"\n",
"No tests found for generate_missing_metadata
. To contribute a test please refer to this guide and this discussion.
update_nb_metadata
[source][test]update_nb_metadata
(**`nb_path`**=***`None`***, **`title`**=***`None`***, **`summary`**=***`None`***, **`keywords`**=***`'fastai'`***, **`overwrite`**=***`True`***, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for update_nb_metadata
. To contribute a test please refer to this guide and this discussion.
update_notebooks
[source][test]update_notebooks
(**`source_path`**, **`dest_path`**=***`None`***, **`update_html`**=***`True`***, **`document_new_fns`**=***`False`***, **`update_nb_links`**=***`True`***, **`html_path`**=***`None`***, **`force`**=***`False`***)\n",
"\n",
"No tests found for update_notebooks
. To contribute a test please refer to this guide and this discussion.