-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_docs.sh
executable file
·105 lines (69 loc) · 2.01 KB
/
build_docs.sh
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
#!/bin/bash
# A tool to build the admin help pages for Grassroots
# Where we are reading the files from
ROOT=..
# The directory in which we will build the pages
OUTPUT_DIR=docs
# The name of the initial page that we are writing to
OUTPUT_FILE=${OUTPUT_DIR}/components.md
# $1 is the directory name that we're copying and building the docs for
# $2 is the markdown filename
BuildDocForContent ()
{
i=$2;
n=$( basename $( dirname "$i" ) );
n=${n/-/ };
to="$1/$( basename $( dirname "$i")).md";
echo "> i $i n $n to $to";
cp "$i" "${OUTPUT_DIR}/${to}";
c=$(tr '[:lower:]' '[:upper:]' <<<"${n:0:1}")
echo " * [($c${n:1})](${to})" >> ${OUTPUT_FILE};
}
NewBuildDocForContent ()
{
echo "> 1 $1 2 $2"
parent=$( basename "$2" )
mkdir -p ${OUTPUT_DIR}/$1/$parent
cp $2/*.md ${OUTPUT_DIR}/$1/$parent/;
n=$parent;
n=${n/-/ };
echo " * [${n^}](${OUTPUT_DIR}/$2/readme.md)" >> ${OUTPUT_FILE};
}
#
# $1 is the directory name that we're copying and building the docs for
# $2 is the heading used for the list of entries
BuildDocsForContent ()
{
mkdir -p ${OUTPUT_DIR}/$1
echo "" >> ${OUTPUT_FILE}
echo "## $2" >> ${OUTPUT_FILE}
if [[ $3 = "true" ]]; then
for i in ${ROOT}/$1/*;
do
if test -f $i/readme.md; then
NewBuildDocForContent $1 $i
fi
done
else
if test -f $i/readme.md; then
NewBuildDocForContent $1 ${ROOT}/$1
fi
fi
# find . -maxdepth 1 -mindepth 1 -name \*.md -a -not -name readme.md -exec cp -t ${OUTPUT_DIR} {} +
}
# Clear the output file
mkdir -p ${OUTPUT_DIR}
truncate -s 0 ${OUTPUT_FILE}
cat components_intro.md > ${OUTPUT_FILE}
BuildDocsForContent services Services true
BuildDocsForContent libs Libraries true
BuildDocsForContent lucene Lucene true
BuildDocsForContent servers Servers true
BuildDocsForContent clients Clients true
cp readme.md ${OUTPUT_DIR}/index.md
cp configuration.md ${OUTPUT_DIR}
cp examples.md ${OUTPUT_DIR}
cp schema.md ${OUTPUT_DIR}
cp service_configuration.md ${OUTPUT_DIR}
cp wizard.md ${OUTPUT_DIR}
cp federation.md ${OUTPUT_DIR}