incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hermw...@apache.org
Subject [12/38] docs commit: Update lib/ references from Cordova to PhoneGap.
Date Thu, 05 Apr 2012 19:02:11 GMT
Update lib/ references from Cordova to PhoneGap.


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/21e511f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/21e511f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/21e511f7

Branch: refs/heads/master
Commit: 21e511f761bde3ca7fa70049c63e5aac5adf1993
Parents: 09f25a4
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Thu Mar 29 15:24:56 2012 -0700
Committer: hermwong <herm.wong@gmail.com>
Committed: Thu Apr 5 10:52:04 2012 -0700

----------------------------------------------------------------------
 lib/cordova/add_title.rb                |   19 ++++++++
 lib/cordova/file_merger.rb              |   47 ++++++++++++++++++
 lib/cordova/jodoc.rb                    |   51 ++++++++++++++++++++
 lib/cordova/navigation_menu.rb          |   61 ++++++++++++++++++++++++
 lib/cordova/prettify.rb                 |   16 ++++++
 lib/cordova/quirks_merger.rb            |   48 +++++++++++++++++++
 lib/cordova/table_of_contents.rb        |   59 +++++++++++++++++++++++
 lib/cordova/update_index.rb             |   29 +++++++++++
 lib/cordova/update_keyword_index.rb     |   34 +++++++++++++
 lib/cordova/version_menu.rb             |   65 ++++++++++++++++++++++++++
 lib/cordova/yaml_front_matter.rb        |   26 ++++++++++
 lib/docs_generator.rb                   |    4 +-
 lib/phonegap/add_title.rb               |   19 --------
 lib/phonegap/file_merger.rb             |   47 ------------------
 lib/phonegap/jodoc.rb                   |   51 --------------------
 lib/phonegap/navigation_menu.rb         |   61 ------------------------
 lib/phonegap/prettify.rb                |   16 ------
 lib/phonegap/quirks_merger.rb           |   47 ------------------
 lib/phonegap/table_of_contents.rb       |   59 -----------------------
 lib/phonegap/update_index.rb            |   29 -----------
 lib/phonegap/update_keyword_index.rb    |   34 -------------
 lib/phonegap/version_menu.rb            |   65 --------------------------
 lib/phonegap/yaml_front_matter.rb       |   26 ----------
 spec/phonegap/add_title_spec.rb         |    2 +-
 spec/phonegap/prettify_spec.rb          |    2 +-
 spec/phonegap/table_of_contents_spec.rb |    2 +-
 spec/spec_helpers.rb                    |    2 +-
 27 files changed, 461 insertions(+), 460 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/add_title.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/add_title.rb b/lib/cordova/add_title.rb
