This repository was archived by the owner on Jan 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.sh
executable file
·90 lines (74 loc) · 2.37 KB
/
build.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
#!/usr/bin/env bash
# Build the documentation.
#
# This script does the following:
#
# - Updates the mkdocs.yml to add:
# - site_url
# - markdown extension directives
# - theme directory
# - Builds the documentation.
# - Restores mkdocs.yml to its original state.
#
# The script should be copied to the `doc/` directory of your project,
# and run from the project root.
#
# @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
# @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd -P)"
function help() {
echo "Usage:"
echo " ${0} [options]"
echo "Options:"
echo " -h Usage help; this message."
echo " -u <url> Deplyment URL of documentation (to ensure search works)"
}
while getopts hu: option;do
case "${option}" in
h) help && exit 0;;
u) SITE_URL=${OPTARG};;
esac
done
cp mkdocs.yml mkdocs.yml.orig
DOCS_DIR=$(php ${SCRIPT_PATH}/discover_doc_dir.php)
DOC_DIR=$(dirname ${DOCS_DIR})
# Update the mkdocs.yml
echo "Building documentation in ${DOC_DIR}"
${SCRIPT_PATH}/update_mkdocs_yml.py ${SITE_URL} ${DOCS_DIR}
# Preserve files if necessary (as mkdocs build --clean removes all files)
if [ -e .zf-mkdoc-theme-preserve ]; then
mkdir .preserve
for PRESERVE in $(cat .zf-mkdoc-theme-preserve); do
cp ${DOC_DIR}/html/${PRESERVE} .preserve/
done
fi
# Find all fenced code blocks
echo "Find all fenced code blocks"
php ${SCRIPT_PATH}/fenced_code_before.php ${DOC_DIR}
mkdocs build --clean
# Restore mkdocs.yml
mv mkdocs.yml.orig mkdocs.yml
# Restore files if necessary
if [ -e .zf-mkdoc-theme-preserve ]; then
for PRESERVE in $(cat .zf-mkdoc-theme-preserve); do
mv .preserve/${PRESERVE} ${DOC_DIR}/html/${PRESERVE}
done
rm -Rf ./preserve
fi
# Make images responsive
echo "Making images responsive"
php ${SCRIPT_PATH}/img_responsive.php ${DOC_DIR}
# Make tables responsive
echo "Making tables responsive"
php ${SCRIPT_PATH}/table_responsive.php ${DOC_DIR}
# Fix pipes in tables
echo "Fixing pipes in tables"
php ${SCRIPT_PATH}/table_fix_pipes.php ${DOC_DIR}
# Fix fenced code blocks
echo "Fixing fenced code blocks"
php ${SCRIPT_PATH}/fenced_code.php ${DOC_DIR}
# Replace landing page content
if [ -e .zf-mkdoc-theme-landing ]; then
echo "Replacing landing page content"
php ${SCRIPT_PATH}/swap_index.php ${DOC_DIR}
fi