Skip to content

Commit

Permalink
[Bug] Currently, search includes non-existing pages that land to 404 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschmidt85 authored Aug 30, 2024
1 parent fd8cdf1 commit ebbfe96
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions scripts/docs/gen_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

import logging
import os
from fnmatch import fnmatch
from pathlib import Path

import mkdocs_gen_files
from mkdocs.structure.files import File

FILE_PATTERN = "examples/**/README.md"
FILE_PATTERN = "examples/**/index.md"
logger = logging.getLogger("mkdocs.plugins.dstack.examples")

disable_env = "DSTACK_DOCS_DISABLE_EXAMPLES"
Expand All @@ -17,16 +20,12 @@

logger.info("Generating examples documentation...")


for root, dirs, files in os.walk("examples"):
for file in files:
if file == "README.md":
src_file = os.path.join(root, file)
with open(src_file, "r") as f:
text = f.read()
src_dir = os.path.dirname(src_file)
# dest_dir = os.path.join("docs", src_dir)
dest_file = os.path.join(src_dir, "index.md")
dest = mkdocs_gen_files._get_file(dest_file, new=True)
with mkdocs_gen_files.open(dest, "w") as f:
f.write(text)
file: File
for file in mkdocs_gen_files.files:
if not fnmatch(file.src_uri, FILE_PATTERN):
continue
p = (Path(file.src_dir).parent / file.src_uri).parent / "README.md"
with open(p, "r") as f:
text = f.read()
with mkdocs_gen_files.open(file.src_uri, "w") as f:
f.write(text)

0 comments on commit ebbfe96

Please sign in to comment.