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
12 end12 end
13 13
14 def api14 def api
15 css('#footer', '.location').remove15 @doc = doc.at_css('#page-content')
16
17 css('.location').remove
16 18
17 # Replace .header with <h1>19 # Replace .header with <h1>
18 css('.header > h1').each do |node|20 css('.page-header > h1').each do |node|
19 node.parent.before(node).remove
20 node.content = 'Laravel' if root_page?21 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
21 end33 end
22 34
23 # Remove <abbr>35 # Remove <abbr>
@@ -38,7 +50,7 @@ module Docs · 14 unmodified lines
38 end50 end
39 51
40 def other52 def other
41 @doc = at_css('#docs-content')53 @doc = at_css('article')
42 54
43 # Clean up headings55 # Clean up headings
44 css('h2 > a').each do |node|56 css('h2 > a').each do |node|
lib/docs/filters/laravel/entries.rb+19−8
@@ -3,29 +3,36 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if api_page?5 if api_page?
6 at_css('h1').content.strip.split('\\').last6 name = at_css('h1').content.strip.remove('Illuminate\\')
7 name << " (#{type})" unless name.start_with?(self.type)
8 name
7 else9 else
8 at_css('h1').content.strip10 at_css('h1').content
9 end11 end
10 end12 end
11 13
12 def get_type14 def get_type
13 if api_page?15 return 'Guides' unless api_page?
14 type = at_css('h1').content.strip.remove('Illuminate\\').remove(/\\\w+?\z/)16 type = slug.remove('api/5.0/').remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\')
15 type.end_with?('Console') ? type.split('\\').first : type17
18 if type.end_with?('Console')
19 type.split('\\').first
20 elsif type.start_with?('Contracts')
21 'Contracts'
16 else22 else
17 'Guides'23 type
18 end24 end
19 end25 end
20 26
21 def additional_entries27 def additional_entries
22 return [] unless api_page?28 return [] if root_page? || !api_page?
29 base_name = self.name.remove(/\(.+\)/).strip
23 30
24 css('h3[id^="method_"]').each_with_object [] do |node, entries|31 css('h3[id^="method_"]').each_with_object [] do |node, entries|
25 next if node.at_css('.location').content.start_with?('in')32 next if node.at_css('.location').content.start_with?('in')
26 33
27 name = node['id'].remove('method_')34 name = node['id'].remove('method_')
28 name.prepend "#{self.name}::"35 name.prepend "#{base_name}::"
29 name << '()'36 name << '()'
30 37
31 entries << [name, node['id']]38 entries << [name, node['id']]
@@ -35,6 +42,10 @@ module Docs · 3 unmodified lines
35 def api_page?42 def api_page?
36 subpath.start_with?('/api')43 subpath.start_with?('/api')
37 end44 end
45
46 def include_default_entry?
47 subpath != '/api/5.0/classes.html'
48 end
38 end49 end
39 end50 end
40end51end
lib/docs/scrapers/laravel.rb+18−18
@@ -3,36 +3,36 @@ module Docs · 2 unmodified lines
3 self.name = 'Laravel'3 self.name = 'Laravel'
4 self.slug = 'laravel'4 self.slug = 'laravel'
5 self.type = 'laravel'5 self.type = 'laravel'
6 self.version = '4.2.11'6 self.version = '5.0.0'
7 self.base_url = 'http://laravel.com'7 self.base_url = 'http://laravel.com'
8 self.root_path = '/docs/4.2/introduction'8 self.root_path = '/api/5.0/index.html'
9 self.initial_paths = %w(/api/4.2/classes.html)9 self.initial_paths = %w(/docs/5.0/installation /api/5.0/classes.html)
10 10
11 html_filters.push 'laravel/entries', 'laravel/clean_html'11 html_filters.push 'laravel/entries', 'laravel/clean_html'
12 12
13 options[:container] = ->(filter) {13 options[:container] = ->(filter) {
14 filter.subpath.start_with?('/api') ? nil : '#documentation > article'14 filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper'
15 }15 }
16 16
17 options[:only_patterns] = [17 options[:only_patterns] = [
18 /\A\/api\/4\.2\//,18 /\A\/api\/5\.0\//,
19 /\A\/docs\/4\.2\//]19 /\A\/docs\/5\.0\//]
20 20
21 options[:skip] = %w(21 options[:skip] = %w(
22 /docs/4.2/quick22 /docs/5.0/quick
23 /docs/4.2/releases23 /docs/5.0/releases
24 /docs/4.2/upgrade24 /docs/5.0/artisan
25 /docs/4.2/artisan25 /docs/5.0/commands
26 /docs/4.2/commands26 /api/5.0/panel.html
27 /api/4.2/panel.html27 /api/5.0/namespaces.html
28 /api/4.2/namespaces.html28 /api/5.0/interfaces.html
29 /api/4.2/interfaces.html29 /api/5.0/traits.html
30 /api/4.2/traits.html30 /api/5.0/doc-index.html
31 /api/4.2/doc-index.html31 /api/5.0/Illuminate.html
32 /api/4.2/Illuminate.html)32 /api/5.0/search.html)
33 33
34 options[:fix_urls] = ->(url) do34 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/"
36 url36 url
37 end37 end
38 38