This repository has been archived by the owner on Apr 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
93 lines (73 loc) · 2.34 KB
/
Jenkinsfile
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
pipeline {
agent any
stages {
stage('build') {
steps {
sh 'stack --nix build'
}
}
stage('docs') {
steps {
sh '''WEB_DIR=/srv/http/docs
function hsdoc {
srcdir=$(cabal-info hs-source-dirs)
hsfiles=$(cabal-info exposed-modules | sed -e "s:\\.:/:g" -e "s:$:.hs:")
otherfiles=$(cabal-info other-modules | sed -e "s:\\.:/:g" -e "s:$:.hs:")
name=$(cabal-info name)
version=$(cabal-info version)
synopsis=$(cabal-info synopsis)
dir=$1
url=$2
tmpdir=`mktemp -d`
# Highlight source
mkdir -p $dir/source
wget "https://raw.githubusercontent.com/houshuang/hackage-css/master/generated_css/tango.css" -O "$dir/source/hscolour.css"
for file in $hsfiles; do
HsColour "$srcdir/$file" -css -anchor \\
-o"$dir/source/`echo $file | sed "s:^\\(.*\\)\\.hs$:\\1:" | sed "s:/:-:g"`.html"
done
# Generate documentation
cabal-info description > "$tmpdir/description"
macros=$(find . -type f -wholename "./.stack-work/dist/*/autogen/cabal_macros.h")
find . -type f -wholename "./.stack-work/dist/*/autogen/*.hs" -exec cp "{}" . \\;
for file in $hsfiles; do
mkdir -p "$tmpdir/`dirname $file`"
efile="$tmpdir/`dirname $file`/`basename $file`"
cpphs "$srcdir/$file" -O"$efile" \\
--include="$macros" \\
--strip --strip-eol
done
for file in $otherfiles; do
mkdir -p "$tmpdir/`dirname $file`"
efile="$tmpdir/`dirname $file`/`basename $file`"
cpphs "$srcdir/$file" -O"$efile" \\
--include="$macros" \\
--strip --strip-eol
done
processedfiles=$(find "$tmpdir" -type f -name "*.hs")
hidefiles=$(cabal-info other-modules | sed "s:^:--hide=:" | tr "\\n" " ")
stack --nix exec -- \\
haddock $processedfiles -o "$dir" \\
--title="$name-$version: $synopsis" \\
--prologue="$tmpdir/description" \\
--html --built-in-themes \\
--source-module="$url/source/%{MODULE/./-}.html" \\
--source-entity="$url/source/%{MODULE/./-}.html#%N" \\
--source-entity-line="$url/source/%{MODULE/./-}.html#line-%L" \\
$hidefiles
# Clean up
rm -rf $tmpdir
}
docdir="$WEB_DIR/coco"
docweb="https://docs.barrucadu.co.uk/coco"
if [[ $BRANCH_NAME == "master" ]]; then
hsdoc $docdir $docweb
ln -sf $docdir "$docdir/master"
else
hsdoc "$docdir/$BRANCH_NAME" "$docweb/$BRANCH_NAME"
fi
chmod -R 755 $WEB_DIR'''
}
}
}
}