new file mode 100644
index 0000000..10aae9a
--- /dev/null
+++ b/lib/cordova/add_title.rb
@@ -0,0 +1,19 @@
+require 'rubygems'
+require 'nokogiri'
+
+class AddTitle
+  def run(filename)
+    doc = Nokogiri::HTML(File.read(filename))
+    
+    title_source = doc.css('#content > h1')[0]
+    return nil if title_source.nil?
+    
+    title_target = doc.css('#subheader > h1')[0]
+    return nil if title_target.nil?
+    
+    title_target.content = title_source.content
+    File.open(filename, 'w') { |file| file.write doc.to_html }
+    
+    return title_source.content
+  end
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/file_merger.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/file_merger.rb b/lib/cordova/file_merger.rb
new file mode 100644
index 0000000..1508698
--- /dev/null
+++ b/lib/cordova/file_merger.rb
@@ -0,0 +1,47 @@
+require 'fileutils'
+require 'rubygems'
+require 'json'
+
+class FileMerger
+  def initialize
+  end
+
+  def run(file_path)
+    # partial files are deleted after being merged, so they may not exist
+    return unless File.exists? file_path
+    
+    root_name = File.basename file_path
+    @root_dir ||= File.dirname file_path
+    @json     ||= config_json(@root_dir)['merge']
+
+    @json.each do |name, files| 
+      if name == root_name
+        File.open file_path, 'a' do |file|
+          files.each do |filename|
+            # skip the file that is opened for appending
+            next if File.basename(filename) == root_name
+
+            filename = File.join @root_dir, filename
+            next unless file_exists? filename
+
+            file.write "\n\n---\n"
+            file.write File.read(filename).strip
+            FileUtils.rm filename unless name == File.basename(filename)
+          end
+        end
+      end
+    end
+  end
+
+  def config_json(basename)
+      file = File.join basename, 'config.json'
+      return JSON.parse IO.read(file)
+  end
+
+  def file_exists?(file_path)
+    return true if File.exists? file_path
+
+    puts "Missing: #{file_path}"
+    return false
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/jodoc.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/jodoc.rb b/lib/cordova/jodoc.rb
new file mode 100644
index 0000000..19c63b4
--- /dev/null
+++ b/lib/cordova/jodoc.rb
@@ -0,0 +1,51 @@
+class JoDoc
+  JO_DOC_CLI    = 'jodoc'
+  TEMPLATE_PATH = File.expand_path File.join(File.dirname(__FILE__), '..', '..', 'template',
'docs' )
+  
+  attr_accessor :input_directory
+  attr_accessor :output_directory
+  
+  def initialize(input_directory, output_directory, options)
+    @input_directory      = input_directory
+    @output_directory     = output_directory
+    @template_directories = [ File.join TEMPLATE_PATH, 'default' ]
+
+    # add custom language template
+    if options[:lang]
+      @template_directories.push(File.join TEMPLATE_PATH, options[:lang])
+    end
+
+    check_dependencies
+  end
+  
+  def run
+    # Copy HTML template assets
+    @template_directories.each do |template|
+      next unless File.directory? template
+      FileUtils.cp_r File.join(template, '.'), @output_directory
+    end
+
+    # Run joDoc
+    FileUtils.cd @input_directory do
+        `jodoc --output #{@output_directory} --title "Cordova API Documentation" --template
#{@output_directory}/index.html ./ 2> /dev/null`
+    end
+  end
+  
+  protected
+  
+  def check_dependencies
+    die 'The jodoc script is not in your path' unless command_exists?(JO_DOC_CLI)
+
+    [@input_directory, @template_directories[0]].each do |directory|
+      die "The directory #{directory}/ should exist." unless File.directory? directory
+    end
+  end
+  
+  def command_exists?(command)
+    system("which #{command} > /dev/null 2> /dev/null")
+  end
+  
+  def die(message)
+    raise StandardError, message
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/navigation_menu.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/navigation_menu.rb b/lib/cordova/navigation_menu.rb
new file mode 100644
index 0000000..14cdd5b
--- /dev/null
+++ b/lib/cordova/navigation_menu.rb
@@ -0,0 +1,61 @@
+$: << File.join(File.dirname(__FILE__))
+require 'rubygems'
+require 'nokogiri'
+require 'fileutils'
+require 'file_helpers'
+
+class NavigationMenu
+  include FileHelpers
+
+  def initialize(options = {})
+    @sections = []
+
+    filename = Dir.glob(File.join tmp_directory, '**', 'index.md.html')[0]
+    doc     = Nokogiri::HTML(File.read(filename))
+
+    h1_set   = doc.css('#home > h1')
+    ul_set   = doc.css('#home > ul')
+    count    = h1_set.length
+
+    count.times do |index|
+      links = []
+      ul_set[index].css('li > h2 > a').each { |a| links.push(a) }
+
+      @sections.push({
+        'title' => h1_set[index].text,
+        'links' => links
+      })
+    end
+  end
+
+  def run(filename)
+    doc = Nokogiri::HTML(File.read(filename))
+
+    @sections.each do |section|
+      insert_title(section['title'], doc)
+      insert_links(section['links'], doc)
+    end
+
+    File.open(filename, 'w') { |file| file.write doc.to_html }
+
+    return doc.to_html
+  end
+
+  def insert_title(title, doc)
+    h1 = Nokogiri::XML::Node.new 'h1', doc
+    h1.content = title
+    doc.css('#sidebar').first.add_child(h1)
+  end
+
+  def insert_links(links, doc)
+    ul = Nokogiri::XML::Node.new 'ul', doc
+
+    links.each do |link|
+      li = Nokogiri::XML::Node.new 'li', doc
+      li.add_child(link)
+      ul.add_child(li)
+    end
+
+    doc.css('#sidebar').first.add_child(ul)
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/prettify.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/prettify.rb b/lib/cordova/prettify.rb
new file mode 100644
index 0000000..d34bb72
--- /dev/null
+++ b/lib/cordova/prettify.rb
@@ -0,0 +1,16 @@
+require 'rubygems'
+require 'nokogiri'
+
+class Prettify
+  def run(filename)
+    doc = Nokogiri::HTML(File.read(filename))
+    
+    code_tags = doc.css('#content pre').each do |tag|
+      tag['class'] = 'prettyprint'
+    end
+
+    File.open(filename, 'w') { |file| file.write doc.to_html }
+    
+    return code_tags
+  end
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/quirks_merger.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/quirks_merger.rb b/lib/cordova/quirks_merger.rb
new file mode 100644
index 0000000..bdaee95
--- /dev/null
+++ b/lib/cordova/quirks_merger.rb
@@ -0,0 +1,48 @@
+require 'fileutils'
+
+class QuirksMerger
+  attr_accessor :cordova_path
+  
+  def run(file_path)
+    @cordova_path = nil
+    
+    platform_directory = find_directory_containing(file_path, 'phonegap')
+    platform_directory = find_directory_containing(file_path, 'cordova') if platform_directory.nil?
+    return if platform_directory.nil?
+    return if ['phonegap', 'cordova'].include?(File.basename(platform_directory).downcase)
+    
+    @cordova_path = generate_cordova_path(file_path, platform_directory)
+    return unless File.file? @cordova_path
+    
+    cordova_data = File.read(@cordova_path).strip
+    partial_data  = File.read(file_path).strip
+
+    File.open(@cordova_path, 'w') { |file| file.write(cordova_data + "\n\n" + partial_data)
}
+    FileUtils.rm file_path
+  end
+  
+  protected
+  
+  def find_directory_containing(directory, directory_to_find)
+    platform_name = nil
+    
+    until File.exists? File.join(directory, directory_to_find)
+      return nil if File.dirname(directory) == directory
+      
+      platform_name = File.basename(directory)
+      directory     = File.dirname(directory)
+    end
+    
+    File.join directory, platform_name
+  end
+  
+  def generate_cordova_path(full_path, platform_path)
+    path = {
+      :prefix   => File.dirname(platform_path),
+      :platform => File.basename(platform_path),
+      :postfix  => full_path.sub(platform_path, '')
+    }
+    
+    "#{path[:prefix]}/#{path[:platform]}/#{path[:postfix]}".gsub(/\/+/, '/')
+  end
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/table_of_contents.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/table_of_contents.rb b/lib/cordova/table_of_contents.rb
new file mode 100644
index 0000000..4e62270
--- /dev/null
+++ b/lib/cordova/table_of_contents.rb
@@ -0,0 +1,59 @@
+require 'rubygems'
+require 'nokogiri'
+require 'uri'
+
+class TableOfContents
+  def run(filename)
+    doc        = Nokogiri::HTML(File.read(filename))
+    option_set = Nokogiri::XML::NodeSet.new(doc)
+    
+    # Find all the H1 and H2 elements in the content area
+    #
+    current_h1  = ""
+    indentation = "&nbsp;" * 6
+    
+    doc.xpath("id('content')/h1 | id('content')/h2").each do |tag| 
+      if (tag.name == 'h1' && tag.child[:name]) then
+        current_h1 = tag.content
+
+        option = Nokogiri::XML::Node.new 'option', doc
+        option['value'] = URI.escape(tag.child[:name])
+        option.content = tag.content
+        option_set.push option
+      else
+        # Remove all leading and trailing non-word characters
+        # Replace all inner non-word characters with an underscore
+        s = tag.content.gsub(/^\W+|\W+$/, '').gsub(/\W+/, '_').downcase
+
+        option = Nokogiri::XML::Node.new 'option', doc
+        option['value'] = URI.escape("#{current_h1}_#{s}")
+        option.content = "#{indentation}- #{tag.content}"
+        option_set.push option
+
+        a = Nokogiri::XML::Node.new 'a', doc
+        a['name'] = "#{current_h1}_#{s}"
+        a.content = tag.content
+
+        tag.content = ''
+        tag.add_child a
+      end
+    end
+    
+    # Return if one or less elments found (useless selection box)
+    #
+    return nil if option_set.length <= 1
+    
+    # Add select menu to the subheader
+    #
+    select = Nokogiri::XML::Node.new 'select', doc
+    select.add_child option_set
+    subheader = doc.css('#subheader > small')[0]
+    subheader.add_child select
+    
+    # Save Table of Contents
+    # Add Nokogiri hack to properly render spaces
+    File.open(filename, 'w') { |file| file.write doc.to_html.gsub('&amp;nbsp;', '&nbsp;')
}
+    
+    return option_set
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/update_index.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/update_index.rb b/lib/cordova/update_index.rb
new file mode 100644
index 0000000..28b38f9
--- /dev/null
+++ b/lib/cordova/update_index.rb
@@ -0,0 +1,29 @@
+require 'rubygems'
+require 'nokogiri'
+require 'fileutils'
+
+class UpdateIndex
+  attr_accessor :header_title
+  attr_accessor :filename
+  
+  def initialize
+    @input_filename  = 'index.md.html'
+    @output_filename = 'index.html'
+    @header_title    = 'Home'
+  end
+  
+  def run(filename)
+    return false unless File.basename(filename) == @input_filename
+    
+    doc = Nokogiri::HTML(File.read(filename))
+    
+    element = doc.css('#subheader > h1')[0]
+    element.content = @header_title unless element.nil?
+    
+    File.open(filename, 'w') { |file| file.write doc.to_html }
+    
+    FileUtils.mv(filename, File.join(File.dirname(filename), @output_filename))
+    
+    return true
+  end
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/update_keyword_index.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/update_keyword_index.rb b/lib/cordova/update_keyword_index.rb
new file mode 100644
index 0000000..3e3643a
--- /dev/null
+++ b/lib/cordova/update_keyword_index.rb
@@ -0,0 +1,34 @@
+require 'rubygems'
+require 'nokogiri'
+require 'fileutils'
+
+class UpdateKeywordIndex
+  attr_accessor :header_title
+  attr_accessor :content_title
+  attr_accessor :filename
+  
+  def initialize
+    @header_title  = 'Keyword Index'
+    @content_title = 'Keyword Index'
+  end
+  
+  def run(filename)
+    return false unless File.basename(filename) == '_index.html'
+
+    doc = Nokogiri::HTML(File.read(filename))
+    
+    element = doc.css('#subheader > h1')[0]
+    element.content = @header_title unless element.nil?
+    
+    element = doc.css('#content > h1')[0]
+    element.content = @content_title unless element.nil?
+    
+    element = doc.css('#content > hr')[0]
+    element.remove unless element.nil?
+    
+    # Update referenced to index.md.html
+    # Then save
+    File.open(filename, 'w') { |file| file.write doc.to_html.gsub('"index.md.html', '"index.html')
}
+    return true
+  end
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/version_menu.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/version_menu.rb b/lib/cordova/version_menu.rb
new file mode 100644
index 0000000..24ba19f
--- /dev/null
+++ b/lib/cordova/version_menu.rb
@@ -0,0 +1,65 @@
+require 'rubygems'
+require 'json'
+require 'nokogiri'
+require 'fileutils'
+
+class VersionMenu
+  def initialize(options = {})
+      @version  = options[:version]
+      @language = options[:lang]
+  end
+
+  def run(filename)
+    doc = Nokogiri::HTML(File.read(filename))
+
+    select = doc.css('#header small select')[0]
+    select.add_child generate_set(doc)
+
+    File.open(filename, 'w') { |file| file.write doc.to_html }
+
+    return doc.to_html
+  end
+
+  private
+
+  def generate_set doc
+    optgroup_set = Nokogiri::XML::NodeSet.new doc
+    docs_path    = File.expand_path File.join(__FILE__, '..', '..', '..', 'docs')
+    versions     = {}
+    languages    = {}
+    html         = []
+
+    # build hash of languages and versions
+    Dir.glob(File.join docs_path, '**', 'config.json').each do |file|
+      version  = File.basename(File.dirname file)
+      lang     = File.basename(File.dirname(File.dirname file))
+      language = JSON.parse(IO.read(file))['language']
+
+      if language
+        versions[language] ||= []
+        versions[language].push version
+        languages[language] = lang
+      else
+        puts "Warning: The key 'language' was not defined in #{file}"
+      end
+    end
+
+    # generate HTML <select> output
+    versions.keys.sort.each do |language|
+      optgroup = Nokogiri::XML::Node.new 'optgroup', doc
+      optgroup['label'] = language
+      optgroup['value'] = languages[language]
+      optgroup_set.push optgroup
+
+      versions[language].sort.reverse.each do |v|
+        option = Nokogiri::XML::Node.new 'option', doc
+        option['selected'] = 'selected' if @version == v && @language == languages[language]
+        option['value'] = v;
+        option.content = v
+        optgroup.add_child option
+      end
+    end
+
+    return optgroup_set
+  end
+end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/cordova/yaml_front_matter.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/yaml_front_matter.rb b/lib/cordova/yaml_front_matter.rb
new file mode 100644
index 0000000..f86947c
--- /dev/null
+++ b/lib/cordova/yaml_front_matter.rb
@@ -0,0 +1,26 @@
+require 'yaml'
+
+class YamlFrontMatter
+  def initialize
+  end
+  
+  def run(file_path)
+    content = IO.read(file_path)
+    yaml    = {}
+    
+    # This will also strip out any leading whitespace
+    # Copied the RegEx from [Jekyll](http://github.com/mojombo/jekyll)
+    #
+    if content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
+      content = content[($1.size + $2.size)..-1]
+      yaml    = YAML.load($1)
+      
+      # Save the file
+      File.open(file_path, 'w+') do |file|
+        file.write content
+      end
+    end
+    
+    yaml
+  end
+end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/docs_generator.rb
----------------------------------------------------------------------
diff --git a/lib/docs_generator.rb b/lib/docs_generator.rb
index d2d529b..9eeb852 100644
--- a/lib/docs_generator.rb
+++ b/lib/docs_generator.rb
@@ -1,5 +1,5 @@
 $: << File.join(File.dirname(__FILE__))
