History

Update Laravel documentation (5.0.0)

Thibaut committed 11 years ago

Commit e97b8d41 parent 07047cb3 files · +53 −30Browse files

Unified · Split

3 files
  1. lib/docs/filters/laravel/clean_html.rb +16 −4
  2. lib/docs/filters/laravel/entries.rb +19 −8
  3. lib/docs/scrapers/laravel.rb +18 −18
lib/docs/filters/laravel/clean_html.rb+16−4
@@ -12,12 +12,24 @@ module Docs · 11 unmodified lines
1212 end
1313
1414 def api
15− css('#footer', '.location').remove
15+ @doc = doc.at_css('#page-content')
16+
17+ css('.location').remove
1618
1719 # Replace .header with <h1>
18− css('.header > h1').each do |node|
19− node.parent.before(node).remove
20+ css('.page-header > h1').each do |node|
2021 node.content = 'Laravel' if root_page?
22+ node.parent.before(node).remove
23+ end
24+
25+ css('.container-fluid').each do |node|
26+ node.name = 'table'
27+ node.css('.row').each { |n| n.name = 'tr' }
28+ node.css('div[class^="col"]').each { |n| n.name = 'td' }
29+ end
30+
31+ css('> div').each do |node|
32+ node.before(node.children).remove
2133 end
2234
2335 # Remove <abbr>
@@ -38,7 +50,7 @@ module Docs · 14 unmodified lines
3850 end
3951
4052 def other
41− @doc = at_css('#docs-content')
53+ @doc = at_css('article')
4254
4355 # Clean up headings
4456 css('h2 > a').each do |node|
lib/docs/filters/laravel/entries.rb+19−8
@@ -3,29 +3,36 @@ module Docs · 2 unmodified lines
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
55 if api_page?
6− at_css('h1').content.strip.split('\\').last
6+ name = at_css('h1').content.strip.remove('Illuminate\\')
7+ name << " (#{type})" unless name.start_with?(self.type)
8+ name
79 else
8− at_css('h1').content.strip
10+ at_css('h1').content
911 end
1012 end
1113
1214 def get_type
13− if api_page?
14− type = at_css('h1').content.strip.remove('Illuminate\\').remove(/\\\w+?\z/)
15− type.end_with?('Console') ? type.split('\\').first : type
15+ return 'Guides' unless api_page?
16+ type = slug.remove('api/5.0/').remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\')
17+
18+ if type.end_with?('Console')
19+ type.split('\\').first
20+ elsif type.start_with?('Contracts')
21+ 'Contracts'
1622 else
17− 'Guides'
23+ type
1824 end
1925 end
2026
2127 def additional_entries
22− return [] unless api_page?
28+ return [] if root_page? || !api_page?
29+ base_name = self.name.remove(/\(.+\)/).strip
2330
2431 css('h3[id^="method_"]').each_with_object [] do |node, entries|
2532 next if node.at_css('.location').content.start_with?('in')
2633
2734 name = node['id'].remove('method_')
28− name.prepend "#{self.name}::"
35+ name.prepend "#{base_name}::"
2936 name << '()'
3037
3138 entries << [name, node['id']]
@@ -35,6 +42,10 @@ module Docs · 3 unmodified lines
3542 def api_page?
3643 subpath.start_with?('/api')
3744 end
45+
46+ def include_default_entry?
47+ subpath != '/api/5.0/classes.html'
48+ end
3849 end
3950 end
4051 end
lib/docs/scrapers/laravel.rb+18−18
@@ -3,36 +3,36 @@ module Docs · 2 unmodified lines
33 self.name = 'Laravel'
44 self.slug = 'laravel'
55 self.type = 'laravel'
6− self.version = '4.2.11'
6+ self.version = '5.0.0'
77 self.base_url = 'http://laravel.com'
8− self.root_path = '/docs/4.2/introduction'
9− self.initial_paths = %w(/api/4.2/classes.html)
8+ self.root_path = '/api/5.0/index.html'
9+ self.initial_paths = %w(/docs/5.0/installation /api/5.0/classes.html)
1010
1111 html_filters.push 'laravel/entries', 'laravel/clean_html'
1212
1313 options[:container] = ->(filter) {
14− filter.subpath.start_with?('/api') ? nil : '#documentation > article'
14+ filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper'
1515 }
1616
1717 options[:only_patterns] = [
18− /\A\/api\/4\.2\//,
19− /\A\/docs\/4\.2\//]
18+ /\A\/api\/5\.0\//,
19+ /\A\/docs\/5\.0\//]
2020
2121 options[:skip] = %w(
22− /docs/4.2/quick
23− /docs/4.2/releases
24− /docs/4.2/upgrade
25− /docs/4.2/artisan
26− /docs/4.2/commands
27− /api/4.2/panel.html
28− /api/4.2/namespaces.html
29− /api/4.2/interfaces.html
30− /api/4.2/traits.html
31− /api/4.2/doc-index.html
32− /api/4.2/Illuminate.html)
22+ /docs/5.0/quick
23+ /docs/5.0/releases
24+ /docs/5.0/artisan
25+ /docs/5.0/commands
26+ /api/5.0/panel.html
27+ /api/5.0/namespaces.html
28+ /api/5.0/interfaces.html
29+ /api/5.0/traits.html
30+ /api/5.0/doc-index.html
31+ /api/5.0/Illuminate.html
32+ /api/5.0/search.html)
3333
3434 options[:fix_urls] = ->(url) do
35− url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/4.2/"
35+ url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.0/"
3636 url
3737 end
3838