|
627 | 627 | " for m in strip_libs:\n",
|
628 | 628 | " if m in entries:\n",
|
629 | 629 | " _d = entries[m]\n",
|
630 |
| - " stripped = {remove_prefix(k,f\"{mod}.\"):v\n", |
631 |
| - " for mod,dets in _d['syms'].items() if mod not in skip_mods\n", |
632 |
| - " for k,v in dets.items()}\n", |
| 630 | + " stripped = {}\n", |
| 631 | + " for mod, dets in _d['syms'].items():\n", |
| 632 | + " if mod not in skip_mods:\n", |
| 633 | + " for k,v in dets.items():\n", |
| 634 | + " k = remove_prefix(k,f\"{mod}.\")\n", |
| 635 | + " if k not in stripped: stripped[k] = v\n", |
633 | 636 | " py_syms = merge(stripped, py_syms)\n",
|
634 | 637 | " return entries,py_syms"
|
635 | 638 | ]
|
|
804 | 807 | "text/markdown": [
|
805 | 808 | "---\n",
|
806 | 809 | "\n",
|
807 |
| - "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L266){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 810 | + "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L269){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
808 | 811 | "\n",
|
809 | 812 | "### NbdevLookup.doc\n",
|
810 | 813 | "\n",
|
|
815 | 818 | "text/plain": [
|
816 | 819 | "---\n",
|
817 | 820 | "\n",
|
818 |
| - "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L266){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 821 | + "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L269){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
819 | 822 | "\n",
|
820 | 823 | "### NbdevLookup.doc\n",
|
821 | 824 | "\n",
|
|
906 | 909 | "text/markdown": [
|
907 | 910 | "---\n",
|
908 | 911 | "\n",
|
909 |
| - "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L271){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 912 | + "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L274){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
910 | 913 | "\n",
|
911 | 914 | "### NbdevLookup.code\n",
|
912 | 915 | "\n",
|
|
917 | 920 | "text/plain": [
|
918 | 921 | "---\n",
|
919 | 922 | "\n",
|
920 |
| - "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L271){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 923 | + "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L274){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
921 | 924 | "\n",
|
922 | 925 | "### NbdevLookup.code\n",
|
923 | 926 | "\n",
|
|
965 | 968 | "text/markdown": [
|
966 | 969 | "---\n",
|
967 | 970 | "\n",
|
968 |
| - "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L289){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 971 | + "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L292){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
969 | 972 | "\n",
|
970 | 973 | "### NbdevLookup.linkify\n",
|
971 | 974 | "\n",
|
|
974 | 977 | "text/plain": [
|
975 | 978 | "---\n",
|
976 | 979 | "\n",
|
977 |
| - "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L289){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 980 | + "[source](https://github.com/AnswerDotAI/nbdev/blob/master/nbdev/doclinks.py#L292){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
978 | 981 | "\n",
|
979 | 982 | "### NbdevLookup.linkify\n",
|
980 | 983 | "\n",
|
|
1075 | 1078 | {
|
1076 | 1079 | "data": {
|
1077 | 1080 | "text/plain": [
|
1078 |
| - "'[`str.split`](https://docs.python.org/3/library/stdtypes.html#str.split) and [`str`](https://docs.python.org/3/library/locale.html#locale.str)'" |
| 1081 | + "'[`str.split`](https://docs.python.org/3/library/stdtypes.html#str.split) and [`str`](https://docs.python.org/3/library/stdtypes.html#str)'" |
1079 | 1082 | ]
|
1080 | 1083 | },
|
1081 | 1084 | "execution_count": null,
|
|
1089 | 1092 | "NbdevLookup('nbdev_stdlib').linkify(md)"
|
1090 | 1093 | ]
|
1091 | 1094 | },
|
| 1095 | + { |
| 1096 | + "cell_type": "markdown", |
| 1097 | + "metadata": {}, |
| 1098 | + "source": [ |
| 1099 | + "When there is a conflict, the linkification will apply in the order of the stripped libraries and then by alphabetical order. For example, `enumerate` is both a builtin and a function in the threading module. However, since builtins comes first alphabetically, it will take priority" |
| 1100 | + ] |
| 1101 | + }, |
| 1102 | + { |
| 1103 | + "cell_type": "code", |
| 1104 | + "execution_count": null, |
| 1105 | + "metadata": {}, |
| 1106 | + "outputs": [ |
| 1107 | + { |
| 1108 | + "data": { |
| 1109 | + "text/plain": [ |
| 1110 | + "'[`enumerate`](https://docs.python.org/3/library/functions.html#enumerate), [`builtins.enumerate`](https://docs.python.org/3/library/functions.html#enumerate) and [`threading.enumerate`](https://docs.python.org/3/library/threading.html#threading.enumerate)'" |
| 1111 | + ] |
| 1112 | + }, |
| 1113 | + "execution_count": null, |
| 1114 | + "metadata": {}, |
| 1115 | + "output_type": "execute_result" |
| 1116 | + } |
| 1117 | + ], |
| 1118 | + "source": [ |
| 1119 | + "md = \"`enumerate`, `builtins.enumerate` and `threading.enumerate`\"\n", |
| 1120 | + "NbdevLookup(('nbdev_stdlib')).linkify(md)" |
| 1121 | + ] |
| 1122 | + }, |
| 1123 | + { |
| 1124 | + "cell_type": "markdown", |
| 1125 | + "metadata": {}, |
| 1126 | + "source": [ |
| 1127 | + "We can also take the `find()` function as another instance, it exists as a standard library and in numpy. Therefore, depending on the order of stripped libraries we pass, `find()` will link to either numpy or standard library." |
| 1128 | + ] |
| 1129 | + }, |
| 1130 | + { |
| 1131 | + "cell_type": "code", |
| 1132 | + "execution_count": null, |
| 1133 | + "metadata": {}, |
| 1134 | + "outputs": [ |
| 1135 | + { |
| 1136 | + "data": { |
| 1137 | + "text/plain": [ |
| 1138 | + "'[`find()`](https://numpy.org/doc/stable/reference/generated/numpy.char.find.html#numpy.char.find)'" |
| 1139 | + ] |
| 1140 | + }, |
| 1141 | + "execution_count": null, |
| 1142 | + "metadata": {}, |
| 1143 | + "output_type": "execute_result" |
| 1144 | + } |
| 1145 | + ], |
| 1146 | + "source": [ |
| 1147 | + "md = \"`find()`\"\n", |
| 1148 | + "NbdevLookup(('nbdev_numpy','nbdev_stdlib')).linkify(md)" |
| 1149 | + ] |
| 1150 | + }, |
| 1151 | + { |
| 1152 | + "cell_type": "code", |
| 1153 | + "execution_count": null, |
| 1154 | + "metadata": {}, |
| 1155 | + "outputs": [ |
| 1156 | + { |
| 1157 | + "data": { |
| 1158 | + "text/plain": [ |
| 1159 | + "'[`find()`](https://docs.python.org/3/library/gettext.html#gettext.find)'" |
| 1160 | + ] |
| 1161 | + }, |
| 1162 | + "execution_count": null, |
| 1163 | + "metadata": {}, |
| 1164 | + "output_type": "execute_result" |
| 1165 | + } |
| 1166 | + ], |
| 1167 | + "source": [ |
| 1168 | + "md = \"`find()`\"\n", |
| 1169 | + "NbdevLookup(('nbdev_stdlib','nbdev_numpy')).linkify(md)" |
| 1170 | + ] |
| 1171 | + }, |
1092 | 1172 | {
|
1093 | 1173 | "cell_type": "markdown",
|
1094 | 1174 | "metadata": {},
|
|
0 commit comments