blob: a5ffd2ac7c0c29ede4df3a57dda8ba9d488e8052 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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
<dt>
<h2>
(${tag}) Not generated
</h2>
</dt>
HTML
}
function gitAuthor {
local tag="$1"
git log -n1 --pretty="%an" "${tag}"
}
function linkToTaggedDocumentation {
local tag="$1"
cat <<-HTML
<a href="${tag}/index.html">
<button>
<small>Go to </small>
<strong>${tag}</strong>
<small> released by </small>
<strong>$(gitAuthor "${tag}")</strong>
</button>
</a>
HTML
}
function contentOfTaggedDocumentation {
local tag=$1;
local content
content=$(git log --pretty="%ad | %h | %s" --date=short "$(parentTag "${tag}")..${tag}")
echo "<pre>${content}</pre>"
}
function prettyLogTag {
local tag=$1
cat <<-HTML
<dt>$(linkToTaggedDocumentation "${tag}")</dt>
<dd>$(contentOfTaggedDocumentation "${tag}")</dd>
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
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/yegor256/tacit/gh-pages/tacit-css-1.3.4.min.css"/>
</head>
<body>
<section>
<article>
<h1>Available documentations</h1>
<hr>
<dl>
$(listTags | formatTags "${webRoot}")
</dl>
</section>
</article>
</section>
</body>
</html>
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"
|