Forráskód Böngészése

Update Laravel documentation (5.5.0)

Thibaut Courouble 8 éve
szülő
commit
6cbf550ec8
2 módosított fájl, 19 hozzáadás és 5 törlés
  1. 6 1
      lib/docs/filters/laravel/entries.rb
  2. 13 4
      lib/docs/scrapers/laravel.rb

+ 6 - 1
lib/docs/filters/laravel/entries.rb

@@ -12,7 +12,12 @@ module Docs
       end
 
       def get_type
-        return 'Guides' unless api_page?
+        unless api_page?
+          link = at_css(".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('/', '\\')
 
         if type.end_with?('Console')

+ 13 - 4
lib/docs/scrapers/laravel.rb

@@ -1,11 +1,7 @@
 module Docs
   class Laravel < UrlScraper
-    self.name = 'Laravel'
-    self.slug = 'laravel'
     self.type = 'laravel'
-
     self.base_url = 'https://laravel.com'
-
     self.links = {
       home: 'https://laravel.com/',
       code: 'https://github.com/laravel/laravel'
@@ -33,6 +29,19 @@ module Docs
       Laravel is a trademark of Taylor Otwell.
     HTML
 
+    version '5.5' do
+      self.release = '5.5.0'
+      self.root_path = '/api/5.5/index.html'
+      self.initial_paths = %w(/docs/5.5/installation /api/5.5/classes.html)
+
+      options[:only_patterns] = [%r{\A/api/5\.5/}, %r{\A/docs/5\.5/}]
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.5/"
+        url
+      end
+    end
+
     version '5.4' do
       self.release = '5.4.30'
       self.root_path = '/api/5.4/index.html'