missing
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 14 Jan 2016 12:49:58 +0000 (13:49 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 14 Jan 2016 12:49:58 +0000 (13:49 +0100)
website/index.py [new file with mode: 0755]

diff --git a/website/index.py b/website/index.py
new file mode 100755 (executable)
index 0000000..fe137e5
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# computes an index file in markdown/index.md from ./index.md with all the other md files referenced
+
+import sys
+import os
+from glob import glob
+
+source = "index.md"
+output_dir = "markdown"
+
+index_line_format = " * [{title}]({base}.html)\n"
+
+TITLE="title:"
+
+def get_title(filename):
+    with open(filename) as input:
+        for line in input:
+            if line.startswith(TITLE):
+                return line[len(TITLE):].strip()
+    return filename
+
+def main():
+    if not os.path.isfile(source):
+        print("Source not found {}".format(source))
+        sys.exit(1)
+
+    output = os.path.join(output_dir, source)
+    with open(output, 'w') as result:
+        # copy index.md
+        with open(source) as input:
+            result.write(input.read())
+        for other in sys.argv[1:]:
+            dir = os.path.dirname(other) or "."
+            base = os.path.basename(other).replace(".md", "")
+            title = get_title(other)
+            # skip index from the index...
+            if base == "index":
+                continue
+            # menu generated
+            #result.write(index_line_format.format(**locals()))
+    print("(Over)wrote {}".format(output))
+
+main()