diff --git a/assets/javascripts/views/pages/simple.coffee b/assets/javascripts/views/pages/simple.coffee index b25e30c5..ebf9b694 100644 --- a/assets/javascripts/views/pages/simple.coffee +++ b/assets/javascripts/views/pages/simple.coffee @@ -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 = diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index ba6084a0..85cc67b9 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -40,6 +40,7 @@ 'pages/cakephp', 'pages/clojure', 'pages/coffeescript', + 'pages/cordova', 'pages/crystal', 'pages/d3', 'pages/dojo', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index bce9f41d..29ede327 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -40,6 +40,7 @@ 'pages/cakephp', 'pages/clojure', 'pages/coffeescript', + 'pages/cordova', 'pages/crystal', 'pages/d3', 'pages/dojo', diff --git a/assets/stylesheets/pages/_cordova.scss b/assets/stylesheets/pages/_cordova.scss new file mode 100644 index 00000000..01231ea6 --- /dev/null +++ b/assets/stylesheets/pages/_cordova.scss @@ -0,0 +1,9 @@ +._cordova { + @extend %simple; + + .alert { @extend %note; } + + .compat .n { background: pink; } + .compat .y { background: lightgreen; } + .compat .p { background: khaki; } +} diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index 7ea79cf1..23529107 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -19,7 +19,6 @@ ._apache_pig, ._chai, -._cordova, ._docker, ._gnu, ._grunt, diff --git a/lib/docs/filters/cordova/clean_html.rb b/lib/docs/filters/cordova/clean_html.rb index 01443ec3..fee86cea 100644 --- a/lib/docs/filters/cordova/clean_html.rb +++ b/lib/docs/filters/cordova/clean_html.rb @@ -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 diff --git a/lib/docs/filters/cordova/entries.rb b/lib/docs/filters/cordova/entries.rb index 86800cc5..0620c82a 100644 --- a/lib/docs/filters/cordova/entries.rb +++ b/lib/docs/filters/cordova/entries.rb @@ -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 diff --git a/lib/docs/scrapers/cordova.rb b/lib/docs/scrapers/cordova.rb index 04ec403d..cc9bf04b 100644 --- a/lib/docs/scrapers/cordova.rb +++ b/lib/docs/scrapers/cordova.rb @@ -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 © 2012–2016 The Apache Software Foundation
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