Skip to content
Browse files

Moved sdoc generation script into sublime text plugin

  • Loading branch information...
1 parent d92732e commit fbf94f8521aa0664dc77df1e8c8cd2ed175eb09d @ndbroadbent committed
Showing with 3 additions and 116 deletions.
  1. +3 −3 _shared_bin/functions.sh
  2. +0 −98 bin/generate_sdoc
  3. +0 −15 schedule.rb
View
6 _shared_bin/functions.sh
@@ -14,9 +14,9 @@ rvmrc_or_default() {
if type rvm > /dev/null 2>&1; then
# Use .rvmrc, or default ruby
if [ -e .rvmrc ]; then
- # Quit if ruby version not installed.
- if ! source .rvmrc; then
- echo "Aborting: source .rvmrc failed!"
+ if ! . .rvmrc; then
+ # Quit if ruby version not installed.
+ echo "Aborting: . .rvmrc failed!"
exit
fi
else
View
98 bin/generate_sdoc
@@ -1,98 +0,0 @@
-#!/bin/bash
-source "$DOTFILES_PATH/_shared_bin/functions.sh"
-REVISION_FILE=".sdoc_revision~"
-
-abort_if_revision_unchanged "$REVISION_FILE"
-
-# Project must contain a Gemfile
-if ! [ -e Gemfile ]; then exit; fi
-
-rvmrc_or_default
-
-# Ensure sdoc gem is installed
-ensure_gem sdoc
-
-echo "Generating sdoc for $(pwd)..."
-echo "--------------------------------------------------------------------------------"
-
-project_name="$(basename $(pwd))"
-
-mkdir -p "$HOME/.sdoc/rubies/" "$HOME/.sdoc/gems/$RUBY_VERSION/"
-sdoc_paths=""
-sdoc_names=""
-
-# Build sdoc for the current project
-# ----------------------------------------------------------------
-sdoc --op "./tmp/sdoc"
-sdoc_names+="$project_name,"
-sdoc_paths+="./tmp/sdoc "
-
-# Build sdoc for current Ruby version (unless already generated)
-# ----------------------------------------------------------------
-ruby_rvm_dir="$HOME/.rvm/src/$RUBY_VERSION/"
-ruby_sdoc_dir="$HOME/.sdoc/rubies/$RUBY_VERSION"
-if ! [ -e "$ruby_sdoc_dir/index.html" ]; then
- $(
- cd "$ruby_rvm_dir"
- if ! sdoc --op "$ruby_sdoc_dir"; then
- echo "Could not generate sdoc for $RUBY_VERSION! Aborting..."
- exit 1
- fi
- )
-else
- echo "sdoc already generated for $RUBY_VERSION"
-fi
-
-sdoc_names+="ruby (${RUBY_VERSION#ruby-}),"
-sdoc_paths+="$ruby_sdoc_dir "
-
-# Fetch the list of required gems
-required_gems=$(bundle list | sed 1d | sed "s/\s*\* \([^ ]*\) (\([^) ]*\).*/\1-\2/")
-
-function add_gem_and_sdoc_path_if_index(){
- if [ -e "$sdoc_dir/index.html" ]; then
- gem_name=$(echo $1 | sed 's/\(.*\)-\([^-]*\)$/\1 (\2)/')
- sdoc_names+="$gem_name,"
- sdoc_paths+="$2 "
- fi
-}
-
-# Build sdoc for each gem (unless already generated)
-# ----------------------------------------------------------------
-for gem in $required_gems; do
- rvm_dir="$HOME/.rvm/gems/$RUBY_VERSION/gems/$gem"
- sdoc_dir="$HOME/.sdoc/gems/$RUBY_VERSION/$gem"
-
- if ! [ -e "$sdoc_dir/.sdoc_generated" ]; then
- if [ -d "$rvm_dir" ]; then
- if [ -e "$HOME/.sdoc/ignored_gems" ]; then
- # Skip any ignored gems that cause problems with sdoc
- if grep -q "^$gem$" "$HOME/.sdoc/ignored_gems"; then
- echo "Skipping $gem - Ignored by ~/.sdoc/ignored_gems"
- break
- fi
- fi
-
- $(
- cd "$rvm_dir"
- echo "Generating sdoc for gem: $gem..."
- if sdoc --op "$sdoc_dir"; then
- touch "$sdoc_dir/.sdoc_generated"
- add_gem_and_sdoc_path_if_index $gem $sdoc_dir
- fi
- )
- fi
- else
- echo "sdoc already generated for gem: $gem"
- add_gem_and_sdoc_path_if_index $gem $sdoc_dir
- fi
-done
-
-# Merge all the generated sdocs together to provide complete project documentation
-mkdir -p "./tmp"
-pwd
-git_exclude "tmp/" # Always exclude tmp dir, even if not in .gitignore
-rm -rf "./tmp/sdoc-merged"
-sdoc-merge --title "$project_name" --op './tmp/sdoc-merged' --names "$sdoc_names" $sdoc_paths
-
-store_current_revision "$REVISION_FILE"
View
15 schedule.rb
@@ -41,19 +41,4 @@
# Cache rails commands for Rake, Capistrano, etc.
git_index "batch-cmd cache_rails_commands"
-end
-
-every 2.hours do
- # Only run one sdoc generation at a time.
- # The initial run for all your projects will take a really long time (a few hours),
- # but subsequent runs will be much shorter.
- # We need to use a lock file called GENERATING to ensure that tasks don't overlap.
-
- command <<-CMD.gsub(/\s{2,}/, ' ').strip
- mkdir -p $HOME/.sdoc &&
- ! [ -e $HOME/.sdoc/GENERATING ] &&
- touch $HOME/.sdoc/GENERATING &&
- git_index --batch-cmd generate_sdoc;
- rm -f $HOME/.sdoc/GENERATING
- CMD
end

0 comments on commit fbf94f8

Please sign in to comment.
Something went wrong with that request. Please try again.