X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=doc%2Fupdt.sh;h=d0c02e7add08324af9b21c350af017cb08cea7f1;hb=38ba270af828b80e0ffb5eab955aff733de17dba;hp=a6292c832fbdc618b99fc5b6a0ef07729a2f3002;hpb=ddd10705d70b598160a41d197f364d2f792359f5;p=src%2Fapp-framework-main.git diff --git a/doc/updt.sh b/doc/updt.sh index a6292c8..d0c02e7 100755 --- a/doc/updt.sh +++ b/doc/updt.sh @@ -1,25 +1,53 @@ -#!/bin/sh - -fmd() { -cat << EOC - - - - - - -$(cat) - - -EOC +#!/bin/bash + +title() { + sed '/^[ \t]*$/d' "$1" | + sed '/^===/Q' | + sed '/^---/Q' | + sed 's/^# //;T;Q' | + sed 's/^## //;T;Q' | + sed '/^---/Q' +} + +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 + echo updating $h from $x + meta "$x" | + pandoc --css doc.css -f markdown -t html5 --toc > "$h" +} +# apply for x in *.md; do - t=$(stat -c %Y $x) - t=$(git log -n 1 --format=%ct $x) - d=$(LANG= date -d @$t +"%d %B %Y") - sed -i "s/^\( Date: *\).*/\1$d/" $x - markdown -f toc,autolink $x | fmd > ${x%%.md}.html + mkhtml $x done