From 4b0a40a20c26331b0a9c76845091b5065ffa6e2e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 5 Sep 2022 17:29:09 -0400 Subject: [PATCH] docs: add navigation indexes for installations and upgrades --- contrib/write-mkdocs | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/contrib/write-mkdocs b/contrib/write-mkdocs index fe5ddfb6c..ad645f47e 100644 --- a/contrib/write-mkdocs +++ b/contrib/write-mkdocs @@ -32,13 +32,52 @@ def get_nav_from_selector(soup, selector, docs_dir): filename = filename.replace("http://dokku.viewdocs.io/dokku/", "") filename = filename.strip("/") + ".md" filename = filename.removeprefix("dokku/") + + ignore_errors_for = [ + "getting-started/installation.md", + "getting-started/upgrading.md", + ] if not os.path.exists(docs_dir + "/" + filename): - print("error fetching markdown file:", filename) - continue + if filename not in ignore_errors_for: + print("error fetching markdown file:", filename) + continue for nav in navigation: if header_name in nav: - nav[header_name].append(filename) + if filename == "getting-started/installation.md": + child_dir = "getting-started/install/" + children = os.listdir(docs_dir + "/" + child_dir) + children = [child_dir + c for c in children] + children.insert( + 0, "getting-started/advanced-installation.md") + if os.path.exists(docs_dir + "/" + filename): + children.insert(0, filename) + else: + children.insert( + 0, "getting-started/installation/index.md") + nav[header_name].append({ + "Getting Started with Dokku": children, + }) + continue + elif filename == "getting-started/upgrading.md": + child_dir = "appendices/" + children = os.listdir(docs_dir + "/" + child_dir) + + children.sort(key=lambda x: list( + map(int, x.split("-")[0].split('.'))), + reverse=True) + children = [child_dir + c for c in children] + if os.path.exists(docs_dir + "/" + filename): + children.insert(0, filename) + else: + children.insert( + 0, "getting-started/upgrading/index.md") + nav[header_name].append({ + "Upgrading": children, + }) + continue + else: + nav[header_name].append(filename) return navigation