Skip to content
This repository was archived by the owner on Jan 12, 2023. It is now read-only.

Commit e240575

Browse files
committed
Initial commit
0 parents  commit e240575

File tree

7 files changed

+104
-0
lines changed

7 files changed

+104
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_input
2+
_output

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# kotlin-docset
2+
3+
*kotlin-docset* is a docset for [Dash.app](http://kapeli.com/dash)
4+
containing the documentation for [Kotlin](http://kotlinlang.org).
5+
6+
The current docset only includes the Guides and not the API documentation
7+
since that will be [changed soon](http://kotlinlang.org/docs/api/index.html).
8+
9+
## Building the Docset
10+
11+
Just run `./fetch && ./generate` to download and build everything.
12+
The generated `Kotlin.docset` will be in the `_output` folder.

fetch

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
mkdir -p _input
6+
cd _input
7+
8+
FILES=(
9+
"js/page/reference.js"
10+
"js/vendor/jquery/jquery-1.11.0.min.js"
11+
"js/com/nav-tree.js"
12+
"js/util/render.js"
13+
"js/util/localStorage.js"
14+
)
15+
16+
for f in ${FILES[@]}
17+
do
18+
dir=`dirname $f`
19+
mkdir -p $dir
20+
wget -O $f http://kotlinlang.org/$f
21+
done
22+
23+
wget --mirror -k -nH http://kotlinlang.org/docs/reference/

generate

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
ROOT=_output/Kotlin.docset
6+
RESOURCES=$ROOT/Contents/Resources
7+
8+
rm -rf $ROOT
9+
mkdir -p $RESOURCES
10+
11+
cp src/Info.plist $ROOT/Contents/
12+
cp -r _input $RESOURCES/Documents
13+
cat src/overrides.css >> $RESOURCES/Documents/css/styles.css
14+
convert _input/assets/images/favicon.ico $ROOT/icon.png
15+
16+
pushd _input
17+
find . -name \*\.html | xargs -n 1 ruby ../src/index.rb | sqlite3 ../$RESOURCES/docSet.dsidx
18+
popd
19+
20+
cd _output
21+
tar \
22+
--exclude 'tutorials.*' \
23+
--exclude 'apple-touch-*.png' \
24+
--exclude='.DS_Store' \
25+
-cvzf Kotlin.tgz \
26+
Kotlin.docset

src/Info.plist

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleIdentifier</key>
6+
<string>kotlin</string>
7+
<key>CFBundleName</key>
8+
<string>Kotlin</string>
9+
<key>DocSetPlatformFamily</key>
10+
<string>kotlin</string>
11+
<key>dashIndexFilePath</key>
12+
<string>/docs/reference/index.html</string>
13+
<key>isDashDocset</key>
14+
<true/>
15+
</dict>
16+
</plist>

src/index.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'nokogiri'
2+
3+
file_name = ARGV.first
4+
doc = Nokogiri::HTML(ARGF.read)
5+
6+
puts 'CREATE TABLE IF NOT EXISTS searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);'
7+
puts 'CREATE UNIQUE INDEX IF NOT EXISTS anchor ON searchIndex (name, type, path);'
8+
9+
title = doc.css('head > title').first.content
10+
puts "INSERT INTO searchIndex VALUES (NULL, '#{title}', 'Guide', '#{file_name}');"

src/overrides.css

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
Dash DocSet Overrides
3+
*/
4+
5+
article, .g-layout {
6+
width: auto !important;
7+
}
8+
9+
.g-layout {
10+
padding: 20px !important;
11+
}
12+
13+
header, footer, aside, nav, .global-layout:after, .page-link-to-github {
14+
display: none !important;
15+
}

0 commit comments

Comments
 (0)