Update Cordova documentation (6.3.1)

pull/481/head
Thibaut Courouble 9 years ago
parent 0ebd9fac8e
commit 818fa97bb0

@ -12,6 +12,7 @@ app.views.BootstrapPage =
app.views.CPage =
app.views.CakephpPage =
app.views.ChaiPage =
app.views.CordovaPage =
app.views.CrystalPage =
app.views.D3Page =
app.views.DrupalPage =

@ -40,6 +40,7 @@
'pages/cakephp',
'pages/clojure',
'pages/coffeescript',
'pages/cordova',
'pages/crystal',
'pages/d3',
'pages/dojo',

@ -40,6 +40,7 @@
'pages/cakephp',
'pages/clojure',
'pages/coffeescript',
'pages/cordova',
'pages/crystal',
'pages/d3',
'pages/dojo',

@ -0,0 +1,9 @@
._cordova {
@extend %simple;
.alert { @extend %note; }
.compat .n { background: pink; }
.compat .y { background: lightgreen; }
.compat .p { background: khaki; }
}

@ -19,7 +19,6 @@
._apache_pig,
._chai,
._cordova,
._docker,
._gnu,
._grunt,

@ -2,21 +2,31 @@ module Docs
class Cordova
class CleanHtmlFilter < Filter
def call
if root_page?
css('h1').each { |node| node.name = 'h2' }
css('li > h2').each { |node| node.name = 'div' }
end
@doc = at_css('.page-content > div')
at_css('h1').content = 'Apache Cordova' if root_page?
css('hr').remove
css('hr', '.content-header', 'button').remove
css('a[name]').each do |node|
node.parent['id'] = node['name']
css('.home', '#page-toc-source', '.highlight', 'th h2').each do |node|
node.before(node.children).remove
end
# Remove code highlighting
css('img[src*="travis-ci"]').each do |node|
node.ancestors('p').first.remove
end
css('pre').each do |node|
node.content = node.content.remove(/^\ {4,5}/)
node['data-language'] = node.at_css('code')['data-lang']
node.content = node.content.strip_heredoc
end
css('> .alert + h1').each do |node|
node.previous_element.before(node)
end
css('h1, h2, h3, h4, h5, h6').each do |node|
node['id'] = node.content.strip.parameterize
end
doc

@ -2,16 +2,56 @@ module Docs
class Cordova
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('h1').content.remove(' Guide')
return 'CLI' if slug == 'reference/cordova-cli/index'
name = at_css('#page-toc-source h1').content.strip
name.remove! ' Guide'
name
end
def get_type
if subpath.start_with?('guide/platforms')
name[/Amazon\ Fire\ OS|Android|BlackBerry|Firefox OS|iOS|Windows/] || 'Platform Guides'
elsif subpath.start_with?('cordova/events')
'Events'
return 'Platforms' if subpath.include?('guide/platforms/')
return 'Plugins' if name.start_with?('cordova-plugin')
at_css('.site-toc .this-page').ancestors('li').last.at_css('span').content
end
def additional_entries
case slug
when 'reference/cordova-cli/index'
css('#page-toc-source h2').each_with_object [] do |node, entries|
name = node.content.strip
id = name.parameterize
next unless name =~ /cordova .+ command/
name.remove! ' command'
entries << [name, id, 'Reference: CLI']
end
when 'config_ref/index'
namespace = ''
css('#page-toc-source > *').each_with_object [] do |node, entries|
case node.name
when 'h1'
name = node.content.strip
next unless name =~ /\A[a-z]+\z/
entries << ["<#{name}>", name.parameterize, 'Reference: config.xml']
when 'h2'
name = node.content.strip
next unless name =~ /\A[a-z]+\z/
namespace = name
entries << ["<#{name}>", name.parameterize, 'Reference: config.xml']
when 'h3'
name = node.content.strip
next unless name =~ /\A[a-z]+\z/
entries << ["<#{namespace}> <#{name}>", name.parameterize, 'Reference: config.xml']
end
end
when 'cordova/events/events'
css('#page-toc-source h2').each_with_object [] do |node, entries|
name = node.content.strip
id = name.parameterize
next unless name =~ /\A[a-z]+\z/
entries << [name, id, 'Reference: events']
end
else
'Guides'
[]
end
end
end

@ -2,23 +2,34 @@ module Docs
class Cordova < UrlScraper
self.name = 'Cordova'
self.type = 'cordova'
self.release = '6.0.0'
self.base_url = "https://cordova.apache.org/docs/en/#{release}/"
self.root_path = 'index.html'
self.root_path = 'guide/overview/index.html'
self.links = {
home: 'https://cordova.apache.org/'
}
html_filters.push 'cordova/clean_html', 'cordova/entries', 'title'
html_filters.push 'cordova/entries', 'cordova/clean_html'
options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page-toc-source' }
options[:title] = false
options[:root_title] = 'Apache Cordova'
options[:skip] = %w(page_index.html)
options[:container] = '.docs'
options[:skip] = %w(index.html)
options[:fix_urls] = ->(url) do
if url.include?('https://cordova.apache.org/docs') && !url.end_with?('.html')
if url.end_with?('/')
url << 'index.html'
else
url << '/index.html'
end
end
end
options[:attribution] = <<-HTML
&copy; 2012&ndash;2016 The Apache Software Foundation<br>
Licensed under the Apache License 2.0.
HTML
version '6' do
self.release = '6.3.1'
self.base_url = 'https://cordova.apache.org/docs/en/6.x/'
end
end
end

Loading…
Cancel
Save