Przeglądaj źródła

Fix issues in Angular scraper

Thibaut Courouble 9 lat temu
rodzic
commit
f0211029ef

+ 7 - 0
lib/docs/filters/angular/clean_html.rb

@@ -12,6 +12,13 @@ module Docs
         container.child.before(at_css('header.hero h1')).before(badges).before(css('header.hero + .banner'))
         @doc = container
 
+        title = at_css('h1').content.strip
+        if title == 'Index'
+          at_css('h1').content = result[:entries].first.name
+        elsif title == 'Angular'
+          at_css('h1').content = slug.split('/').last.gsub('-', ' ')
+        end
+
         css('pre.no-bg-with-indent').each do |node|
           node.content = '  ' + node.content.gsub("\n", "\n  ")
         end

+ 4 - 4
lib/docs/filters/angular/entries.rb

@@ -11,10 +11,10 @@ module Docs
         name = name.split(':').first
 
         if mod
-          if name == 'Testing'
-            return "#{mod.capitalize} Testing"
-          elsif name == 'Index' || name == 'Angular'
-            return mod
+          if name == 'Index'
+            return slug.split('/')[1..-2].join('/')
+          elsif name == 'Angular'
+            return slug.split('/').last.split('-').first
           end
         end
 

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

@@ -25,7 +25,6 @@ module Docs
 
     options[:fix_urls] = -> (url) do
       url.sub! %r{\A(https://angular\.io/docs/.+/)index\.html\z}, '\1'
-      url.sub! %r{\A(https://angular\.io/docs/.+/index)/\z}, '\1'
       url
     end