From 2d8ccc08d99579d9902133c63302aeaa13aa88a9 Mon Sep 17 00:00:00 2001 From: Isaac Flath Date: Sat, 19 Oct 2024 20:26:16 -0400 Subject: [PATCH] Combine show_doc and remove alias --- nbs/tutorials/tutorial.ipynb | 89 ++++++++++++++---------------------- 1 file changed, 35 insertions(+), 54 deletions(-) diff --git a/nbs/tutorials/tutorial.ipynb b/nbs/tutorials/tutorial.ipynb index 7fa8431f..ceff5b87 100644 --- a/nbs/tutorials/tutorial.ipynb +++ b/nbs/tutorials/tutorial.ipynb @@ -9,8 +9,7 @@ "> A step-by-step guide to using nbdev\n", "\n", "- order: 1\n", - "- image: ../images/card.png\n", - "- aliases: [/tutorial.html]" + "- image: ../images/card.png" ] }, { @@ -874,13 +873,14 @@ } ], "source": [ + "#| echo: false\n", "#| output: asis\n", "def say_hello(to):\n", " \"Say hello to somebody\"\n", " return f'Hello {to}!'\n", "\n", - "# print(div(show_doc(say_hello)._repr_markdown_(),\n", - "# classes='py-2 px-3 mb-4 border rounded shadow-sm'.split()))" + "print(div(show_doc(say_hello)._repr_markdown_(),\n", + " classes='py-2 px-3 mb-4 border rounded shadow-sm'.split()))" ] }, { @@ -1108,22 +1108,6 @@ "This will automatically appear in the docs like this:" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#| export\n", - "class HelloSayer:\n", - " \"Say hello to `to` using `say_hello`\"\n", - " def __init__(self, to): self.to = to\n", - "\n", - " def say(self):\n", - " \"Do the saying\"\n", - " return say_hello(self.to)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -1150,38 +1134,9 @@ "*Say hello to `to` using `say_hello`*" ] }, - "execution_count": null, "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# show_doc(HelloSayer)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Document with show_doc" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "However, methods aren't automatically documented. To add method docs, use `show_doc`:\n", - "\n", - "```python\n", - "show_doc(HelloSayer.say)\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ + "output_type": "display_data" + }, { "data": { "text/markdown": [ @@ -1203,13 +1158,39 @@ "*Do the saying*" ] }, - "execution_count": null, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "# show_doc(HelloSayer.say)" + "class HelloSayer:\n", + " \"Say hello to `to` using `say_hello`\"\n", + " def __init__(self, to): self.to = to\n", + "\n", + " def say(self):\n", + " \"Do the saying\"\n", + " return say_hello(self.to)\n", + "display(show_doc(HelloSayer))\n", + "\n", + "display(show_doc(HelloSayer.say))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Document with show_doc" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "However, methods aren't automatically documented. To add method docs, use `show_doc`:\n", + "\n", + "```python\n", + "show_doc(HelloSayer.say)\n", + "```" ] }, {