diff --git a/llms_txt/core.py b/llms_txt/core.py index e8a43bc..838cb23 100644 --- a/llms_txt/core.py +++ b/llms_txt/core.py @@ -15,7 +15,7 @@ from fastcore.script import * import httpx from urllib.parse import urlparse -from nbdev.config import get_config +from nbdev.config import * # %% ../nbs/01_core.ipynb def opt_re(s): @@ -74,7 +74,7 @@ def _local_docs_pth(cfg): return cfg.config_path/'_proc'/cfg.doc_path.name def get_doc_content(url): "Fetch content from local file if in nbdev repo." cfg = get_config() - if url.startswith(cfg.doc_host): + if is_nbdev() and url.startswith(cfg.doc_host): relative_path = urlparse(url).path.lstrip('/') local_path = _local_docs_pth(cfg) / relative_path if local_path.exists(): return local_path.read_text() diff --git a/nbs/01_core.ipynb b/nbs/01_core.ipynb index c65c9fa..331f0de 100644 --- a/nbs/01_core.ipynb +++ b/nbs/01_core.ipynb @@ -51,7 +51,7 @@ "from fastcore.script import *\n", "import httpx\n", "from urllib.parse import urlparse\n", - "from nbdev.config import get_config" + "from nbdev.config import *" ] }, { @@ -686,7 +686,7 @@ "def get_doc_content(url):\n", " \"Fetch content from local file if in nbdev repo.\"\n", " cfg = get_config()\n", - " if url.startswith(cfg.doc_host):\n", + " if is_nbdev() and url.startswith(cfg.doc_host):\n", " relative_path = urlparse(url).path.lstrip('/')\n", " local_path = _local_docs_pth(cfg) / relative_path\n", " if local_path.exists(): return local_path.read_text()\n", @@ -778,8 +778,8 @@ "data": { "text/plain": [ "{'docs': {'internal docs - ed': 34464,\n", - " 'FastHTML quick start': 27376,\n", - " 'HTMX reference': 26427,\n", + " 'FastHTML quick start': 27383,\n", + " 'HTMX reference': 26642,\n", " 'Starlette quick guide': 7936},\n", " 'examples': {'Todo list application': 18558},\n", " 'optional': {'Starlette full documentation': 48331}}" @@ -802,7 +802,7 @@ { "data": { "text/plain": [ - "164321" + "164543" ] }, "execution_count": null,