#!/usr/bin/env python # index for the documentation import sys from glob import glob from collections import defaultdict LANG = {"en": "english", "hu": "hungarian"} output = [""] pages = {"html": defaultdict(list), "pdf": defaultdict(list)} for path in glob("*/*"): what, lang = path.split("/") for path2 in glob(path + "/*"): EXT = "/*.pdf" if what == "pdf" else "/index.html" for fn in glob(path2 + EXT): pages[what][lang].append(fn) output.append("

Documentation

") for what in pages: output.append("

%s

" % what.upper()) output.append("") output.append("") with open("index.html", "w") as index: index.write("\n".join(output)) if len(sys.argv) > 1 and sys.argv[1] == "fix": # fixes the static links in sphinx # !!! ONLY RUN THIS ONCE !!! import os import subprocess as sp os.chdir(os.path.expanduser("~/documentation/html/")) ROOT = os.path.abspath(os.curdir) for link in sp.Popen("find -type l -name _static".split(), stdout=sp.PIPE).stdout: d = os.path.normpath(os.path.join(ROOT, link.rsplit("/", 1)[0])) print(d) os.chdir(d) os.system( r'find -type f -name "*.html" -exec sed -i "s/_static/..\/_static/" {} \;')