From a9d77a20008efe82862cc1adbfa7a6d4f09f8ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Menou?= Date: Thu, 8 Dec 2016 10:19:15 +0200 Subject: Release code as open source --- scripts/documentation-versioning.sh | 125 ++++++++++++++++++++++++++++++++++++ scripts/scaffolder.sh | 29 +++++++++ 2 files changed, 154 insertions(+) create mode 100755 scripts/documentation-versioning.sh create mode 100755 scripts/scaffolder.sh (limited to 'scripts') diff --git a/scripts/documentation-versioning.sh b/scripts/documentation-versioning.sh new file mode 100755 index 0000000..a5ffd2a --- /dev/null +++ b/scripts/documentation-versioning.sh @@ -0,0 +1,125 @@ +#!/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" diff --git a/scripts/scaffolder.sh b/scripts/scaffolder.sh new file mode 100755 index 0000000..a7121f7 --- /dev/null +++ b/scripts/scaffolder.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +HERE="$(dirname "$0")" + +REVISION="D96A" +if [ -n "$1" ] +then + REVISION=$1 + shift 1 +fi + +function specification { + stack exec edi-parser-scaffolder -- \ + scaffold --revision "$REVISION" \ + --src "$HERE/../src" \ + --specification "$HERE/../specification" +} + +function missing { + echo "$1 is missing. Aborting." + exit 1 +} + +function checkRequirements { + command -v stylish-haskell > /dev/null || missing "stylish-haskell" +} + +checkRequirements +specification -- cgit v1.2.3