-
Notifications
You must be signed in to change notification settings - Fork 322
/
Copy pathdocument.sh
executable file
·75 lines (58 loc) · 3.09 KB
/
document.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
#!/usr/bin/env bash
set -e
set -o pipefail
set -u
if [ -z `which jazzy` ]; then
echo "Installing jazzy…"
gem install jazzy
if [ -z `which jazzy` ]; then
echo "Unable to install jazzy. See https://github.com/mapbox/mapbox-gl-native-ios/blob/master/platform/ios/INSTALL.md"
exit 1
fi
fi
OUTPUT=${OUTPUT:-documentation}
BRANCH=$( git describe --tags --match=v*.*.* --abbrev=0 )
SHORT_VERSION=$( echo ${BRANCH} | sed 's/^v//' )
RELEASE_VERSION=$( echo ${SHORT_VERSION} | sed -e 's/-.*//' )
MINOR_VERSION=$( echo ${SHORT_VERSION} | grep -Eo '^\d+\.\d+' )
DEFAULT_THEME="docs/theme"
THEME=${JAZZY_THEME:-$DEFAULT_THEME}
BASE_URL="https://docs.mapbox.com/ios"
# Link to directions documentation
DIRECTIONS_VERSION=$(grep 'mapbox-directions-swift' Cartfile.resolved | grep -oE '"v.+?"' | grep -oE '[^"v]+')
DIRECTIONS_SYMBOLS="AttributeOptions|CoordinateBounds|Directions|DirectionsCredentials|DirectionsOptions|DirectionsPriority|DirectionsProfileIdentifier|DirectionsResult|Intersection|Lane|LaneIndication|MapMatchingResponse|Match|MatchOptions|RoadClasses|Route|RouteLeg|RouteOptions|RouteResponse|RouteStep|SpokenInstruction|Tracepoint|VisualInstruction|VisualInstruction.Component|VisualInstruction.Component.ImageRepresentation|VisualInstruction.Component.TextRepresentation|VisualInstructionBanner|Waypoint"
rm -rf ${OUTPUT}
mkdir -p ${OUTPUT}
cp -r docs/img "${OUTPUT}"
rm -rf /tmp/mbnavigation
mkdir -p /tmp/mbnavigation/
README=/tmp/mbnavigation/README.md
cp docs/cover.md "${README}"
perl -pi -e "s/\\$\\{MINOR_VERSION\\}/${MINOR_VERSION}/" "${README}"
# http://stackoverflow.com/a/4858011/4585461
echo "## Changes in version ${RELEASE_VERSION}" >> "${README}"
sed -n -e '/^## /{' -e ':a' -e 'n' -e '/^## /q' -e 'p' -e 'ba' -e '}' CHANGELOG.md >> "${README}"
# Blow away any includes of MapboxCoreNavigation, because
# MapboxNavigation-Documentation.podspec gloms the two targets into one.
# https://github.com/mapbox/mapbox-navigation-ios/issues/2363
find Sources/Mapbox{Core,}Navigation/ -name '*.swift' -exec \
perl -pi -e 's/\bMapboxCoreNavigation\b/MapboxNavigation/' {} \;
find Sources/Mapbox{Core,}Navigation/ -name '*.[hm]' -exec \
perl -pi -e 's/([<"])MapboxCoreNavigation\b/$1MapboxNavigation/' {} \;
jazzy \
--podspec MapboxNavigation-Documentation.podspec \
--config docs/jazzy.yml \
--sdk iphonesimulator \
--module-version ${SHORT_VERSION} \
--github-file-prefix "https://github.com/mapbox/mapbox-navigation-ios/tree/${BRANCH}" \
--readme ${README} \
--documentation="docs/guides/*.md" \
--root-url "${BASE_URL}/navigation/api/${RELEASE_VERSION}/" \
--theme ${THEME} \
--output ${OUTPUT} \
--module_version ${RELEASE_VERSION}
REPLACE_REGEXP='s/MapboxNavigation\s+(Docs|Reference)/Mapbox Navigation SDK for iOS $1/, '
REPLACE_REGEXP+="s/<span class=\"kt\">(${DIRECTIONS_SYMBOLS})<\/span>/<span class=\"kt\"><a href=\"${BASE_URL//\//\\/}\/directions\/api\/${DIRECTIONS_VERSION}\/Classes\/\$1.html\">\$1<\/a><\/span>/, "
find ${OUTPUT} -name *.html -exec \
perl -pi -e "$REPLACE_REGEXP" {} \;
echo $SHORT_VERSION > $OUTPUT/latest_version