Bläddra i källkod

Update Angular documentation (6.0.4)

Thibaut Courouble 7 år sedan
förälder
incheckning
941f33e133

+ 2 - 0
assets/stylesheets/pages/_angular.scss

@@ -19,4 +19,6 @@
     font-style: italic;
     text-align: right;
   }
+
+  td h3 { margin: 0 !important; }
 }

+ 9 - 1
lib/docs/filters/angular/clean_html.rb

@@ -7,7 +7,7 @@ module Docs
           at_css('h1').content = 'Angular Documentation'
         end
 
-        css('br', 'hr', '.material-icons', '.header-link').remove
+        css('br', 'hr', '.material-icons', '.header-link', '.breadcrumb').remove
 
         css('.content', 'article', '.api-header', 'section', '.instance-member').each do |node|
           node.before(node.children).remove
@@ -86,6 +86,14 @@ module Docs
           at_css('h1').content = subpath.remove('api/')
         end
 
+        css('th h3').each do |node|
+          node.name = 'span'
+        end
+
+        css('code code').each do |node|
+          node.before(node.children).remove
+        end
+
         doc
       end
     end

+ 2 - 0
lib/docs/filters/angular/entries.rb

@@ -16,6 +16,8 @@ module Docs
           node.next_element.content.remove('@angular/')
         elsif at_css('.api-type-label.module')
           name.split('/').first
+        elsif slug.start_with?('api/')
+          slug.split('/').second
         else
           'Miscellaneous'
         end

+ 21 - 1
lib/docs/scrapers/angular.rb

@@ -59,7 +59,7 @@ module Docs
     end
 
     version do
-      self.release = '5.2.9'
+      self.release = '6.0.4'
       self.base_url = 'https://angular.io/'
       self.root_path = 'docs'
 
@@ -78,6 +78,26 @@ module Docs
       include Docs::Angular::Common
     end
 
+    version '5' do
+      self.release = '5.2.11'
+      self.base_url = 'https://v5.angular.io/'
+      self.root_path = 'docs'
+
+      html_filters.push 'angular/clean_html', 'angular/entries'
+
+      options[:follow_links] = false
+      options[:only_patterns] = [/\Aguide/, /\Atutorial/, /\Aapi/]
+      options[:fix_urls_before_parse] = ->(url) do
+        url.sub! %r{\Aguide/}, '/guide/'
+        url.sub! %r{\Atutorial/}, '/tutorial/'
+        url.sub! %r{\Aapi/}, '/api/'
+        url.sub! %r{\Agenerated/}, '/generated/'
+        url
+      end
+
+      include Docs::Angular::Common
+    end
+
     version '4' do
       self.release = '4.4.6'
       self.base_url = 'https://v4.angular.io/'