#!/usr/bin/env bash # This is the initial commit of this project. # This is useful to list content of the first tagged version. rootCommit="c468e930cf7f15c709bf8890f197135a62858f16" function parentTag { local tag=$1 git describe --abbrev=0 --tags "${tag}^" 2>/dev/null || echo "${rootCommit}" } function prettyLogUndocumentedTag { local tag=$1; cat <<-HTML

(${tag}) Not generated

HTML } function gitAuthor { local tag="$1" git log -n1 --pretty="%an" "${tag}" } function linkToTaggedDocumentation { local tag="$1" cat <<-HTML HTML } function contentOfTaggedDocumentation { local tag=$1; local content content=$(git log --pretty="%ad | %h | %s" --date=short "$(parentTag "${tag}")..${tag}") echo "
${content}
" } function prettyLogTag { local tag=$1 cat <<-HTML
$(linkToTaggedDocumentation "${tag}")
$(contentOfTaggedDocumentation "${tag}")
HTML } function formatTags { local webRoot="$1" while read -r tag do if [ -d "${webRoot}/${tag}" ] then prettyLogTag "$tag" else prettyLogUndocumentedTag "$tag" fi done } function listTags { git tag --list "v20??-??-??" --sort="-refname" } function generateIndex { local webRoot="$1" cat <<-HTML

Available documentations


$(listTags | formatTags "${webRoot}")
HTML } function generateDoc { local webRoot="$1" local currentTag="$2" local docRoot="$3" local tagWebRoot="${webRoot}/${currentTag}" if [[ -z "$webRoot" ]] then echo "Undefined webRoot directory" exit 1 fi if [[ -z "$currentTag" ]] then echo "Undefined current tag" exit 1 fi if [[ -z "$docRoot" ]] then echo "Undefined documentation root" exit 1 fi echo "Documentation root: ${docRoot}" mkdir -p "${webRoot}"; cp -r "${docRoot}" "${tagWebRoot}" generateIndex "${webRoot}" > "${webRoot}/index.html" } generateDoc "$1" "$2" "$3"