-$: << File.join(File.dirname(__FILE__), 'phonegap')
+$: << File.join(File.dirname(__FILE__), 'cordova')
 require 'file_helpers'
 require 'yaml_front_matter'
 require 'quirks_merger'
@@ -26,7 +26,7 @@ class DocsGenerator
     @working_directory = File.join tmp_directory, 'docs'
   end
   
-  # PhoneGap Build-Time Steps
+  # Cordova Build-Time Steps
   #   - For each version of the documentation
   #     - Create a work space for the docs processing
   #     - Pre-file processing

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/add_title.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/add_title.rb b/lib/phonegap/add_title.rb
deleted file mode 100644
index 10aae9a..0000000
--- a/lib/phonegap/add_title.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'rubygems'
-require 'nokogiri'
-
-class AddTitle
-  def run(filename)
-    doc = Nokogiri::HTML(File.read(filename))
-    
-    title_source = doc.css('#content > h1')[0]
-    return nil if title_source.nil?
-    
-    title_target = doc.css('#subheader > h1')[0]
-    return nil if title_target.nil?
-    
-    title_target.content = title_source.content
-    File.open(filename, 'w') { |file| file.write doc.to_html }
-    
-    return title_source.content
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/file_merger.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/file_merger.rb b/lib/phonegap/file_merger.rb
deleted file mode 100644
index 1508698..0000000
--- a/lib/phonegap/file_merger.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'fileutils'
-require 'rubygems'
-require 'json'
-
-class FileMerger
-  def initialize
-  end
-
-  def run(file_path)
-    # partial files are deleted after being merged, so they may not exist
-    return unless File.exists? file_path
-    
-    root_name = File.basename file_path
-    @root_dir ||= File.dirname file_path
-    @json     ||= config_json(@root_dir)['merge']
-
-    @json.each do |name, files| 
-      if name == root_name
-        File.open file_path, 'a' do |file|
-          files.each do |filename|
-            # skip the file that is opened for appending
-            next if File.basename(filename) == root_name
-
-            filename = File.join @root_dir, filename
-            next unless file_exists? filename
-
-            file.write "\n\n---\n"
-            file.write File.read(filename).strip
-            FileUtils.rm filename unless name == File.basename(filename)
-          end
-        end
-      end
-    end
-  end
-
-  def config_json(basename)
-      file = File.join basename, 'config.json'
-      return JSON.parse IO.read(file)
-  end
-
-  def file_exists?(file_path)
-    return true if File.exists? file_path
-
-    puts "Missing: #{file_path}"
-    return false
-  end
-end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/jodoc.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/jodoc.rb b/lib/phonegap/jodoc.rb
deleted file mode 100644
index 19c63b4..0000000
--- a/lib/phonegap/jodoc.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-class JoDoc
-  JO_DOC_CLI    = 'jodoc'
-  TEMPLATE_PATH = File.expand_path File.join(File.dirname(__FILE__), '..', '..', 'template',
'docs' )
-  
-  attr_accessor :input_directory
-  attr_accessor :output_directory
-  
-  def initialize(input_directory, output_directory, options)
-    @input_directory      = input_directory
-    @output_directory     = output_directory
-    @template_directories = [ File.join TEMPLATE_PATH, 'default' ]
-
-    # add custom language template
-    if options[:lang]
-      @template_directories.push(File.join TEMPLATE_PATH, options[:lang])
-    end
-
-    check_dependencies
-  end
-  
-  def run
-    # Copy HTML template assets
-    @template_directories.each do |template|
-      next unless File.directory? template
-      FileUtils.cp_r File.join(template, '.'), @output_directory
-    end
-
-    # Run joDoc
-    FileUtils.cd @input_directory do
-        `jodoc --output #{@output_directory} --title "Cordova API Documentation" --template
#{@output_directory}/index.html ./ 2> /dev/null`
-    end
-  end
-  
-  protected
-  
-  def check_dependencies
-    die 'The jodoc script is not in your path' unless command_exists?(JO_DOC_CLI)
-
-    [@input_directory, @template_directories[0]].each do |directory|
-      die "The directory #{directory}/ should exist." unless File.directory? directory
-    end
-  end
-  
-  def command_exists?(command)
-    system("which #{command} > /dev/null 2> /dev/null")
-  end
-  
-  def die(message)
-    raise StandardError, message
-  end
-end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/navigation_menu.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/navigation_menu.rb b/lib/phonegap/navigation_menu.rb
deleted file mode 100644
index 14cdd5b..0000000
--- a/lib/phonegap/navigation_menu.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-$: << File.join(File.dirname(__FILE__))
-require 'rubygems'
-require 'nokogiri'
-require 'fileutils'
-require 'file_helpers'
-
-class NavigationMenu
-  include FileHelpers
-
-  def initialize(options = {})
-    @sections = []
-
-    filename = Dir.glob(File.join tmp_directory, '**', 'index.md.html')[0]
-    doc     = Nokogiri::HTML(File.read(filename))
-
-    h1_set   = doc.css('#home > h1')
-    ul_set   = doc.css('#home > ul')
-    count    = h1_set.length
-
-    count.times do |index|
-      links = []
-      ul_set[index].css('li > h2 > a').each { |a| links.push(a) }
-
-      @sections.push({
-        'title' => h1_set[index].text,
-        'links' => links
-      })
-    end
-  end
-
-  def run(filename)
-    doc = Nokogiri::HTML(File.read(filename))
-
-    @sections.each do |section|
-      insert_title(section['title'], doc)
-      insert_links(section['links'], doc)
-    end
-
-    File.open(filename, 'w') { |file| file.write doc.to_html }
-
-    return doc.to_html
-  end
-
-  def insert_title(title, doc)
-    h1 = Nokogiri::XML::Node.new 'h1', doc
-    h1.content = title
-    doc.css('#sidebar').first.add_child(h1)
-  end
-
-  def insert_links(links, doc)
-    ul = Nokogiri::XML::Node.new 'ul', doc
-
-    links.each do |link|
-      li = Nokogiri::XML::Node.new 'li', doc
-      li.add_child(link)
-      ul.add_child(li)
-    end
-
-    doc.css('#sidebar').first.add_child(ul)
-  end
-end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/prettify.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/prettify.rb b/lib/phonegap/prettify.rb
deleted file mode 100644
index d34bb72..0000000
--- a/lib/phonegap/prettify.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'rubygems'
-require 'nokogiri'
-
-class Prettify
-  def run(filename)
-    doc = Nokogiri::HTML(File.read(filename))
-    
-    code_tags = doc.css('#content pre').each do |tag|
-      tag['class'] = 'prettyprint'
-    end
-
-    File.open(filename, 'w') { |file| file.write doc.to_html }
-    
-    return code_tags
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/quirks_merger.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/quirks_merger.rb b/lib/phonegap/quirks_merger.rb
deleted file mode 100644
index f582069..0000000
--- a/lib/phonegap/quirks_merger.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'fileutils'
-
-class QuirksMerger
-  attr_accessor :phonegap_path
-  
-  def run(file_path)
-    @phonegap_path = nil
-    
-    platform_directory = find_directory_containing(file_path, 'phonegap')
-    return if platform_directory.nil?
-    return if File.basename(platform_directory).downcase == 'phonegap'
-    
-    @phonegap_path = generate_phonegap_path(file_path, platform_directory)
-    return unless File.file? @phonegap_path
-    
-    phonegap_data = File.read(@phonegap_path).strip
-    partial_data  = File.read(file_path).strip
-
-    File.open(@phonegap_path, 'w') { |file| file.write(phonegap_data + "\n\n" + partial_data)
}
-    FileUtils.rm file_path
-  end
-  
-  protected
-  
-  def find_directory_containing(directory, directory_to_find)
-    platform_name = nil
-    
-    until File.exists? File.join(directory, directory_to_find)
-      return nil if File.dirname(directory) == directory
-      
-      platform_name = File.basename(directory)
-      directory     = File.dirname(directory)
-    end
-    
-    File.join directory, platform_name
-  end
-  
-  def generate_phonegap_path(full_path, platform_path)
-    path = {
-      :prefix   => File.dirname(platform_path),
-      :platform => File.basename(platform_path),
-      :postfix  => full_path.sub(platform_path, '')
-    }
-    
-    "#{path[:prefix]}/phonegap/#{path[:postfix]}".gsub(/\/+/, '/')
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/table_of_contents.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/table_of_contents.rb b/lib/phonegap/table_of_contents.rb
deleted file mode 100644
index 4e62270..0000000
--- a/lib/phonegap/table_of_contents.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'rubygems'
-require 'nokogiri'
-require 'uri'
-
-class TableOfContents
-  def run(filename)
-    doc        = Nokogiri::HTML(File.read(filename))
-    option_set = Nokogiri::XML::NodeSet.new(doc)
-    
-    # Find all the H1 and H2 elements in the content area
-    #
-    current_h1  = ""
-    indentation = "&nbsp;" * 6
-    
-    doc.xpath("id('content')/h1 | id('content')/h2").each do |tag| 
-      if (tag.name == 'h1' && tag.child[:name]) then
-        current_h1 = tag.content
-
-        option = Nokogiri::XML::Node.new 'option', doc
-        option['value'] = URI.escape(tag.child[:name])
-        option.content = tag.content
-        option_set.push option
-      else
-        # Remove all leading and trailing non-word characters
-        # Replace all inner non-word characters with an underscore
-        s = tag.content.gsub(/^\W+|\W+$/, '').gsub(/\W+/, '_').downcase
-
-        option = Nokogiri::XML::Node.new 'option', doc
-        option['value'] = URI.escape("#{current_h1}_#{s}")
-        option.content = "#{indentation}- #{tag.content}"
-        option_set.push option
-
-        a = Nokogiri::XML::Node.new 'a', doc
-        a['name'] = "#{current_h1}_#{s}"
-        a.content = tag.content
-
-        tag.content = ''
-        tag.add_child a
-      end
-    end
-    
-    # Return if one or less elments found (useless selection box)
-    #
-    return nil if option_set.length <= 1
-    
-    # Add select menu to the subheader
-    #
-    select = Nokogiri::XML::Node.new 'select', doc
-    select.add_child option_set
-    subheader = doc.css('#subheader > small')[0]
-    subheader.add_child select
-    
-    # Save Table of Contents
-    # Add Nokogiri hack to properly render spaces
-    File.open(filename, 'w') { |file| file.write doc.to_html.gsub('&amp;nbsp;', '&nbsp;')
}
-    
-    return option_set
-  end
-end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/update_index.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/update_index.rb b/lib/phonegap/update_index.rb
deleted file mode 100644
index 28b38f9..0000000
--- a/lib/phonegap/update_index.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require 'rubygems'
-require 'nokogiri'
-require 'fileutils'
-
-class UpdateIndex
-  attr_accessor :header_title
-  attr_accessor :filename
-  
-  def initialize
-    @input_filename  = 'index.md.html'
-    @output_filename = 'index.html'
-    @header_title    = 'Home'
-  end
-  
-  def run(filename)
-    return false unless File.basename(filename) == @input_filename
-    
-    doc = Nokogiri::HTML(File.read(filename))
-    
-    element = doc.css('#subheader > h1')[0]
-    element.content = @header_title unless element.nil?
-    
-    File.open(filename, 'w') { |file| file.write doc.to_html }
-    
-    FileUtils.mv(filename, File.join(File.dirname(filename), @output_filename))
-    
-    return true
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/update_keyword_index.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/update_keyword_index.rb b/lib/phonegap/update_keyword_index.rb
deleted file mode 100644
index 3e3643a..0000000
--- a/lib/phonegap/update_keyword_index.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'rubygems'
-require 'nokogiri'
-require 'fileutils'
-
-class UpdateKeywordIndex
-  attr_accessor :header_title
-  attr_accessor :content_title
-  attr_accessor :filename
-  
-  def initialize
-    @header_title  = 'Keyword Index'
-    @content_title = 'Keyword Index'
-  end
-  
-  def run(filename)
-    return false unless File.basename(filename) == '_index.html'
-
-    doc = Nokogiri::HTML(File.read(filename))
-    
-    element = doc.css('#subheader > h1')[0]
-    element.content = @header_title unless element.nil?
-    
-    element = doc.css('#content > h1')[0]
-    element.content = @content_title unless element.nil?
-    
-    element = doc.css('#content > hr')[0]
-    element.remove unless element.nil?
-    
-    # Update referenced to index.md.html
-    # Then save
-    File.open(filename, 'w') { |file| file.write doc.to_html.gsub('"index.md.html', '"index.html')
}
-    return true
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/version_menu.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/version_menu.rb b/lib/phonegap/version_menu.rb
deleted file mode 100644
index 24ba19f..0000000
--- a/lib/phonegap/version_menu.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require 'rubygems'
-require 'json'
-require 'nokogiri'
-require 'fileutils'
-
-class VersionMenu
-  def initialize(options = {})
-      @version  = options[:version]
-      @language = options[:lang]
-  end
-
-  def run(filename)
-    doc = Nokogiri::HTML(File.read(filename))
-
-    select = doc.css('#header small select')[0]
-    select.add_child generate_set(doc)
-
-    File.open(filename, 'w') { |file| file.write doc.to_html }
-
-    return doc.to_html
-  end
-
-  private
-
-  def generate_set doc
-    optgroup_set = Nokogiri::XML::NodeSet.new doc
-    docs_path    = File.expand_path File.join(__FILE__, '..', '..', '..', 'docs')
-    versions     = {}
-    languages    = {}
-    html         = []
-
-    # build hash of languages and versions
-    Dir.glob(File.join docs_path, '**', 'config.json').each do |file|
-      version  = File.basename(File.dirname file)
-      lang     = File.basename(File.dirname(File.dirname file))
-      language = JSON.parse(IO.read(file))['language']
-
-      if language
-        versions[language] ||= []
-        versions[language].push version
-        languages[language] = lang
-      else
-        puts "Warning: The key 'language' was not defined in #{file}"
-      end
-    end
-
-    # generate HTML <select> output
-    versions.keys.sort.each do |language|
-      optgroup = Nokogiri::XML::Node.new 'optgroup', doc
-      optgroup['label'] = language
-      optgroup['value'] = languages[language]
-      optgroup_set.push optgroup
-
-      versions[language].sort.reverse.each do |v|
-        option = Nokogiri::XML::Node.new 'option', doc
-        option['selected'] = 'selected' if @version == v && @language == languages[language]
-        option['value'] = v;
-        option.content = v
-        optgroup.add_child option
-      end
-    end
-
-    return optgroup_set
-  end
-end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/lib/phonegap/yaml_front_matter.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/yaml_front_matter.rb b/lib/phonegap/yaml_front_matter.rb
deleted file mode 100644
index f86947c..0000000
--- a/lib/phonegap/yaml_front_matter.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'yaml'
-
-class YamlFrontMatter
-  def initialize
-  end
-  
-  def run(file_path)
-    content = IO.read(file_path)
-    yaml    = {}
-    
-    # This will also strip out any leading whitespace
-    # Copied the RegEx from [Jekyll](http://github.com/mojombo/jekyll)
-    #
-    if content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
-      content = content[($1.size + $2.size)..-1]
-      yaml    = YAML.load($1)
-      
-      # Save the file
-      File.open(file_path, 'w+') do |file|
-        file.write content
-      end
-    end
-    
-    yaml
-  end
-end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/spec/phonegap/add_title_spec.rb
----------------------------------------------------------------------
diff --git a/spec/phonegap/add_title_spec.rb b/spec/phonegap/add_title_spec.rb
index 33e0788..0f87870 100644
--- a/spec/phonegap/add_title_spec.rb
+++ b/spec/phonegap/add_title_spec.rb
@@ -1,5 +1,5 @@
 $: << File.join(File.dirname(__FILE__), '..')
