Skip to content

Commit

Permalink
Merge pull request #10 from AnswerDotAI/chk-cfg
Browse files Browse the repository at this point in the history
Check if in nbdev proect
  • Loading branch information
hamelsmu authored Sep 17, 2024
2 parents 58c8219 + 27fcf63 commit 3e12f49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions llms_txt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions nbs/01_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 *"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}}"
Expand All @@ -802,7 +802,7 @@
{
"data": {
"text/plain": [
"164321"
"164543"
]
},
"execution_count": null,
Expand Down

0 comments on commit 3e12f49

Please sign in to comment.