Skip to content

Commit 009cde4

Browse files
committed
showdoc tests
1 parent 5b4522d commit 009cde4

File tree

3 files changed

+107
-59
lines changed

3 files changed

+107
-59
lines changed

nbs/09_processors.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@
859859
"metadata": {},
860860
"outputs": [],
861861
"source": [
862-
"#|eval: false\n",
863862
"#|hide\n",
864863
"from nbdev.doclinks import nbdev_export\n",
865864
"nbdev_export()"

nbs/10_cli.ipynb

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "510ed03d-0c3b-4caf-910d-e6eaec08fd63",
77
"metadata": {},
88
"outputs": [],
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 2,
15+
"execution_count": null,
1616
"id": "6a35c7c4-748f-4c82-a9bf-c780a8d83e90",
1717
"metadata": {},
1818
"outputs": [],
@@ -39,7 +39,7 @@
3939
},
4040
{
4141
"cell_type": "code",
42-
"execution_count": 3,
42+
"execution_count": null,
4343
"id": "1e623a3d-3e77-44c6-adf3-4768b78328c5",
4444
"metadata": {},
4545
"outputs": [],
@@ -59,7 +59,7 @@
5959
},
6060
{
6161
"cell_type": "code",
62-
"execution_count": 4,
62+
"execution_count": null,
6363
"id": "03fabbba",
6464
"metadata": {},
6565
"outputs": [],
@@ -85,7 +85,7 @@
8585
},
8686
{
8787
"cell_type": "code",
88-
"execution_count": 5,
88+
"execution_count": null,
8989
"id": "8abd3b62",
9090
"metadata": {},
9191
"outputs": [],
@@ -138,7 +138,7 @@
138138
},
139139
{
140140
"cell_type": "code",
141-
"execution_count": 6,
141+
"execution_count": null,
142142
"id": "7b04052d",
143143
"metadata": {},
144144
"outputs": [],
@@ -156,7 +156,7 @@
156156
},
157157
{
158158
"cell_type": "code",
159-
"execution_count": 7,
159+
"execution_count": null,
160160
"id": "c3b89ff6",
161161
"metadata": {},
162162
"outputs": [],
@@ -193,7 +193,7 @@
193193
},
194194
{
195195
"cell_type": "code",
196-
"execution_count": 8,
196+
"execution_count": null,
197197
"id": "86c29369",
198198
"metadata": {},
199199
"outputs": [],
@@ -223,7 +223,7 @@
223223
},
224224
{
225225
"cell_type": "code",
226-
"execution_count": 9,
226+
"execution_count": null,
227227
"id": "fe4dc8bf",
228228
"metadata": {},
229229
"outputs": [],
@@ -242,7 +242,7 @@
242242
},
243243
{
244244
"cell_type": "code",
245-
"execution_count": 10,
245+
"execution_count": null,
246246
"id": "b505ba72",
247247
"metadata": {},
248248
"outputs": [],
@@ -291,7 +291,7 @@
291291
},
292292
{
293293
"cell_type": "code",
294-
"execution_count": 11,
294+
"execution_count": null,
295295
"id": "a1c001af-2c7c-4e0b-8c7d-a7d40c08f5e9",
296296
"metadata": {},
297297
"outputs": [],
@@ -304,7 +304,7 @@
304304
},
305305
{
306306
"cell_type": "code",
307-
"execution_count": 12,
307+
"execution_count": null,
308308
"id": "d21b9697-8d1b-4d11-b2ea-83c20ac82e10",
309309
"metadata": {},
310310
"outputs": [],
@@ -335,7 +335,7 @@
335335
},
336336
{
337337
"cell_type": "code",
338-
"execution_count": 13,
338+
"execution_count": null,
339339
"id": "8d1125db-977a-4119-85e4-6e3586064ed0",
340340
"metadata": {},
341341
"outputs": [],
@@ -350,7 +350,7 @@
350350
},
351351
{
352352
"cell_type": "code",
353-
"execution_count": 14,
353+
"execution_count": null,
354354
"id": "b0720122-8fef-4999-8572-31ffc222d32f",
355355
"metadata": {},
356356
"outputs": [],
@@ -371,7 +371,7 @@
371371
},
372372
{
373373
"cell_type": "code",
374-
"execution_count": 15,
374+
"execution_count": null,
375375
"id": "fafdcb43-c0c6-4709-9c03-057ea55cc45e",
376376
"metadata": {},
377377
"outputs": [],
@@ -394,7 +394,7 @@
394394
},
395395
{
396396
"cell_type": "code",
397-
"execution_count": 16,
397+
"execution_count": null,
398398
"id": "f894cfa3-fff2-4d0a-886d-150a86649d25",
399399
"metadata": {},
400400
"outputs": [],
@@ -405,7 +405,7 @@
405405
},
406406
{
407407
"cell_type": "code",
408-
"execution_count": 17,
408+
"execution_count": null,
409409
"id": "f3cd72a9-0ae4-45f9-884a-aa8f6d71fb33",
410410
"metadata": {},
411411
"outputs": [],
@@ -463,7 +463,7 @@
463463
},
464464
{
465465
"cell_type": "code",
466-
"execution_count": 18,
466+
"execution_count": null,
467467
"id": "c4a663d9",
468468
"metadata": {},
469469
"outputs": [],
@@ -507,7 +507,7 @@
507507
},
508508
{
509509
"cell_type": "code",
510-
"execution_count": 19,
510+
"execution_count": null,
511511
"id": "aae2d2be-ad03-4536-bf70-c4575f39cea3",
512512
"metadata": {},
513513
"outputs": [],
@@ -520,7 +520,7 @@
520520
},
521521
{
522522
"cell_type": "code",
523-
"execution_count": 20,
523+
"execution_count": null,
524524
"id": "5192dfae",
525525
"metadata": {},
526526
"outputs": [],
@@ -537,7 +537,7 @@
537537
},
538538
{
539539
"cell_type": "code",
540-
"execution_count": 21,
540+
"execution_count": null,
541541
"id": "4e995496",
542542
"metadata": {},
543543
"outputs": [],
@@ -560,7 +560,7 @@
560560
},
561561
{
562562
"cell_type": "code",
563-
"execution_count": 25,
563+
"execution_count": null,
564564
"id": "0efe744e",
565565
"metadata": {},
566566
"outputs": [],
@@ -602,7 +602,7 @@
602602
},
603603
{
604604
"cell_type": "code",
605-
"execution_count": 26,
605+
"execution_count": null,
606606
"id": "3d8031ce",
607607
"metadata": {},
608608
"outputs": [],
@@ -626,31 +626,6 @@
626626
"display_name": "Python 3 (ipykernel)",
627627
"language": "python",
628628
"name": "python3"
629-
},
630-
"language_info": {
631-
"codemirror_mode": {
632-
"name": "ipython",
633-
"version": 3
634-
},
635-
"file_extension": ".py",
636-
"mimetype": "text/x-python",
637-
"name": "python",
638-
"nbconvert_exporter": "python",
639-
"pygments_lexer": "ipython3",
640-
"version": "3.9.13"
641-
},
642-
"toc": {
643-
"base_numbering": 1,
644-
"nav_menu": {},
645-
"number_sections": false,
646-
"sideBar": true,
647-
"skip_h1_title": false,
648-
"title_cell": "Table of Contents",
649-
"title_sidebar": "Contents",
650-
"toc_cell": false,
651-
"toc_position": {},
652-
"toc_section_display": true,
653-
"toc_window_display": false
654629
}
655630
},
656631
"nbformat": 4,

