-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgenerate-docs
executable file
·82 lines (63 loc) · 2.63 KB
/
generate-docs
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
#!/bin/bash
# ----- Check for dependencies
JAZZY=$(which jazzy)
if [ $? != 0 ]; then
echo -e "Jazzy is required to generate documentation. Install it with:\n"
echo -e " gem install jazzy\n"
exit
fi
echo "Using jazzy: $JAZZY"
# ----- Commandline options
if [ "$BRANCH" == "" ]; then
BRANCH=$([ "$1" == "" ] && echo "master" || echo "$1")
fi
if [ "$OUTPUT_PATH" == "" ]; then
OUTPUT_PATH=$([ "$2" == "" ] && echo "Docs/output/$BRANCH" || echo "$2")
fi
# ----- Configuration
ORGANISATION=ReSwift
NAME=ReactiveReSwift
TMP=Docs/tmp
GITHUB=https://github.com/$ORGANISATION/$NAME
URL=http://$ORGANISATION.github.io/$NAME
PREPROC=.scripts/doc-preprocessor
# ----- Setup and generate docs
# Clean $TMP folder
if [ -d "$TMP" ]; then rm -rf "$TMP"; fi
mkdir -p $TMP/{compile,docs,api}
cp Docs/*.md $TMP/api/
# Split the README into sections
$PREPROC README.md "$TMP/docs/About ReactiveReSwift.md" --section "About ReactiveReSwift" --title "About ReactiveReSwift"
$PREPROC README.md "$TMP/docs/Why ReactiveReSwift.md" --section "Why ReactiveReSwift?" --title "Why ReactiveReSwift?"
$PREPROC README.md "$TMP/docs/Installation.md" --section "Installation" --title "Installation"
$PREPROC README.md "$TMP/docs/Reactive Extensions.md" --section "Reactive Extensions" --title "Reactive Extensions"
$PREPROC README.md "$TMP/docs/Example Projects.md" --section "Example Projects" --title "Example Projects"
$PREPROC README.md "$TMP/docs/Credits.md" --section "Credits" --title "Credits"
$PREPROC README.md "$TMP/docs/Get in touch.md" --section "Get in touch" --title "Get in touch"
$PREPROC README.md "$TMP/compile/intro.md" --section "Introduction"
# Copy remaining root docs
$PREPROC CONTRIBUTING.md "$TMP/docs/Contributing.md"
$PREPROC CHANGELOG.md "$TMP/docs/Changelog.md" --title "Changelog"
$PREPROC LICENSE.md "$TMP/docs/License.md" --title "License"
# Copy over the Getting started guide
$PREPROC "Docs/Getting Started Guide.md" "$TMP/docs/Getting Started Guide.md"
# Create the documentation landing page by combining:
#
# - Docs/templates/heading.md
# - README.md#introduction
# - Docs/templates/toc.md
#
cat Docs/templates/heading.md $TMP/compile/intro.md Docs/templates/toc.md > $TMP/compile/readme-raw.md
$PREPROC "$TMP/compile/readme-raw.md" "$TMP/compile/README.md"
cp $TMP/compile/README.md $TMP/api/Documentation.md
# Compile our Docs/tmp + generate API docs using jazzy
jazzy \
--config .jazzy.json \
--clean \
--output "$OUTPUT_PATH" \
--module-version "$BRANCH" \
--dash_url "$URL/$BRANCH/docsets/$NAME.xml" \
--root-url "$URL/$BRANCH/" \
--github_url "$GITHUB" \
--github-file-prefix "$GITHUB/tree/$BRANCH"
cp Docs/img/* $OUTPUT_PATH/img/