Skip to content

Commit

Permalink
Add TOC to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Nov 5, 2023
1 parent b2d855b commit 89a47a0
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
_toc.yml
36 changes: 36 additions & 0 deletions docs/book/build_toc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import geemap

input_dir = os.getcwd()
files = geemap.find_files(input_dir, ext=".ipynb", fullpath=True)
files = [file.replace(f"{input_dir}/docs/", "") for file in files]
files.sort()

fundamentals = []
applications = []

for file in files:
if file.startswith("book/Part F"):
fundamentals.append(file)
elif file.startswith("book/Part A"):
applications.append(file)

files = fundamentals + applications

sections = []
toc = []

for file in files:
if file.startswith("book/Part"):
section = file.split("/")[2]
if section not in sections:
sections.append(section)
toc.append(f" - {section}:\n")
print(f" - {section}:")
print(f" - {file}")
toc.append(f" - {file}\n")

print(sections)

with open("_toc.yml", "w") as f:
f.writelines(toc)
Loading

0 comments on commit 89a47a0

Please sign in to comment.