{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "c2ac41fe-6c3c-48c1-9531-490927859346", "metadata": {}, "outputs": [], "source": [ "from nbdev.showdoc import show_doc\n", "from fastcore.utils import patch\n", "from fastcore.meta import delegates" ] }, { "cell_type": "code", "execution_count": null, "id": "f67bf2b2-88cf-446b-9241-f1351b129739", "metadata": {}, "outputs": [], "source": [ "#|export\n", "class Foo:\n", " def __init__(self,\n", " a, # A thing\n", " b:int=None): # Another thing\n", " ..." ] }, { "cell_type": "code", "execution_count": null, "id": "1f970abb-dfd0-41f0-9610-7e8b8ecdd552", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "---\n", "\n", "### Foo\n", "\n", "> Foo (a, b:int=None)\n", "\n", "Initialize self. See help(type(self)) for accurate signature.\n", "\n", "| | **Type** | **Default** | **Details** |\n", "| -- | -------- | ----------- | ----------- |\n", "| a | | | A thing |\n", "| b | int | None | Another thing |" ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "show_doc(Foo)" ] }, { "cell_type": "code", "execution_count": null, "id": "49cdb1d8-579f-4d3a-a93e-e52a35430810", "metadata": {}, "outputs": [], "source": [ "#|export\n", "@patch\n", "def a_method(self:Foo, a:list,b:dict,c):\n", " \"This is a method\"\n", " ..." ] }, { "cell_type": "code", "execution_count": null, "id": "f8be1e1a", "metadata": {}, "outputs": [], "source": [ "#|export\n", "@delegates()\n", "class B(Foo):\n", " def __init__(self, c, d:str=\"a\", **kwargs): ..." ] }, { "cell_type": "code", "execution_count": null, "id": "87d056c5", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "---\n", "\n", "### B\n", "\n", "> B (c, d:str='a', b:int=None)\n", "\n", "Initialize self. See help(type(self)) for accurate signature." ], "text/plain": [ "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "show_doc(B)" ] }, { "cell_type": "code", "execution_count": null, "id": "e3c091c2", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }