aboutsummaryrefslogtreecommitdiffstats
path: root/doc/updt.sh
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-06-10 13:49:34 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-06-10 13:49:34 +0200
commit17b196f1326d6b6c249d44b8744d73d7bba12d7a (patch)
tree6592d70b095c010cf726ac27ad51fd6ca86cc61a /doc/updt.sh
parent6518887513840471ea9c5af7e534787717e6bd82 (diff)
Improves documentation
The script updt.sh is revisited to generate better the meta data. The format of events is documented. Change-Id: I3bb7347f3ac0f660196a25a4c0c0432848fe4168 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'doc/updt.sh')
-rwxr-xr-xdoc/updt.sh53
1 files changed, 34 insertions, 19 deletions
diff --git a/doc/updt.sh b/doc/updt.sh
index e6b721d6..5267ad5f 100755
--- a/doc/updt.sh
+++ b/doc/updt.sh
@@ -1,37 +1,52 @@
#!/bin/bash
-meta() {
- awk '
- NR == 1 { t = $0; next }
- NR == 2 && $1 ~ "======" { next }
- NR == 2 { exit }
- $1 == "Date:" { d = $2; for(i = 3 ; i <= NF ; i++) d = d " " $i; next }
- $1 == "Author:" { a = $2; for(i = 3 ; i <= NF ; i++) a = a " " $i; next }
- $1 == "version" || $1 == "Version" {next}
- /^[ \t]*$/ { printf "%% %s\n%% %s\n%% %s\n", t, a, d; exit }
- ' "$1"
+title() {
+ sed '/^[ \t]*$/d' "$1" |
+ sed '/^===/Q' |
+ sed '/^---/Q' |
+ sed 's/^# //;T;Q' |
+ sed 's/^## //;T;Q' |
+ sed '/^---/Q'
}
-# update the date field of file $1
-updadate() {
- local x=$1
- local t=$(git log -n 1 --format=%ct $x)
- [[ -n "$t" ]] || t=$(stat -c %Y $x)
- local d=$(LANG= date -d @$t +"%d %B %Y")
- sed -i "s/^\( Date: *\).*/\1$d/" $x
+authors() {
+ git log --numstat --format='A %aN' -- "$1" |
+ awk '$1=="A"{sub(/^A /,"");a=$0; s[a]+=0; next}NF==3{s[a]+=($1+0)}END{for(a in s)print s[a]" : "a}' |
+ sort -nr |
+ sed 's/[^:]* : //' |
+ sed '1!s/^/; /' |
+ tr -d '\n'
+}
+
+dateof() {
+ local file="$1"
+ local t=$(git log -n 1 --format=%ct "$file")
+ [[ -n "$t" ]] || t=$(stat -c %Y "$file")
+ LANG= date -d @$t +"%d %B %Y"
}
+meta() {
+ local file="$1"
+ local t=$(title "$file")
+ local a=$(authors "$file")
+ local d=$(dateof "$file")
+ echo "% $t"
+ echo "% $a"
+ echo "% $d"
+ cat "$file"
+}
+
+
# make the html file for $1
mkhtml() {
local x=$1
local h=${x%%.md}.html
- { meta "$x"; sed 's/TABLE-OF-CONTENT-HERE//' "$x"; } |
+ meta "$x" |
pandoc --css doc.css -f markdown -t html5 --toc > "$h"
}
# apply
for x in *.md; do
- updadate $x
mkhtml $x
done