Skip to content

Commit 991eb34

Browse files
committed
Add Slate for documentation
1 parent c61bb65 commit 991eb34

34 files changed

+14674
-3
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ completely from the source of the data. Therefore it is possible to implement yo
1616
every possible data source. Doctrine ORM comes bundled already, we intend to provide popular choices like
1717
Elastica, Doctrine DBAL and MongoDB out of the box as well.
1818

19-
This library is near initial release, [only a few issues](https://github.com/omines/datatables-bundle/milestone/1)
20-
need to be resolved before a stable package will be tagged.
21-
2219
## Installation
2320

2421
To install, use composer:

docs/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*.gem
2+
*.rbc
3+
.bundle
4+
.config
5+
coverage
6+
InstalledFiles
7+
lib/bundler/man
8+
pkg
9+
rdoc
10+
spec/reports
11+
test/tmp
12+
test/version_tmp
13+
tmp
14+
*.DS_STORE
15+
build/
16+
.cache
17+
.vagrant
18+
.sass-cache
19+
20+
# YARD artifacts
21+
.yardoc
22+
_yardoc
23+
doc/
24+
.idea/

docs/config.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Unique header generation
2+
require './lib/unique_head.rb'
3+
4+
# Markdown
5+
set :markdown_engine, :redcarpet
6+
set :markdown,
7+
fenced_code_blocks: true,
8+
smartypants: true,
9+
disable_indented_code_blocks: true,
10+
prettify: true,
11+
tables: true,
12+
with_toc_data: true,
13+
no_intra_emphasis: true,
14+
renderer: UniqueHeadCounter
15+
16+
# Assets
17+
set :css_dir, 'stylesheets'
18+
set :js_dir, 'javascripts'
19+
set :images_dir, 'images'
20+
set :fonts_dir, 'fonts'
21+
22+
# Live reload
23+
activate :livereload
24+
25+
# Activate the syntax highlighter
26+
activate :syntax
27+
ready do
28+
require './lib/multilang.rb'
29+
end
30+
31+
activate :sprockets
32+
33+
activate :autoprefixer do |config|
34+
config.browsers = ['last 2 version', 'Firefox ESR']
35+
config.cascade = false
36+
config.inline = true
37+
end
38+
39+
# Github pages require relative links
40+
activate :relative_assets
41+
set :relative_links, true
42+
43+
# Build Configuration
44+
configure :build do
45+
# If you're having trouble with Middleman hanging, commenting
46+
# out the following two lines has been known to help
47+
activate :minify_css
48+
activate :minify_javascript
49+
# activate :relative_assets
50+
# activate :asset_hash
51+
# activate :gzip
52+
end
53+
54+
# Deploy Configuration
55+
# If you want Middleman to listen on a different port, you can set that below
56+
set :port, 4567
57+
58+
helpers do
59+
require './lib/toc_data.rb'
60+
end

docs/deploy.sh

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
#!/usr/bin/env bash
2+
set -o errexit #abort if any command fails
3+
me=$(basename "$0")
4+
5+
help_message="\
6+
Usage: $me [-c FILE] [<options>]
7+
Deploy generated files to a git branch.
8+
9+
Options:
10+
11+
-h, --help Show this help information.
12+
-v, --verbose Increase verbosity. Useful for debugging.
13+
-e, --allow-empty Allow deployment of an empty directory.
14+
-m, --message MESSAGE Specify the message used when committing on the
15+
deploy branch.
16+
-n, --no-hash Don't append the source commit's hash to the deploy
17+
commit's message.
18+
--source-only Only build but not push
19+
--push-only Only push but not build
20+
"
21+
22+
23+
run_build() {
24+
bundle exec middleman build --clean
25+
}
26+
27+
parse_args() {
28+
# Set args from a local environment file.
29+
if [ -e ".env" ]; then
30+
source .env
31+
fi
32+
33+
# Parse arg flags
34+
# If something is exposed as an environment variable, set/overwrite it
35+
# here. Otherwise, set/overwrite the internal variable instead.
36+
while : ; do
37+
if [[ $1 = "-h" || $1 = "--help" ]]; then
38+
echo "$help_message"
39+
return 0
40+
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
41+
verbose=true
42+
shift
43+
elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then
44+
allow_empty=true
45+
shift
46+
elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then
47+
commit_message=$2
48+
shift 2
49+
elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then
50+
GIT_DEPLOY_APPEND_HASH=false
51+
shift
52+
else
53+
break
54+
fi
55+
done
56+
57+
# Set internal option vars from the environment and arg flags. All internal
58+
# vars should be declared here, with sane defaults if applicable.
59+
60+
# Source directory & target branch.
61+
deploy_directory=build
62+
deploy_branch=gh-pages
63+
64+
#if no user identity is already set in the current git environment, use this:
65+
default_username=${GIT_DEPLOY_USERNAME:-deploy.sh}
66+
default_email=${GIT_DEPLOY_EMAIL:-}
67+
68+
#repository to deploy to. must be readable and writable.
69+
repo=origin
70+
71+
#append commit hash to the end of message by default
72+
append_hash=${GIT_DEPLOY_APPEND_HASH:-true}
73+
}
74+
75+
main() {
76+
parse_args "$@"
77+
78+
enable_expanded_output
79+
80+
if ! git diff --exit-code --quiet --cached; then
81+
echo Aborting due to uncommitted changes in the index >&2
82+
return 1
83+
fi
84+
85+
commit_title=`git log -n 1 --format="%s" HEAD`
86+
commit_hash=` git log -n 1 --format="%H" HEAD`
87+
88+
#default commit message uses last title if a custom one is not supplied
89+
if [[ -z $commit_message ]]; then
90+
commit_message="publish: $commit_title"
91+
fi
92+
93+
#append hash to commit message unless no hash flag was found
94+
if [ $append_hash = true ]; then
95+
commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash"
96+
fi
97+
98+
previous_branch=`git rev-parse --abbrev-ref HEAD`
99+
100+
if [ ! -d "$deploy_directory" ]; then
101+
echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2
102+
return 1
103+
fi
104+
105+
# must use short form of flag in ls for compatibility with OS X and BSD
106+
if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then
107+
echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2
108+
return 1
109+
fi
110+
111+
if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then
112+
# deploy_branch exists in $repo; make sure we have the latest version
113+
114+
disable_expanded_output
115+
git fetch --force $repo $deploy_branch:$deploy_branch
116+
enable_expanded_output
117+
fi
118+
119+
# check if deploy_branch exists locally
120+
if git show-ref --verify --quiet "refs/heads/$deploy_branch"
121+
then incremental_deploy
122+
else initial_deploy
123+
fi
124+
125+
restore_head
126+
}
127+
128+
initial_deploy() {
129+
git --work-tree "$deploy_directory" checkout --orphan $deploy_branch
130+
git --work-tree "$deploy_directory" add --all
131+
commit+push
132+
}
133+
134+
incremental_deploy() {
135+
#make deploy_branch the current branch
136+
git symbolic-ref HEAD refs/heads/$deploy_branch
137+
#put the previously committed contents of deploy_branch into the index
138+
git --work-tree "$deploy_directory" reset --mixed --quiet
139+
git --work-tree "$deploy_directory" add --all
140+
141+
set +o errexit
142+
diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$?
143+
set -o errexit
144+
case $diff in
145+
0) echo No changes to files in $deploy_directory. Skipping commit.;;
146+
1) commit+push;;
147+
*)
148+
echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2
149+
return $diff
150+
;;
151+
esac
152+
}
153+
154+
commit+push() {
155+
set_user_id
156+
git --work-tree "$deploy_directory" commit -m "$commit_message"
157+
158+
disable_expanded_output
159+
#--quiet is important here to avoid outputting the repo URL, which may contain a secret token
160+
git push --quiet $repo $deploy_branch
161+
enable_expanded_output
162+
}
163+
164+
#echo expanded commands as they are executed (for debugging)
165+
enable_expanded_output() {
166+
if [ $verbose ]; then
167+
set -o xtrace
168+
set +o verbose
169+
fi
170+
}
171+
172+
#this is used to avoid outputting the repo URL, which may contain a secret token
173+
disable_expanded_output() {
174+
if [ $verbose ]; then
175+
set +o xtrace
176+
set -o verbose
177+
fi
178+
}
179+
180+
set_user_id() {
181+
if [[ -z `git config user.name` ]]; then
182+
git config user.name "$default_username"
183+
fi
184+
if [[ -z `git config user.email` ]]; then
185+
git config user.email "$default_email"
186+
fi
187+
}
188+
189+
restore_head() {
190+
if [[ $previous_branch = "HEAD" ]]; then
191+
#we weren't on any branch before, so just set HEAD back to the commit it was on
192+
git update-ref --no-deref HEAD $commit_hash $deploy_branch
193+
else
194+
git symbolic-ref HEAD refs/heads/$previous_branch
195+
fi
196+
197+
git reset --mixed
198+
}
199+
200+
filter() {
201+
sed -e "s|$repo|\$repo|g"
202+
}
203+
204+
sanitize() {
205+
"$@" 2> >(filter 1>&2) | filter
206+
}
207+
208+
if [[ $1 = --source-only ]]; then
209+
run_build
210+
elif [[ $1 = --push-only ]]; then
211+
main "$@"
212+
else
213+
run_build
214+
main "$@"
215+
fi

0 commit comments

Comments
 (0)