#!/usr/bin/env python3 def print_outline(): root_path = "https://github.com/binkley/modern-java-practices/wiki" with open("./_Sidebar.md", 'r') as sidebar: for line in sidebar.readlines(): if line.startswith("#"): if line.startswith("## "): header = line.replace("##", "") print("- {}".format(header.strip())) else: line = (line.replace("###", "").strip()) if line.startswith("[["): page_name = line.replace("[[", "").replace("]]", "") file_name = "{}.md".format(page_name.replace(" ", "-")) else: page_name, file_name = "", "" if page_name != "": print(" - [{}]({}/{})".format(page_name, root_path, file_name)) print_page_outline(file_name) def print_page_outline(page_name): with open(page_name, 'r') as wiki_page: for line in wiki_page.readlines(): if line.startswith("#"): if line.startswith("## "): print(" - {}".format(line.replace("##", "").strip())) elif line.startswith("### "): print(" - {}".format(line.replace("###", "").strip())) elif line.startswith("#### "): print(" - {}".format(line.replace("####", "").strip())) elif line.startswith("##### "): print(" - {}".format(line.replace("#####", "").strip())) print_outline()