Skip to content

Commit

Permalink
Merge pull request #11 from AnswerDotAI/no-nbdev
Browse files Browse the repository at this point in the history
delete nbdev
  • Loading branch information
jph00 authored Sep 20, 2024
2 parents 3e12f49 + c86a79a commit 1ee68fa
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 94 deletions.
1 change: 1 addition & 0 deletions llms_txt/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'git_url': 'https://github.com/AnswerDotAI/llms-txt',
'lib_path': 'llms_txt'},
'syms': { 'llms_txt.core': { 'llms_txt.core._doc': ('core.html#_doc', 'llms_txt/core.py'),
'llms_txt.core._get_config': ('core.html#_get_config', 'llms_txt/core.py'),
'llms_txt.core._local_docs_pth': ('core.html#_local_docs_pth', 'llms_txt/core.py'),
'llms_txt.core._parse_links': ('core.html#_parse_links', 'llms_txt/core.py'),
'llms_txt.core._parse_llms': ('core.html#_parse_llms', 'llms_txt/core.py'),
Expand Down
10 changes: 4 additions & 6 deletions llms_txt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from fastcore.script import *
import httpx
from urllib.parse import urlparse
from nbdev.config import *

# %% ../nbs/01_core.ipynb
def opt_re(s):
Expand Down Expand Up @@ -69,12 +68,12 @@ def parse_llms_file(txt):
from fastcore.xml import Sections,Project,Doc

# %% ../nbs/01_core.ipynb
def _local_docs_pth(cfg): return cfg.config_path/'_proc'/cfg.doc_path.name
def _local_docs_pth(cfg): return cfg.config_path/'_proc'/cfg.doc_path
def _get_config(): return Config.find('settings.ini')

def get_doc_content(url):
"Fetch content from local file if in nbdev repo."
cfg = get_config()
if is_nbdev() and url.startswith(cfg.doc_host):
if (cfg:=_get_config()) 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 Expand Up @@ -124,7 +123,6 @@ def llms_txt2ctx(
):
"Print a `Project` with a `Section` for each H2 part in file read from `fname`, optionally skipping the 'optional' section."
ctx = create_ctx(Path(fname).read_text(), optional=optional, n_workers=n_workers)
if save_nbdev_fname:
cfg = get_config()
if save_nbdev_fname and (cfg:=_get_config()):
(_local_docs_pth(cfg) / save_nbdev_fname).mk_write(ctx)
else: print(ctx)
Loading

0 comments on commit 1ee68fa

Please sign in to comment.