History

Update Cordova documentation (6.3.1)

Thibaut Courouble committed 10 years ago

Commit 818fa971 parent 0ebd9fa8 files · +96 −24Browse files

Unified · Split

8 files
  1. assets/javascripts/views/pages/simple.coffee +1 −0
  2. assets/stylesheets/application-dark.css.scss +1 −0
  3. assets/stylesheets/application.css.scss +1 −0
  4. assets/stylesheets/pages/_cordova.scss +9 −0
  5. assets/stylesheets/pages/_simple.scss +0 −1
  6. lib/docs/filters/cordova/clean_html.rb +19 −9
  7. lib/docs/filters/cordova/entries.rb +46 −6
  8. lib/docs/scrapers/cordova.rb +19 −8
assets/javascripts/views/pages/simple.coffee+1−0
@@ -12,6 +12,7 @@ app.views.BootstrapPage = · 11 unmodified lines
1212 app.views.CPage =
1313 app.views.CakephpPage =
1414 app.views.ChaiPage =
15+app.views.CordovaPage =
1516 app.views.CrystalPage =
1617 app.views.D3Page =
1718 app.views.DrupalPage =
assets/stylesheets/application-dark.css.scss+1−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 'pages/cakephp',
4141 'pages/clojure',
4242 'pages/coffeescript',
43+ 'pages/cordova',
4344 'pages/crystal',
4445 'pages/d3',
4546 'pages/dojo',
assets/stylesheets/application.css.scss+1−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 'pages/cakephp',
4141 'pages/clojure',
4242 'pages/coffeescript',
43+ 'pages/cordova',
4344 'pages/crystal',
4445 'pages/d3',
4546 'pages/dojo',
assets/stylesheets/pages/_cordova.scss+9−0
@@ -0,0 +1,9 @@
1+._cordova {
2+ @extend %simple;
3+
4+ .alert { @extend %note; }
5+
6+ .compat .n { background: pink; }
7+ .compat .y { background: lightgreen; }
8+ .compat .p { background: khaki; }
9+}
assets/stylesheets/pages/_simple.scss+0−1
@@ -19,7 +19,6 @@ · 18 unmodified lines
1919
2020 ._apache_pig,
2121 ._chai,
22−._cordova,
2322 ._docker,
2423 ._gnu,
2524 ._grunt,
lib/docs/filters/cordova/clean_html.rb+19−9
@@ -2,21 +2,31 @@ module Docs · 1 unmodified line
22 class Cordova
33 class CleanHtmlFilter < Filter
44 def call
5− if root_page?
6− css('h1').each { |node| node.name = 'h2' }
7− css('li > h2').each { |node| node.name = 'div' }
8− end
5+ @doc = at_css('.page-content > div')
6+
7+ at_css('h1').content = 'Apache Cordova' if root_page?
98
10− css('hr').remove
9+ css('hr', '.content-header', 'button').remove
1110
12− css('a[name]').each do |node|
13− node.parent['id'] = node['name']
11+ css('.home', '#page-toc-source', '.highlight', 'th h2').each do |node|
1412 node.before(node.children).remove
1513 end
1614
17− # Remove code highlighting
15+ css('img[src*="travis-ci"]').each do |node|
16+ node.ancestors('p').first.remove
17+ end
18+
1819 css('pre').each do |node|
19− node.content = node.content.remove(/^\ {4,5}/)
20+ node['data-language'] = node.at_css('code')['data-lang']
21+ node.content = node.content.strip_heredoc
22+ end
23+
24+ css('> .alert + h1').each do |node|
25+ node.previous_element.before(node)
26+ end
27+
28+ css('h1, h2, h3, h4, h5, h6').each do |node|
29+ node['id'] = node.content.strip.parameterize
2030 end
2131
2232 doc
lib/docs/filters/cordova/entries.rb+46−6
@@ -2,16 +2,56 @@ module Docs · 1 unmodified line
22 class Cordova
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
5− at_css('h1').content.remove(' Guide')
5+ return 'CLI' if slug == 'reference/cordova-cli/index'
6+ name = at_css('#page-toc-source h1').content.strip
7+ name.remove! ' Guide'
8+ name
69 end
710
811 def get_type
9− if subpath.start_with?('guide/platforms')
10− name[/Amazon\ Fire\ OS|Android|BlackBerry|Firefox OS|iOS|Windows/] || 'Platform Guides'
11− elsif subpath.start_with?('cordova/events')
12− 'Events'
12+ return 'Platforms' if subpath.include?('guide/platforms/')
13+ return 'Plugins' if name.start_with?('cordova-plugin')
14+ at_css('.site-toc .this-page').ancestors('li').last.at_css('span').content
15+ end
16+
17+ def additional_entries
18+ case slug
19+ when 'reference/cordova-cli/index'
20+ css('#page-toc-source h2').each_with_object [] do |node, entries|
21+ name = node.content.strip
22+ id = name.parameterize
23+ next unless name =~ /cordova .+ command/
24+ name.remove! ' command'
25+ entries << [name, id, 'Reference: CLI']
26+ end
27+ when 'config_ref/index'
28+ namespace = ''
29+ css('#page-toc-source > *').each_with_object [] do |node, entries|
30+ case node.name
31+ when 'h1'
32+ name = node.content.strip
33+ next unless name =~ /\A[a-z]+\z/
34+ entries << ["<#{name}>", name.parameterize, 'Reference: config.xml']
35+ when 'h2'
36+ name = node.content.strip
37+ next unless name =~ /\A[a-z]+\z/
38+ namespace = name
39+ entries << ["<#{name}>", name.parameterize, 'Reference: config.xml']
40+ when 'h3'
41+ name = node.content.strip
42+ next unless name =~ /\A[a-z]+\z/
43+ entries << ["<#{namespace}> <#{name}>", name.parameterize, 'Reference: config.xml']
44+ end
45+ end
46+ when 'cordova/events/events'
47+ css('#page-toc-source h2').each_with_object [] do |node, entries|
48+ name = node.content.strip
49+ id = name.parameterize
50+ next unless name =~ /\A[a-z]+\z/
51+ entries << [name, id, 'Reference: events']
52+ end
1353 else
14− 'Guides'
54+ []
1555 end
1656 end
1757 end
lib/docs/scrapers/cordova.rb+19−8
@@ -2,23 +2,34 @@ module Docs · 1 unmodified line
22 class Cordova < UrlScraper
33 self.name = 'Cordova'
44 self.type = 'cordova'
5− self.release = '6.0.0'
6− self.base_url = "https://cordova.apache.org/docs/en/#{release}/"
7− self.root_path = 'index.html'
5+ self.root_path = 'guide/overview/index.html'
86 self.links = {
97 home: 'https://cordova.apache.org/'
108 }
119
12− html_filters.push 'cordova/clean_html', 'cordova/entries', 'title'
10+ html_filters.push 'cordova/entries', 'cordova/clean_html'
1311
14− options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page-toc-source' }
15− options[:title] = false
16− options[:root_title] = 'Apache Cordova'
17− options[:skip] = %w(page_index.html)
12+ options[:container] = '.docs'
13+ options[:skip] = %w(index.html)
14+
15+ options[:fix_urls] = ->(url) do
16+ if url.include?('https://cordova.apache.org/docs') && !url.end_with?('.html')
17+ if url.end_with?('/')
18+ url << 'index.html'
19+ else
20+ url << '/index.html'
21+ end
22+ end
23+ end
1824
1925 options[:attribution] = <<-HTML
2026 &copy; 2012&ndash;2016 The Apache Software Foundation<br>
2127 Licensed under the Apache License 2.0.
2228 HTML
29+
30+ version '6' do
31+ self.release = '6.3.1'
32+ self.base_url = 'https://cordova.apache.org/docs/en/6.x/'
33+ end
2334 end
2435 end