-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_docset.sh
executable file
·90 lines (77 loc) · 2.61 KB
/
create_docset.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
#!/bin/bash --
DOCSET_NAME="Gulp"
DOCUMENTATION_SRC="https://github.com/gulpjs/gulp.git"
# CREATE THE DOCSET FOLDER...
echo -e "$(tput setaf 2)--> Creating the folder structure$(tput sgr0)"
test -d ${DOCSET_NAME}.docset/Contents/Resources && rm -rf ${DOCSET_NAME}.docset/Contents/Resources 2>/dev/null >&2
mkdir -p ${DOCSET_NAME}.docset/Contents/Resources/Documents
cp icon.tiff ${DOCSET_NAME}.docset/
# DOWNLOAD THE DOCSET...
echo -e "$(tput setaf 2)--> Downloading the documentation of '$DOCSET_NAME'$(tput sgr0)"
git clone $DOCUMENTATION_SRC
mkdir -p gulp_docs && mv gulp/docs/* gulp_docs
cp style.css ${DOCSET_NAME}.docset/Contents/Resources/Documents/
mv gulp_docs/* ${DOCSET_NAME}.docset/Contents/Resources/Documents/
cd ${DOCSET_NAME}.docset/Contents/Resources/Documents/
for inputFile in `find . -type f \( -iname "*.md" \)`; do
strippedName=${inputFile%.*}
fullName="${strippedName#./}.html"
shortName=${strippedName##*/}
touch $fullName
echo $fullName
# Head
cat >> "$fullName" << HEAD
<!DOCTYPE html>
<html lang="es">
<head>
<title>$shortName</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css" />
</head>
<body>
HEAD
# HTML Content
cat $inputFile | markdown >> $fullName
# Tail
cat >> "$fullName" << TAIL
</body>
</html>
TAIL
rm -f $inputFile
done
cd ../../../..
# CLEAN
rm -rf gulp gulp_docs
# CREATE PROPERTY LIST...
echo -e "$(tput setaf 2)--> Creating the Property List$(tput sgr0)"
cat > "${DOCSET_NAME}.docset/Contents/Info.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>$DOCSET_NAME</string>
<key>CFBundleName</key>
<string>$DOCSET_NAME</string>
<key>DocSetPlatformFamily</key>
<string>$DOCSET_NAME</string>
<key>isDashDocset</key>
<true/>
<key>dashIndexFilePath</key>
<string>index.html</string>
<key>isJavaScriptEnabled</key>
<true/>
</dict>
</plist>
EOF
echo "$(tput setaf 2)Created 'Info.plist'$(tput sgr0)"
# PARSE & CLEAN THE HTML DOCUMENTATION. FILL THE DB...
#echo -e "$(tput setaf 2)--> Parsing the documentation...$(tput sgr0)"
#php phalcon_parser.php $DOCSET_NAME ${DOCSET_NAME}.docset/Contents/Resources/Documents
# OPEN THE DOCSET
if [ -d "$HOME/Library/Application Support/Dash/Docsets" ]; then
exit 0
#mkdir -p "$HOME/Library/Application Support/Dash/Docsets/$DOCSET_NAME"
#mv -f "${DOCSET_NAME}.docset" "$HOME/Library/Application Support/Dash/Docsets/$DOCSET_NAME/"
#open -a "/Applications/Dash.app" $HOME/Library/Application\ Support/Dash/Docsets/${DOCSET_NAME}/${DOCSET_NAME}.docset
fi