From 3cdf591bd13c6eef2e2203ad18a415db10563dcc Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sat, 26 Mar 2016 15:51:28 -0400 Subject: [PATCH] Version Laravel documentation (5.2 and 5.1) Fixes #289. Fixes #377. --- lib/docs/filters/laravel/clean_html.rb | 4 ++ lib/docs/filters/laravel/entries.rb | 2 +- lib/docs/scrapers/laravel.rb | 62 +++++++++++++++----------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/lib/docs/filters/laravel/clean_html.rb b/lib/docs/filters/laravel/clean_html.rb index 4ed481e1..1e1f3dc7 100644 --- a/lib/docs/filters/laravel/clean_html.rb +++ b/lib/docs/filters/laravel/clean_html.rb @@ -57,6 +57,10 @@ module Docs node.before(node.children).remove end + css('p > a[name]').each do |node| + node.parent.next_element['id'] = node['name'] + end + # Remove code highlighting css('pre').each do |node| node.content = node.content diff --git a/lib/docs/filters/laravel/entries.rb b/lib/docs/filters/laravel/entries.rb index d75a0da5..4a1794df 100644 --- a/lib/docs/filters/laravel/entries.rb +++ b/lib/docs/filters/laravel/entries.rb @@ -46,7 +46,7 @@ module Docs end def include_default_entry? - subpath != '/api/5.2/classes.html' + !subpath.end_with?('classes.html') end end end diff --git a/lib/docs/scrapers/laravel.rb b/lib/docs/scrapers/laravel.rb index 0c4daead..a2927cf6 100644 --- a/lib/docs/scrapers/laravel.rb +++ b/lib/docs/scrapers/laravel.rb @@ -3,10 +3,9 @@ module Docs self.name = 'Laravel' self.slug = 'laravel' self.type = 'laravel' - self.release = '5.2.0' + self.base_url = 'https://laravel.com' - self.root_path = '/api/5.2/index.html' - self.initial_paths = %w(/docs/5.2/installation /api/5.2/classes.html) + self.links = { home: 'https://laravel.com/', code: 'https://github.com/laravel/laravel' @@ -18,32 +17,45 @@ module Docs filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper' } - options[:only_patterns] = [ - /\A\/api\/5\.2\//, - /\A\/docs\/5\.2\//] - - options[:skip] = %w( - /docs/5.2/quick - /docs/5.2/releases - /docs/5.2/artisan - /docs/5.2/commands - /api/5.2/.html - /api/5.2/panel.html - /api/5.2/namespaces.html - /api/5.2/interfaces.html - /api/5.2/traits.html - /api/5.2/doc-index.html - /api/5.2/Illuminate.html - /api/5.2/search.html) - - options[:fix_urls] = ->(url) do - url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.2/" - url - end + options[:skip_patterns] = [ + %r{\A/api/\d\.\d/\.html}, + %r{\A/api/\d\.\d/panel\.html}, + %r{\A/api/\d\.\d/namespaces\.html}, + %r{\A/api/\d\.\d/interfaces\.html}, + %r{\A/api/\d\.\d/traits\.html}, + %r{\A/api/\d\.\d/doc-index\.html}, + %r{\A/api/\d\.\d/Illuminate\.html}, + %r{\A/api/\d\.\d/search\.html} ] options[:attribution] = <<-HTML © Taylor Otwell
Licensed under the MIT License. HTML + + version '5.2' do + self.release = '5.2.24' + self.root_path = '/api/5.2/index.html' + self.initial_paths = %w(/docs/5.2/installation /api/5.2/classes.html) + + options[:only_patterns] = [%r{\A/api/5\.2/}, %r{\A/docs/5\.2/}] + + options[:fix_urls] = ->(url) do + url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.2/" + url + end + end + + version '5.1' do + self.release = '5.1.11' + self.root_path = '/api/5.1/index.html' + self.initial_paths = %w(/docs/5.1/installation /api/5.1/classes.html) + + options[:only_patterns] = [%r{\A/api/5\.1/}, %r{\A/docs/5\.1/}] + + options[:fix_urls] = ->(url) do + url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.1/" + url + end + end end end