Skip to content

Commit

Permalink
Update doclinks tests to focus on builtins and stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
ncoop57 committed Dec 2, 2024
1 parent 9b982f1 commit 1089ddc
Showing 1 changed file with 26 additions and 57 deletions.
83 changes: 26 additions & 57 deletions nbs/api/05_doclinks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,19 @@
"dict(list(syms['builtins'].items())[:10])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for b in syms['builtins']:\n",
" b = b.split('.')\n",
" if len(b) != 2: continue\n",
" b = b[1]\n",
" assert b in bset"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -805,7 +818,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L241){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L266){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### NbdevLookup.doc\n",
"\n",
Expand All @@ -816,7 +829,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L241){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L266){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### NbdevLookup.doc\n",
"\n",
Expand Down Expand Up @@ -907,7 +920,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L246){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L271){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### NbdevLookup.code\n",
"\n",
Expand All @@ -918,7 +931,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L246){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L271){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### NbdevLookup.code\n",
"\n",
Expand Down Expand Up @@ -966,7 +979,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L264){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L289){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### NbdevLookup.linkify\n",
"\n",
Expand All @@ -975,7 +988,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L264){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/nbdev/blob/master/nbdev/doclinks.py#L289){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### NbdevLookup.linkify\n",
"\n",
Expand Down Expand Up @@ -1054,7 +1067,7 @@
{
"data": {
"text/plain": [
"'[`abc.ABC`](https://docs.python.org/3/library/abc.html#abc.ABC)'"
"'[`builtins.str.split`](https://docs.python.org/3/library/stdtypes.html#str.split)'"
]
},
"execution_count": null,
Expand All @@ -1063,8 +1076,8 @@
}
],
"source": [
"# Test code blocks\n",
"md = \"`abc.ABC`\"\n",
"# Test builtins\n",
"md = \"`builtins.str.split`\"\n",
"NbdevLookup().linkify(md)"
]
},
Expand All @@ -1076,7 +1089,7 @@
{
"data": {
"text/plain": [
"'[`functools.partial`](https://docs.python.org/3/library/functools.html#functools.partial)'"
"'[`str.split`](https://docs.python.org/3/library/stdtypes.html#str.split) and [`str`](https://docs.python.org/3/library/locale.html#locale.str)'"
]
},
"execution_count": null,
Expand All @@ -1085,53 +1098,9 @@
}
],
"source": [
"# Test code blocks\n",
"md = \"`functools.partial`\"\n",
"NbdevLookup().linkify(md)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'`str.split`'"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Test code blocks\n",
"md = \"`str.split`\"\n",
"NbdevLookup().linkify(md)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'[`numpy.array`](https://numpy.org/doc/stable/reference/generated/numpy.array.html#numpy.array)'"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Test code blocks\n",
"md = \"`numpy.array`\"\n",
"NbdevLookup().linkify(md)"
"# ... now with stripping\n",
"md = \"`str.split` and `str`\"\n",
"NbdevLookup('nbdev_stdlib').linkify(md)"
]
},
{
Expand Down

0 comments on commit 1089ddc

Please sign in to comment.