Skip to content

Commit 3e12f49

Browse files
authored
Merge pull request #10 from AnswerDotAI/chk-cfg
Check if in nbdev proect
2 parents 58c8219 + 27fcf63 commit 3e12f49

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

llms_txt/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from fastcore.script import *
1616
import httpx
1717
from urllib.parse import urlparse
18-
from nbdev.config import get_config
18+
from nbdev.config import *
1919

2020
# %% ../nbs/01_core.ipynb
2121
def opt_re(s):
@@ -74,7 +74,7 @@ def _local_docs_pth(cfg): return cfg.config_path/'_proc'/cfg.doc_path.name
7474
def get_doc_content(url):
7575
"Fetch content from local file if in nbdev repo."
7676
cfg = get_config()
77-
if url.startswith(cfg.doc_host):
77+
if is_nbdev() and url.startswith(cfg.doc_host):
7878
relative_path = urlparse(url).path.lstrip('/')
7979
local_path = _local_docs_pth(cfg) / relative_path
8080
if local_path.exists(): return local_path.read_text()

nbs/01_core.ipynb

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"from fastcore.script import *\n",
5252
"import httpx\n",
5353
"from urllib.parse import urlparse\n",
54-
"from nbdev.config import get_config"
54+
"from nbdev.config import *"
5555
]
5656
},
5757
{
@@ -686,7 +686,7 @@
686686
"def get_doc_content(url):\n",
687687
" \"Fetch content from local file if in nbdev repo.\"\n",
688688
" cfg = get_config()\n",
689-
" if url.startswith(cfg.doc_host):\n",
689+
" if is_nbdev() and url.startswith(cfg.doc_host):\n",
690690
" relative_path = urlparse(url).path.lstrip('/')\n",
691691
" local_path = _local_docs_pth(cfg) / relative_path\n",
692692
" if local_path.exists(): return local_path.read_text()\n",
@@ -778,8 +778,8 @@
778778
"data": {
779779
"text/plain": [
780780
"{'docs': {'internal docs - ed': 34464,\n",
781-
" 'FastHTML quick start': 27376,\n",
782-
" 'HTMX reference': 26427,\n",
781+
" 'FastHTML quick start': 27383,\n",
782+
" 'HTMX reference': 26642,\n",
783783
" 'Starlette quick guide': 7936},\n",
784784
" 'examples': {'Todo list application': 18558},\n",
785785
" 'optional': {'Starlette full documentation': 48331}}"
@@ -802,7 +802,7 @@
802802
{
803803
"data": {
804804
"text/plain": [
805-
"164321"
805+
"164543"
806806
]
807807
},
808808
"execution_count": null,

0 commit comments

Comments
 (0)