summaryrefslogtreecommitdiffstats
path: root/doc/updt.sh
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-05-24 23:49:18 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-05-25 00:13:33 +0200
commit302353aa3b90bf3b70d33f05e6c78754d2f1bc7a (patch)
tree081da81f522a3bd27b41862b6c83f538d891c510 /doc/updt.sh
parent01740abeafa96e11103b1366ae0129d4e87281aa (diff)
begins the documentation
Change-Id: I560725dfa5dd7ab1ae5e91b45f5ba613c3a2c1de Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'doc/updt.sh')
-rwxr-xr-xdoc/updt.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/updt.sh b/doc/updt.sh
new file mode 100755
index 00000000..cd978e22
--- /dev/null
+++ b/doc/updt.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+subst() {
+ awk -v pat="$1" -v rep="$(sed 's:\\:\\\\:g' $2)" '{gsub(pat,rep);gsub(pat,"\\&");print}'
+}
+
+main='<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="doc.css">
+ <meta charset="UTF-8">
+</head>
+<body>
+GENERATED-MARKDOWN-HERE
+</body>
+</html>'
+
+for x in *.md; do
+ t=$(git log -n 1 --format=%ct $x)
+ [[ -n "$t" ]] || t=$(stat -c %Y $x)
+ d=$(LANG= date -d @$t +"%d %B %Y")
+ sed -i "s/^\( Date: *\).*/\1$d/" $x
+ h=${x%%.md}.html
+ markdown -f toc,autolink $x > $h.toc.no
+ markdown -Tf toc,autolink $x > $h.toc.yes
+ head --bytes=-$(stat -c %s $h.toc.no) $h.toc.yes > $h.toc
+ echo "$main" |
+ subst GENERATED-MARKDOWN-HERE $h.toc.no |
+ subst TABLE-OF-CONTENT-HERE $h.toc > $h
+# rm $h.toc*
+done
+