mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
Used the website files that are part of the package per setup.py instead of walking the real website directory.
This commit is contained in:
parent
6db8501891
commit
98c0621e44
1 changed files with 8 additions and 19 deletions
|
@ -6,29 +6,18 @@ import warnings
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
import importlib_resources
|
||||||
|
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
|
|
||||||
warnings.simplefilter("ignore", category=FutureWarning)
|
warnings.simplefilter("ignore", category=FutureWarning)
|
||||||
|
|
||||||
|
|
||||||
def should_skip_dir(dirname):
|
def get_package_files():
|
||||||
if dirname.startswith("OLD"):
|
website_files = importlib_resources.files('website')
|
||||||
return True
|
for path in website_files.rglob('*.md'):
|
||||||
if dirname.startswith("tmp"):
|
if not any(part.startswith(('OLD', 'tmp')) or part in ('examples', '_posts') for part in path.parts):
|
||||||
return True
|
yield str(path)
|
||||||
if dirname == "examples":
|
|
||||||
return True
|
|
||||||
if dirname == "_posts":
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def walk_subdirs_for_files(root_dir):
|
|
||||||
root_path = Path(root_dir)
|
|
||||||
for path in root_path.rglob("*.md"):
|
|
||||||
if any(should_skip_dir(part) for part in path.parts):
|
|
||||||
continue
|
|
||||||
yield str(path)
|
|
||||||
|
|
||||||
|
|
||||||
def fname_to_url(filepath):
|
def fname_to_url(filepath):
|
||||||
|
@ -75,10 +64,10 @@ def get_index():
|
||||||
parser = MarkdownNodeParser()
|
parser = MarkdownNodeParser()
|
||||||
|
|
||||||
nodes = []
|
nodes = []
|
||||||
for fname in tqdm(list(walk_subdirs_for_files("website"))):
|
for fname in tqdm(list(get_package_files())):
|
||||||
fname = Path(fname)
|
fname = Path(fname)
|
||||||
doc = Document(
|
doc = Document(
|
||||||
text=fname.read_text(),
|
text=importlib_resources.files('website').joinpath(fname).read_text(),
|
||||||
metadata=dict(
|
metadata=dict(
|
||||||
filename=fname.name,
|
filename=fname.name,
|
||||||
extension=fname.suffix,
|
extension=fname.suffix,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue