소스 검색

Merge pull request #1983 from tklai/laravel-update

laravel: add Laravel 10 documentation with improvements
Simon Legner 2 년 전
부모
커밋
f5d6e74a88
3개의 변경된 파일40개의 추가작업 그리고 16개의 파일을 삭제
  1. 10 3
      lib/docs/filters/laravel/clean_html.rb
  2. 1 1
      lib/docs/filters/laravel/entries.rb
  3. 29 12
      lib/docs/scrapers/laravel.rb

+ 10 - 3
lib/docs/filters/laravel/clean_html.rb

@@ -9,9 +9,16 @@ module Docs
         end
 
         # Remove code highlighting
-        css('pre').each do |node|
-          node.content = node.content
-          node['data-language'] = 'php'
+        css('pre > code').each do |node|
+          if node['data-lang'].eql?('nothing')
+            # Ignore 'nothing' language
+          else
+            node.parent['data-language'] = node['data-lang']
+          end
+          # Prism uses `\n` to determine lines. Otherwise the lines will be
+          # compacted.
+          node.parent.content = node.css('.line').map(&:content).join("\n")
+          node.remove
         end
 
         doc

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

@@ -18,7 +18,7 @@ module Docs
           return heading ? "Guides: #{heading.content.strip}" : 'Guides'
         end
 
-        type = slug.remove(%r{api/\d.[0-9x]/}).remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\')
+        type = slug.remove(%r{api/[1-9]?\d.[0-9x]/}).remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '\\')
 
         if type.end_with?('Console')
           type.split('\\').first

+ 29 - 12
lib/docs/scrapers/laravel.rb

@@ -14,14 +14,14 @@ module Docs
     }
 
     options[:skip_patterns] = [
-      %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} ]
+      %r{\A/api/[1-9]?\d\.[0-9x]/\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/panel\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/namespaces\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/interfaces\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/traits\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/doc-index\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/Illuminate\.html},
+      %r{\A/api/[1-9]?\d\.[0-9x]/search\.html} ]
 
     options[:attribution] = <<-HTML
       &copy; Taylor Otwell<br>
@@ -29,8 +29,22 @@ module Docs
       Laravel is a trademark of Taylor Otwell.
     HTML
 
+    version '10' do
+      self.release = '10.13.0'
+      self.root_path = '/api/10.x/index.html'
+      self.initial_paths = %w(/docs/10.x/installation /api/10.x/classes.html)
+
+      options[:only_patterns] = [%r{\A/api/10\.x/}, %r{\A/docs/10\.x/}]
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{10.x/+}, "10.x/"
+        url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?![1-9]?\d)}, "#{Laravel.base_url}/docs/10.x/"
+        url
+      end
+    end
+
     version '9' do
-      self.release = '9.3.8'
+      self.release = '9.52.8'
       self.root_path = '/api/9.x/index.html'
       self.initial_paths = %w(/docs/9.x/installation /api/9.x/classes.html)
 
@@ -44,39 +58,42 @@ module Docs
     end
 
     version '8' do
-      self.release = '8.4.1'
+      self.release = '8.83.27'
       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{8.x/+}, "8.x/"
         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.release = '7.30.6'
       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{7.x/+}, "7.x/"
         url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/7.x/"
         url
       end
     end
 
     version '6' do
-      self.release = '6.20.0'
+      self.release = '6.20.44'
       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{6.x/+}, "6.x/"
         url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/6.x/"
         url
       end