|
15 | 15 | from fastcore.script import *
|
16 | 16 | import httpx
|
17 | 17 | from urllib.parse import urlparse
|
18 |
| -from nbdev.config import * |
19 | 18 |
|
20 | 19 | # %% ../nbs/01_core.ipynb
|
21 | 20 | def opt_re(s):
|
@@ -69,12 +68,12 @@ def parse_llms_file(txt):
|
69 | 68 | from fastcore.xml import Sections,Project,Doc
|
70 | 69 |
|
71 | 70 | # %% ../nbs/01_core.ipynb
|
72 |
| -def _local_docs_pth(cfg): return cfg.config_path/'_proc'/cfg.doc_path.name |
| 71 | +def _local_docs_pth(cfg): return cfg.config_path/'_proc'/cfg.doc_path |
| 72 | +def _get_config(): return Config.find('settings.ini') |
73 | 73 |
|
74 | 74 | def get_doc_content(url):
|
75 | 75 | "Fetch content from local file if in nbdev repo."
|
76 |
| - cfg = get_config() |
77 |
| - if is_nbdev() and url.startswith(cfg.doc_host): |
| 76 | + if (cfg:=_get_config()) and url.startswith(cfg.doc_host): |
78 | 77 | relative_path = urlparse(url).path.lstrip('/')
|
79 | 78 | local_path = _local_docs_pth(cfg) / relative_path
|
80 | 79 | if local_path.exists(): return local_path.read_text()
|
@@ -124,7 +123,6 @@ def llms_txt2ctx(
|
124 | 123 | ):
|
125 | 124 | "Print a `Project` with a `Section` for each H2 part in file read from `fname`, optionally skipping the 'optional' section."
|
126 | 125 | ctx = create_ctx(Path(fname).read_text(), optional=optional, n_workers=n_workers)
|
127 |
| - if save_nbdev_fname: |
128 |
| - cfg = get_config() |
| 126 | + if save_nbdev_fname and (cfg:=_get_config()): |
129 | 127 | (_local_docs_pth(cfg) / save_nbdev_fname).mk_write(ctx)
|
130 | 128 | else: print(ctx)
|
0 commit comments