tests/showdoc_test.ipynb

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,34 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 19,
66
"id": "c2ac41fe-6c3c-48c1-9531-490927859346",
77
"metadata": {},
88
"outputs": [],
99
"source": [
1010
"from nbdev.showdoc import show_doc\n",
11-
"from fastcore.all import patch"
11+
"from fastcore.utils import patch\n",
12+
"from fastcore.meta import delegates"
1213
]
1314
},
1415
{
1516
"cell_type": "code",
16-
"execution_count": 2,
17+
"execution_count": 12,
1718
"id": "f67bf2b2-88cf-446b-9241-f1351b129739",
1819
"metadata": {},
1920
"outputs": [],
2021
"source": [
2122
"#|export\n",
22-
"class Foo:..."
23+
"class Foo:\n",
24+
" def __init__(self,\n",
25+
" a, # A thing\n",
26+
" b:int=None): # Another thing\n",
27+
" ..."
2328
]
2429
},
2530
{
2631
"cell_type": "code",
27-
"execution_count": 3,
32+
"execution_count": 13,
2833
"id": "1f970abb-dfd0-41f0-9610-7e8b8ecdd552",
2934
"metadata": {},
3035
"outputs": [
@@ -35,15 +40,20 @@
3540
"\n",
3641
"### Foo\n",
3742
"\n",
38-
"> **`Foo`**` ()`\n",
43+
"> Foo (a, b:int=None)\n",
3944
"\n",
40-
"Initialize self. See help(type(self)) for accurate signature."
45+
"Initialize self. See help(type(self)) for accurate signature.\n",
46+
"\n",
47+
"| | **Type** | **Default** | **Details** |\n",
48+
"| -- | -------- | ----------- | ----------- |\n",
49+
"| a | | | A thing |\n",
50+
"| b | int | None | Another thing |"
4151
],
4252
"text/plain": [
43-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x7ff1921f6970>"
53+
"<nbdev.showdoc.BasicMarkdownRenderer at 0x117668130>"
4454
]
4555
},
46-
"execution_count": 3,
56+
"execution_count": 13,
4757
"metadata": {},
4858
"output_type": "execute_result"
4959
}
@@ -65,6 +75,57 @@
6575
" \"This is a method\"\n",
6676
" ..."
6777
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 25,
82+
"id": "f8be1e1a",
83+
"metadata": {},
84+
"outputs": [],
85+
"source": [
86+
"#|export\n",
87+
"@delegates()\n",
88+
"class B(Foo):\n",
89+
" def __init__(self, c, d:str=\"a\", **kwargs): ..."
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": 26,
95+
"id": "87d056c5",
96+
"metadata": {},
97+
"outputs": [
98+
{
99+
"data": {
100+
"text/markdown": [
101+
"---\n",
102+
"\n",
103+
"### B\n",
104+
"\n",
105+
"> B (c, d:str='a', b:int=None)\n",
106+
"\n",
107+
"Initialize self. See help(type(self)) for accurate signature."
108+
],
109+
"text/plain": [
110+
"<nbdev.showdoc.BasicMarkdownRenderer at 0x120dd1520>"
111+
]
112+
},
113+
"execution_count": 26,
114+
"metadata": {},
115+
"output_type": "execute_result"
116+
}
117+
],
118+
"source": [
119+
"show_doc(B)"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": null,
125+
"id": "e3c091c2",
126+
"metadata": {},
127+
"outputs": [],
128+
"source": []
68129
}
69130
],
70131
"metadata": {
@@ -83,7 +144,20 @@
83144
"name": "python",
84145
"nbconvert_exporter": "python",
85146
"pygments_lexer": "ipython3",
86-
"version": "3.9.7"
147+
"version": "3.9.13"
148+
},
149+
"toc": {
150+
"base_numbering": 1,
151+
"nav_menu": {},
152+
"number_sections": false,
153+
"sideBar": true,
154+
"skip_h1_title": false,
155+
"title_cell": "Table of Contents",
156+
"title_sidebar": "Contents",
157+
"toc_cell": false,
158+
"toc_position": {},
159+
"toc_section_display": true,
160+
"toc_window_display": false
87161
}
88162
},
89163
"nbformat": 4,

0 commit comments

Comments
 (0)