Update build script references of PhoneGap to Cordova.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/09f25a4b Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/09f25a4b Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/09f25a4b Branch: refs/heads/master Commit: 09f25a4bce2fb408b92b9d593faf07294f9231ac Parents: 15ada35 Author: Michael Brooks <mich...@michaelbrooks.ca> Authored: Thu Mar 29 14:52:15 2012 -0700 Committer: hermwong <herm.w...@gmail.com> Committed: Thu Apr 5 10:52:04 2012 -0700 ---------------------------------------------------------------------- bin/generate | 8 ++-- lib/docs_generator.rb | 97 ++++++++++++++++++++++++++++++++++++++ lib/phonegap_docs.rb | 97 -------------------------------------- spec/docs_generator_spec.rb | 32 ++++++++++++ spec/phonegap/jodoc_spec.rb | 2 +- spec/phonegap_docs_spec.rb | 32 ------------ 6 files changed, 134 insertions(+), 134 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/09f25a4b/bin/generate ---------------------------------------------------------------------- diff --git a/bin/generate b/bin/generate index b473960..b2af2fa 100755 --- a/bin/generate +++ b/bin/generate @@ -1,8 +1,8 @@ #!/usr/bin/env ruby $: << File.join(File.dirname(__FILE__), '..', 'lib') -require 'phonegap_docs' +require 'docs_generator' -phonegap_docs = PhoneGapDocs.new -phonegap_docs.run +generator = DocsGenerator.new +generator.run -puts " => #{phonegap_docs.output_directory}" +puts " => #{generator.output_directory}" http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/09f25a4b/lib/docs_generator.rb ---------------------------------------------------------------------- diff --git a/lib/docs_generator.rb b/lib/docs_generator.rb new file mode 100644 index 0000000..d2d529b --- /dev/null +++ b/lib/docs_generator.rb @@ -0,0 +1,97 @@ +$: << File.join(File.dirname(__FILE__)) +$: << File.join(File.dirname(__FILE__), 'phonegap') +require 'file_helpers' +require 'yaml_front_matter' +require 'quirks_merger' +require 'file_merger' +require 'add_title' +require 'update_index' +require 'update_keyword_index' +require 'jodoc' +require 'fileutils' +require 'table_of_contents' +require 'version_menu' +require 'navigation_menu' +require 'prettify' + +class DocsGenerator + include FileHelpers + + attr_accessor :input_directory + attr_accessor :output_directory + + def initialize(input_directory = nil, output_directory = nil) + @input_directory = input_directory || default_input_directory + @output_directory = output_directory || default_output_directory + @working_directory = File.join tmp_directory, 'docs' + end + + # PhoneGap Build-Time Steps + # - For each version of the documentation + # - Create a work space for the docs processing + # - Pre-file processing + # - Run joDoc + # - Pre-file processing + # - Release and cleanup + # + def run + empty_output_directory + + ignore_list = ['.', '..', '.DS_Store'] + + Dir.foreach @input_directory do |language_dir| + next if ignore_list.include? language_dir + language_path = File.join @input_directory, language_dir + + Dir.foreach language_path do |version_dir| + next if ignore_list.include? version_dir + output_path = File.join @output_directory, language_dir, version_dir + input_path = File.join @input_directory, language_dir, version_dir + options = { :lang => language_dir, :version => version_dir } + next unless File.directory? input_path + + copy_directory(input_path, @working_directory) + + puts " => Generating the Cordova Documentation for #{version_dir}-#{language_dir}..." + generated_path = after_jodoc(jodocify(before_jodoc(@working_directory, options), options), options) + + move_directory(generated_path, output_path) + empty_tmp_directory + end + end + end + + protected + + def before_jodoc(input_directory, options) + klasses = [ YamlFrontMatter.new, QuirksMerger.new, FileMerger.new ] + + klasses.each do |klass| + each_file input_directory do |file| + next if file.match(/\/guide\//) # do not process the guides + klass.run file + end + end + + input_directory + end + + def jodocify(input_directory, options) + output_directory = File.join tmp_directory, 'jodoc' + JoDoc.new(input_directory, output_directory, options).run + + output_directory + end + + def after_jodoc(input_directory, options) + klasses = [ AddTitle.new, UpdateIndex.new, UpdateKeywordIndex.new, TableOfContents.new, VersionMenu.new(options), NavigationMenu.new(options), Prettify.new ] + + klasses.each do |klass| + each_file input_directory do |file| + klass.run file + end + end + + input_directory + end +end http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/09f25a4b/lib/phonegap_docs.rb ---------------------------------------------------------------------- diff --git a/lib/phonegap_docs.rb b/lib/phonegap_docs.rb deleted file mode 100644 index 543a5a1..0000000 --- a/lib/phonegap_docs.rb +++ /dev/null @@ -1,97 +0,0 @@ -$: << File.join(File.dirname(__FILE__)) -$: << File.join(File.dirname(__FILE__), 'phonegap') -require 'file_helpers' -require 'yaml_front_matter' -require 'quirks_merger' -require 'file_merger' -require 'add_title' -require 'update_index' -require 'update_keyword_index' -require 'jodoc' -require 'fileutils' -require 'table_of_contents' -require 'version_menu' -require 'navigation_menu' -require 'prettify' - -class PhoneGapDocs - include FileHelpers - - attr_accessor :input_directory - attr_accessor :output_directory - - def initialize(input_directory = nil, output_directory = nil) - @input_directory = input_directory || default_input_directory - @output_directory = output_directory || default_output_directory - @working_directory = File.join tmp_directory, 'docs' - end - - # PhoneGap Build-Time Steps - # - For each version of the documentation - # - Create a work space for the docs processing - # - Pre-file processing - # - Run joDoc - # - Pre-file processing - # - Release and cleanup - # - def run - empty_output_directory - - ignore_list = ['.', '..', '.DS_Store'] - - Dir.foreach @input_directory do |language_dir| - next if ignore_list.include? language_dir - language_path = File.join @input_directory, language_dir - - Dir.foreach language_path do |version_dir| - next if ignore_list.include? version_dir - output_path = File.join @output_directory, language_dir, version_dir - input_path = File.join @input_directory, language_dir, version_dir - options = { :lang => language_dir, :version => version_dir } - next unless File.directory? input_path - - copy_directory(input_path, @working_directory) - - puts " => Generating the Cordova Documentation for #{version_dir}-#{language_dir}..." - generated_path = after_jodoc(jodocify(before_jodoc(@working_directory, options), options), options) - - move_directory(generated_path, output_path) - empty_tmp_directory - end - end - end - - protected - - def before_jodoc(input_directory, options) - klasses = [ YamlFrontMatter.new, QuirksMerger.new, FileMerger.new ] - - klasses.each do |klass| - each_file input_directory do |file| - next if file.match(/\/guide\//) # do not process the guides - klass.run file - end - end - - input_directory - end - - def jodocify(input_directory, options) - output_directory = File.join tmp_directory, 'jodoc' - JoDoc.new(input_directory, output_directory, options).run - - output_directory - end - - def after_jodoc(input_directory, options) - klasses = [ AddTitle.new, UpdateIndex.new, UpdateKeywordIndex.new, TableOfContents.new, VersionMenu.new(options), NavigationMenu.new(options), Prettify.new ] - - klasses.each do |klass| - each_file input_directory do |file| - klass.run file - end - end - - input_directory - end -end http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/09f25a4b/spec/docs_generator_spec.rb ---------------------------------------------------------------------- diff --git a/spec/docs_generator_spec.rb b/spec/docs_generator_spec.rb new file mode 100644 index 0000000..22d6a3f --- /dev/null +++ b/spec/docs_generator_spec.rb @@ -0,0 +1,32 @@ +$:.unshift File.join(File.dirname(__FILE__)) +require 'spec_helpers' +require 'docs_generator' + +describe DocsGenerator do + before :each do + @tmp_docs_directory = Helper::create_tmp_directory_assets + @tmp_public_directory = Helper::tmp_public_directory + @generator = DocsGenerator.new(@tmp_docs_directory, Helper::tmp_public_directory) + end + + it 'should create an output directory' do + @generator.run + File.exists?(@tmp_public_directory).should be_true + Dir.glob(File.join(@tmp_public_directory, '**', '*')).should have_at_least(1).items + end + + it 'should have a valid default directories' do + generator = DocsGenerator.new + File.exists?(generator.input_directory).should be_true + end + + it 'should accept custom directories' do + @generator.run + @generator.input_directory.should == @tmp_docs_directory + @generator.output_directory.should == @tmp_public_directory + end + + after :all do + Helper::remove_tmp_directory + end +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/09f25a4b/spec/phonegap/jodoc_spec.rb ---------------------------------------------------------------------- diff --git a/spec/phonegap/jodoc_spec.rb b/spec/phonegap/jodoc_spec.rb index 5a03552..34fd899 100644 --- a/spec/phonegap/jodoc_spec.rb +++ b/spec/phonegap/jodoc_spec.rb @@ -5,7 +5,7 @@ require 'jodoc' describe JoDoc do before :all do @tmp_public_directory = Helper::tmp_public_directory - PhoneGapDocs.new(Helper::create_tmp_directory_assets, @tmp_public_directory).run + DocsGenerator.new(Helper::create_tmp_directory_assets, @tmp_public_directory).run end it 'should run on a validate directory' do http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/09f25a4b/spec/phonegap_docs_spec.rb ---------------------------------------------------------------------- diff --git a/spec/phonegap_docs_spec.rb b/spec/phonegap_docs_spec.rb deleted file mode 100644 index cf0f095..0000000 --- a/spec/phonegap_docs_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -$:.unshift File.join(File.dirname(__FILE__)) -require 'spec_helpers' -require 'phonegap_docs' - -describe PhoneGapDocs do - before :each do - @tmp_docs_directory = Helper::create_tmp_directory_assets - @tmp_public_directory = Helper::tmp_public_directory - @phonegap_docs = PhoneGapDocs.new(@tmp_docs_directory, Helper::tmp_public_directory) - end - - it 'should create an output directory' do - @phonegap_docs.run - File.exists?(@tmp_public_directory).should be_true - Dir.glob(File.join(@tmp_public_directory, '**', '*')).should have_at_least(1).items - end - - it 'should have a valid default directories' do - phonegap_docs = PhoneGapDocs.new - File.exists?(phonegap_docs.input_directory).should be_true - end - - it 'should accept custom directories' do - @phonegap_docs.run - @phonegap_docs.input_directory.should == @tmp_docs_directory - @phonegap_docs.output_directory.should == @tmp_public_directory - end - - after :all do - Helper::remove_tmp_directory - end -end \ No newline at end of file