From 98f582112b790f1ac70a16fed8cef4fd23549778 Mon Sep 17 00:00:00 2001 From: Rick Mac Gillis Date: Mon, 18 May 2020 12:25:55 -0400 Subject: [PATCH 1/3] Laravel versions Signed-off-by: Rick Mac Gillis --- lib/docs/filters/laravel/clean_html.rb | 8 +++- lib/docs/filters/laravel/entries.rb | 4 +- lib/docs/scrapers/laravel.rb | 57 ++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/lib/docs/filters/laravel/clean_html.rb b/lib/docs/filters/laravel/clean_html.rb index fb008028..e43ebda2 100644 --- a/lib/docs/filters/laravel/clean_html.rb +++ b/lib/docs/filters/laravel/clean_html.rb @@ -56,7 +56,7 @@ module Docs end def other - @doc = at_css('article') + @doc = at_css('.docs_body') # Clean up headings css('h2 > a').each do |node| @@ -71,6 +71,12 @@ module Docs node['class'] = 'tip' if node.inner_html.include?('{tip}') node.inner_html = node.inner_html.remove(/\{(tip|note)\}\s?/) end + + css('blockquote').each do |node| + if node.inner_html.include?('You\'re browsing the documentation for an old version of Laravel.') + node.remove + end + end end end end diff --git a/lib/docs/filters/laravel/entries.rb b/lib/docs/filters/laravel/entries.rb index 6b7c7dcf..5de0c713 100644 --- a/lib/docs/filters/laravel/entries.rb +++ b/lib/docs/filters/laravel/entries.rb @@ -13,12 +13,12 @@ module Docs def get_type unless api_page? - link = at_css(".sidebar li a[href='#{result[:path].split('/').last}']") + link = at_css(".docs_sidebar li a[href='#{result[:path].split('/').last}']") heading = link.ancestors('li').last.at_css('> h2') return heading ? "Guides: #{heading.content.strip}" : 'Guides' end - type = slug.remove(%r{api/\d.\d/}).remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\') + type = slug.remove(%r{api/\d.[0-9x]/}).remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\') if type.end_with?('Console') type.split('\\').first diff --git a/lib/docs/scrapers/laravel.rb b/lib/docs/scrapers/laravel.rb index e45b0bed..35e56602 100644 --- a/lib/docs/scrapers/laravel.rb +++ b/lib/docs/scrapers/laravel.rb @@ -10,18 +10,18 @@ module Docs html_filters.push 'laravel/entries', 'laravel/clean_html' options[:container] = ->(filter) { - filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper' + filter.subpath.start_with?('/api') ? '#content' : '.page_contain' } 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} ] + %r{\A/api/\d\.[0-9x]/\.html}, + %r{\A/api/\d\.[0-9x]/panel\.html}, + %r{\A/api/\d\.[0-9x]/namespaces\.html}, + %r{\A/api/\d\.[0-9x]/interfaces\.html}, + %r{\A/api/\d\.[0-9x]/traits\.html}, + %r{\A/api/\d\.[0-9x]/doc-index\.html}, + %r{\A/api/\d\.[0-9x]/Illuminate\.html}, + %r{\A/api/\d\.[0-9x]/search\.html} ] options[:attribution] = <<-HTML © Taylor Otwell
@@ -29,6 +29,45 @@ module Docs Laravel is a trademark of Taylor Otwell. HTML + version '7.0' do + self.release = '7.11.0' + self.root_path = '/api/7.x/index.html' + self.initial_paths = %w(/docs/7.x/installation /api/7.x/classes.html) + + options[:only_patterns] = [%r{\A/api/7\.x/}, %r{\A/docs/7\.x/}] + + options[:fix_urls] = ->(url) do + url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/7.x/" + url + end + end + + version '6.0' do + self.release = '6.18.14' + self.root_path = '/api/6.x/index.html' + self.initial_paths = %w(/docs/6.x/installation /api/6.x/classes.html) + + options[:only_patterns] = [%r{\A/api/6\.x/}, %r{\A/docs/6\.x/}] + + options[:fix_urls] = ->(url) do + url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/6.x/" + url + end + end + + version '5.8' do + self.release = '5.8.38' + self.root_path = '/api/5.8/index.html' + self.initial_paths = %w(/docs/5.8/installation /api/5.8/classes.html) + + options[:only_patterns] = [%r{\A/api/5\.8/}, %r{\A/docs/5\.8/}] + + options[:fix_urls] = ->(url) do + url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.8/" + url + end + end + version '5.7' do self.release = '5.7.7' self.root_path = '/api/5.7/index.html' From 56717583321a004083c166cb1c49f5b32e18de88 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 14 Nov 2020 13:15:02 +0100 Subject: [PATCH 2/3] laravel: update releases 6.20.0 and 7.30.1 --- lib/docs/scrapers/laravel.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/docs/scrapers/laravel.rb b/lib/docs/scrapers/laravel.rb index 35e56602..c7c79ae3 100644 --- a/lib/docs/scrapers/laravel.rb +++ b/lib/docs/scrapers/laravel.rb @@ -29,8 +29,8 @@ module Docs Laravel is a trademark of Taylor Otwell. HTML - version '7.0' do - self.release = '7.11.0' + version '7' do + self.release = '7.30.1' self.root_path = '/api/7.x/index.html' self.initial_paths = %w(/docs/7.x/installation /api/7.x/classes.html) @@ -42,8 +42,8 @@ module Docs end end - version '6.0' do - self.release = '6.18.14' + version '6' do + self.release = '6.20.0' self.root_path = '/api/6.x/index.html' self.initial_paths = %w(/docs/6.x/installation /api/6.x/classes.html) From daaf1d6598cbe99cc525dd3c32aec4e8a559b232 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 14 Nov 2020 13:18:19 +0100 Subject: [PATCH 3/3] laravel: add version 8 --- lib/docs/scrapers/laravel.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/docs/scrapers/laravel.rb b/lib/docs/scrapers/laravel.rb index c7c79ae3..51a0cced 100644 --- a/lib/docs/scrapers/laravel.rb +++ b/lib/docs/scrapers/laravel.rb @@ -29,6 +29,19 @@ module Docs Laravel is a trademark of Taylor Otwell. HTML + version '8' do + self.release = '8.4.1' + self.root_path = '/api/8.x/index.html' + self.initial_paths = %w(/docs/8.x/installation /api/8.x/classes.html) + + options[:only_patterns] = [%r{\A/api/8\.x/}, %r{\A/docs/8\.x/}] + + options[:fix_urls] = ->(url) do + url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/8.x/" + url + end + end + version '7' do self.release = '7.30.1' self.root_path = '/api/7.x/index.html'