-$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'phonegap')
+$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'cordova')
 require 'spec_helpers'
 require 'add_title'
 require 'nokogiri'  # Nokogiri may not be the best way to test this suite. Any thoughts?

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/spec/phonegap/prettify_spec.rb
----------------------------------------------------------------------
diff --git a/spec/phonegap/prettify_spec.rb b/spec/phonegap/prettify_spec.rb
index b9564e4..b31cb51 100644
--- a/spec/phonegap/prettify_spec.rb
+++ b/spec/phonegap/prettify_spec.rb
@@ -1,5 +1,5 @@
 $: << File.join(File.dirname(__FILE__), '..', '..', 'lib')
-$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'phonegap')
+$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'cordova')
 require 'prettify'
 require 'spec_helpers'
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/spec/phonegap/table_of_contents_spec.rb
----------------------------------------------------------------------
diff --git a/spec/phonegap/table_of_contents_spec.rb b/spec/phonegap/table_of_contents_spec.rb
index 205f808..2105672 100644
--- a/spec/phonegap/table_of_contents_spec.rb
+++ b/spec/phonegap/table_of_contents_spec.rb
@@ -1,5 +1,5 @@
 $: << File.join(File.dirname(__FILE__), '..', '..', 'lib')
-$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'phonegap')
+$: << File.join(File.dirname(__FILE__), '..', '..', 'lib', 'cordova')
 require 'table_of_contents'
 require 'spec_helpers'
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/21e511f7/spec/spec_helpers.rb
----------------------------------------------------------------------
diff --git a/spec/spec_helpers.rb b/spec/spec_helpers.rb
index 23aa3a1..da9952a 100644
--- a/spec/spec_helpers.rb
+++ b/spec/spec_helpers.rb
@@ -1,5 +1,5 @@
 $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
-$:.unshift File.join(File.dirname(__FILE__), '..', 'lib', 'phonegap')
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib', 'cordova')
 require 'file_helpers'
 require 'fileutils'
 


Mime
View raw message