Update Laravel documentation (5.0.0)

pull/165/head
Thibaut 10 years ago
parent 07047cb71f
commit e97b8d463d

@ -12,12 +12,24 @@ module Docs
end end
def api def api
css('#footer', '.location').remove @doc = doc.at_css('#page-content')
css('.location').remove
# Replace .header with <h1> # Replace .header with <h1>
css('.header > h1').each do |node| css('.page-header > h1').each do |node|
node.parent.before(node).remove
node.content = 'Laravel' if root_page? node.content = 'Laravel' if root_page?
node.parent.before(node).remove
end
css('.container-fluid').each do |node|
node.name = 'table'
node.css('.row').each { |n| n.name = 'tr' }
node.css('div[class^="col"]').each { |n| n.name = 'td' }
end
css('> div').each do |node|
node.before(node.children).remove
end end
# Remove <abbr> # Remove <abbr>
@ -38,7 +50,7 @@ module Docs
end end
def other def other
@doc = at_css('#docs-content') @doc = at_css('article')
# Clean up headings # Clean up headings
css('h2 > a').each do |node| css('h2 > a').each do |node|

@ -3,29 +3,36 @@ module Docs
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
if api_page? if api_page?
at_css('h1').content.strip.split('\\').last name = at_css('h1').content.strip.remove('Illuminate\\')
name << " (#{type})" unless name.start_with?(self.type)
name
else else
at_css('h1').content.strip at_css('h1').content
end end
end end
def get_type def get_type
if api_page? return 'Guides' unless api_page?
type = at_css('h1').content.strip.remove('Illuminate\\').remove(/\\\w+?\z/) type = slug.remove('api/5.0/').remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\')
type.end_with?('Console') ? type.split('\\').first : type
if type.end_with?('Console')
type.split('\\').first
elsif type.start_with?('Contracts')
'Contracts'
else else
'Guides' type
end end
end end
def additional_entries def additional_entries
return [] unless api_page? return [] if root_page? || !api_page?
base_name = self.name.remove(/\(.+\)/).strip
css('h3[id^="method_"]').each_with_object [] do |node, entries| css('h3[id^="method_"]').each_with_object [] do |node, entries|
next if node.at_css('.location').content.start_with?('in') next if node.at_css('.location').content.start_with?('in')
name = node['id'].remove('method_') name = node['id'].remove('method_')
name.prepend "#{self.name}::" name.prepend "#{base_name}::"
name << '()' name << '()'
entries << [name, node['id']] entries << [name, node['id']]
@ -35,6 +42,10 @@ module Docs
def api_page? def api_page?
subpath.start_with?('/api') subpath.start_with?('/api')
end end
def include_default_entry?
subpath != '/api/5.0/classes.html'
end
end end
end end
end end

@ -3,36 +3,36 @@ module Docs
self.name = 'Laravel' self.name = 'Laravel'
self.slug = 'laravel' self.slug = 'laravel'
self.type = 'laravel' self.type = 'laravel'
self.version = '4.2.11' self.version = '5.0.0'
self.base_url = 'http://laravel.com' self.base_url = 'http://laravel.com'
self.root_path = '/docs/4.2/introduction' self.root_path = '/api/5.0/index.html'
self.initial_paths = %w(/api/4.2/classes.html) self.initial_paths = %w(/docs/5.0/installation /api/5.0/classes.html)
html_filters.push 'laravel/entries', 'laravel/clean_html' html_filters.push 'laravel/entries', 'laravel/clean_html'
options[:container] = ->(filter) { options[:container] = ->(filter) {
filter.subpath.start_with?('/api') ? nil : '#documentation > article' filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper'
} }
options[:only_patterns] = [ options[:only_patterns] = [
/\A\/api\/4\.2\//, /\A\/api\/5\.0\//,
/\A\/docs\/4\.2\//] /\A\/docs\/5\.0\//]
options[:skip] = %w( options[:skip] = %w(
/docs/4.2/quick /docs/5.0/quick
/docs/4.2/releases /docs/5.0/releases
/docs/4.2/upgrade /docs/5.0/artisan
/docs/4.2/artisan /docs/5.0/commands
/docs/4.2/commands /api/5.0/panel.html
/api/4.2/panel.html /api/5.0/namespaces.html
/api/4.2/namespaces.html /api/5.0/interfaces.html
/api/4.2/interfaces.html /api/5.0/traits.html
/api/4.2/traits.html /api/5.0/doc-index.html
/api/4.2/doc-index.html /api/5.0/Illuminate.html
/api/4.2/Illuminate.html) /api/5.0/search.html)
options[:fix_urls] = ->(url) do options[:fix_urls] = ->(url) do
url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/4.2/" url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.0/"
url url
end end

Loading…
Cancel
Save