From 1089ddc9eac51e20f82cba176399134f9bd3e589 Mon Sep 17 00:00:00 2001 From: ncoop57 Date: Sun, 1 Dec 2024 22:32:41 -0600 Subject: [PATCH] Update doclinks tests to focus on builtins and stripping --- nbs/api/05_doclinks.ipynb | 83 ++++++++++++--------------------------- 1 file changed, 26 insertions(+), 57 deletions(-) diff --git a/nbs/api/05_doclinks.ipynb b/nbs/api/05_doclinks.ipynb index 3430efe1..3a1e460f 100644 --- a/nbs/api/05_doclinks.ipynb +++ b/nbs/api/05_doclinks.ipynb @@ -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": {}, @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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, @@ -1063,8 +1076,8 @@ } ], "source": [ - "# Test code blocks\n", - "md = \"`abc.ABC`\"\n", + "# Test builtins\n", + "md = \"`builtins.str.split`\"\n", "NbdevLookup().linkify(md)" ] }, @@ -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, @@ -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)" ] }, {