{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Documentation notebook functions" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[`nbdoc`](/gen_doc.nbdoc.html#gen_doc.nbdoc) contains the functions for documentation notebooks. The most important is [`show_doc`](/gen_doc.nbdoc.html#show_doc):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show the documentation of a function" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

show_doc[source]

\n", "\n", "> show_doc(`elt`, `doc_string`:`bool`=`True`, `full_name`:`str`=`None`, `arg_comments`:`dict`=`None`, `title_level`=`None`, `alt_doc_string`:`str`=`''`, `ignore_warn`:`bool`=`False`, `markdown`=`True`)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(show_doc, doc_string=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Show the documentation of an `elt` (function, class or enum). `doc_string` decices if we show the doc string of the element or not, `full_name` will override the name shown, `arg_comments` is a dictionary that will then show list the arguments with comments. `title_level` is the level of the corresponding cell in the TOC, `alt_doc_string` is a text that can replace the `doc_string`. `ignore_warn` will ignore warnings if you pass arguments in `arg_comments` that don't appear to belong to this function and `markdown` decides if the return is a Markdown cell or plain text.\n", "\n", "Plenty of examples of uses of this cell can been seen through the documentation, and you will want to *hide input* those cells for a clean final result." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Convenience functions" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

get_source_link[source]

\n", "\n", "> get_source_link(`mod`, `lineno`, `display_text`=`'[source]'`) → `str`\n", "\n", "Returns link to `lineno` in source code of `mod`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(get_source_link)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

show_video[source]

\n", "\n", "> show_video(`url`)\n", "\n", "Display video in `url`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(show_video)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

show_video_from_youtube[source]

\n", "\n", "> show_video_from_youtube(`code`, `start`=`0`)\n", "\n", "Display video from Youtube with a `code` and a `start` time. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(show_video_from_youtube)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Functions for internal fastai library use" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

get_exports[source]

\n", "\n", "> get_exports(`mod`)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(get_exports)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the exports of `mod`." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

get_fn_link[source]

\n", "\n", "> get_fn_link(`ft`) → `str`\n", "\n", "Return function link to notebook documentation of `ft`. Private functions link to source code " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(get_fn_link)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

get_ft_names[source]

\n", "\n", "> get_ft_names(`mod`, `include_inner`=`False`) → `List`\\[`str`\\]\n", "\n", "Return all the functions of module `mod`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(get_ft_names)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

is_enum[source]

\n", "\n", "> is_enum()" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(is_enum)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Check if something is an enumerator." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

import_mod[source]

\n", "\n", "> import_mod(`mod_name`:`str`, `ignore_errors`=`False`)\n", "\n", "Return module from `mod_name`. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(import_mod)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "\n", "\n", "> link_docstring(`modules`, `docstring`:`str`, `overwrite`:`bool`=`False`) → `str`\n", "\n", "Search `docstring` for backticks and attempt to link those functions to respective documentation. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(link_docstring)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Undocumented Methods - Methods moved below this line will intentionally be hidden" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## New Methods - Please document or move to the undocumented section" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

jekyll_important[source]

\n", "\n", "> jekyll_important(`s`)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(jekyll_important)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

jekyll_warn[source]

\n", "\n", "> jekyll_warn(`s`)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(jekyll_warn)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

jekyll_note[source]

\n", "\n", "> jekyll_note(`s`)" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(jekyll_note)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "

doc[source]

\n", "\n", "> doc(`elt`)\n", "\n", "Show [`show_doc`](/gen_doc.nbdoc.html#show_doc) info in preview window along with link to full docs. " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "show_doc(doc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] } ], "metadata": { "jekyll": { "keywords": "fastai", "summary": "Helper function to build the documentation", "title": "gen_doc.nbdoc" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 2 }