Skip to content

Commit

Permalink
path corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten committed Feb 6, 2024
1 parent 36e2cb1 commit d3eef11
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions docs/post_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def fix_metadata(notebook_path):
elif notebook_name.startswith("py_"):
notebook["metadata"] = metadata_py
else:
print(f"Notebook {notebook_path} does not start with js_ or py_")
return

print("fixing", notebook_path)
with open(notebook_path, "w") as f:
json.dump(notebook, f, indent=4)

Expand All @@ -74,6 +75,12 @@ def fix_all_notebooks(directory):
if item.is_file() and item.suffix == ".ipynb":
fix_metadata(item)

def recusively_fix_all_notebooks(directory):
if directory.exists():
# iterate over all notebooks (with pathlib)
for item in Path(directory).rglob("*.ipynb"):
fix_metadata(item)


# def fix_rst_links(js_rst_file):

Expand Down Expand Up @@ -117,15 +124,18 @@ def fix_html_links(js_html_file):

from pathlib import Path

this_dir = Path(__file__)#.parent
this_dir = Path(__file__).parent
auto_examples_dir = this_dir / "auto_examples"
build_dir_html = this_dir / "_build" / "html"
lite_build_dir = build_dir_html / "lite"

_download_dir = build_dir_html /"_downloads"
recusively_fix_all_notebooks(this_dir)

lite_auto_examples_dir = lite_build_dir / "files"/ "auto_examples"

fix_all_notebooks(lite_auto_examples_dir)
fix_all_notebooks(auto_examples_dir)
# fix_all_notebooks(lite_auto_examples_dir)
# fix_all_notebooks(auto_examples_dir)

auto_example_build_dir = build_dir_html / "auto_examples"

Expand All @@ -136,7 +146,6 @@ def fix_html_links(js_html_file):
if item.is_file() and item.suffix == ".html":
# only for js
if item.stem.startswith("js_"):
print("fixing html links")
fix_html_links(item)


Expand Down

0 comments on commit d3eef11

Please sign in to comment.