Skip to content

Commit

Permalink
fix order of toc
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchobben committed Aug 15, 2024
1 parent fc33f71 commit bca2da2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion chapters/01_classification.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Classification
title: Classification of Sentinel-2 imagery
subtitle: Finding forests with satelite imagery
jupyter:
kernelspec:
Expand Down
37 changes: 22 additions & 15 deletions src/eo_datascience/render_sfinx_toc.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
from pathlib import Path
import yaml

p = Path("notebooks").glob('*.ipynb')
files = [x.with_suffix('') for x in p if x.is_file()]
titles = [x.stem.split("_")[-1].title() for x in files]
ls = []
for i in range(len(titles)):
ls.append(dict(caption=titles[i], chapters=[dict(file=str(files[i]))]))
ls.append(dict(caption="Preamble", chapters=[dict(file="notebooks/how-to-cite")]))
ls.reverse()
toc = dict(
format="jb-book",
root="README",
parts=ls
)
def render_toc():
p = Path("notebooks").glob('*.ipynb')
files = [x.with_suffix('') for x in p if x.is_file()]
files.sort()
titles = [x.stem.split("_")[-1].title() for x in files]
ls = [dict(caption="Preamble", chapters=[dict(file="notebooks/how-to-cite")])]
for i in range(len(titles)):
ls.append(dict(caption=titles[i], chapters=[dict(file=str(files[i]))]))

with open('_toc.yml', 'w+') as ff:
yaml.dump(toc, ff)
toc = dict(
format="jb-book",
root="README",
parts=ls
)

with open('_toc.yml', 'w+') as ff:
yaml.dump(toc, ff)

def main():
render_toc()

if __name__ == '__main__':
main()

0 comments on commit bca2da2

Please sign in to comment.