diff --git a/tools/navigation.py b/tools/navigation.py index 6985bff..a7044f0 100755 --- a/tools/navigation.py +++ b/tools/navigation.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -import os import glob +import os +import re +import sys import yaml @@ -29,14 +31,31 @@ def traverse_siblings(pages, start, sibling='next'): page = pages[page]['siblings'].get(sibling) -def create_intro_toc(pages, start, offset=2): +def create_intro_toc(pages, start, offset=2, file=sys.stdout): for num, page in enumerate(traverse_siblings(pages, start)): data = pages[page] title = most_appropriate_title(data) - print(f"{num + offset}. [{title}]({page})\n") + print(f"{num + offset}. [{title}]({page})\n", file=file) -def create_navbar(pages, start): +def overwrite_info_toc(pages, start, offset=2): + old_name = "gdb/index.md" + new_name = "gdb/.index.new" + with open(old_name) as orig: + with open(new_name, 'w') as new: + found = False + for line in orig: + if found and '{title}') + print(f' {title}', file=file) -def check_nav_consistency(pages, first): - for page in traverse_siblings(pages, first): +def overwrite_navbar(pages, start): + old_name = "_gdb-menu.hbs" + new_name = ".gdb-menu.new" + with open(old_name) as orig: + with open(new_name, 'w') as new: + found = False + for line in orig: + if found and '