Skip to content

Commit

Permalink
Combine show_doc and remove alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac-Flath committed Oct 20, 2024
1 parent 052786f commit 2d8ccc0
Showing 1 changed file with 35 additions and 54 deletions.
89 changes: 35 additions & 54 deletions nbs/tutorials/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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()))"
]
},
{
Expand Down Expand Up @@ -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,
Expand All @@ -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": [
Expand All @@ -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",
"```"
]
},
{
Expand Down

0 comments on commit 2d8ccc0

Please sign in to comment.