Skip to content

Commit

Permalink
switch to glob for file discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Mar 25, 2024
1 parent 4671fc4 commit c6896c1
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions docs/tools/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import List
import os
import glob

import dlt.cli.echo as fmt

Expand All @@ -15,24 +16,20 @@ def collect_markdown_files(verbose: bool) -> List[str]:

# collect docs pages
markdown_files: List[str] = []
for path, _, files in os.walk(DOCS_DIR):
if "api_reference" in path:
for filepath in glob.glob(f'{DOCS_DIR}/**/*.md', recursive=True):
if "api_reference" in filepath:
continue
if "jaffle_shop" in path:
if "jaffle_shop" in filepath:
continue
for file in files:
if file.endswith(".md"):
markdown_files.append(os.path.join(path, file))
if verbose:
fmt.echo(f"Discovered {os.path.join(path, file)}")
markdown_files.append(filepath)
if verbose:
fmt.echo(f"Discovered {filepath}")

# collect blog pages
for path, _, files in os.walk(BLOG_DIR):
for file in files:
if file.endswith(".md"):
markdown_files.append(os.path.join(path, file))
if verbose:
fmt.echo(f"Discovered {os.path.join(path, file)}")
for filepath in glob.glob(f'{BLOG_DIR}/**/*.md', recursive=True):
markdown_files.append(filepath)
if verbose:
fmt.echo(f"Discovered {filepath}")

if len(markdown_files) < 50: # sanity check
fmt.error("Found too few files. Something went wrong.")
Expand Down

0 comments on commit c6896c1

Please sign in to comment.