[devdocsgjs/main: 12/239] Update Angular documentation (13.0.2)




commit 735b48209f3f0436efaacd431020980fc20ad185
Author: Simon Legner <Simon Legner gmail com>
Date:   Thu Nov 25 00:27:39 2021 +0100

    Update Angular documentation (13.0.2)
    
    https://github.com/angular/angular/pull/42414

 lib/docs/scrapers/angular.rb | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/lib/docs/scrapers/angular.rb b/lib/docs/scrapers/angular.rb
index 3654bbad..275dbbd0 100644
--- a/lib/docs/scrapers/angular.rb
+++ b/lib/docs/scrapers/angular.rb
@@ -46,20 +46,30 @@ module Docs
       def handle_response(response)
         if response.mime_type.include?('json')
           begin
-            response.options[:response_body] = JSON.parse(response.body)['contents']
+            json = JSON.parse(response.body)
+            response.options[:response_body] = json['contents']
+            response.url.path = response.url.path.gsub(/generated\/docs\/.*/, json['id'])
+            response.effective_url.path = response.effective_url.path.gsub(/generated\/docs\/.*/, json['id'])
           rescue JSON::ParserError
             response.options[:response_body] = ''
           end
           response.headers['Content-Type'] = 'text/html'
-          response.url.path = response.url.path.sub('/generated/docs/', '/').remove('.json')
-          response.effective_url.path = response.effective_url.path.sub('/generated/docs/', 
'/').remove('.json')
         end
         super
       end
     end
 
+    module Since12
+      def url_for(path)
+        # See encodeToLowercase im 
aio/tools/transforms/angular-base-package/processors/disambiguateDocPaths.js
+        path = path.gsub(/[A-Z_]/) {|s| s.downcase + '_'}
+        super
+      end
+      include Docs::Angular::Common
+    end
+
     version do
-      self.release = '12.0.0'
+      self.release = '13.0.2'
       self.base_url = 'https://angular.io/'
       self.root_path = 'docs'
 
@@ -75,7 +85,27 @@ module Docs
         url
       end
 
-      include Docs::Angular::Common
+      include Docs::Angular::Since12
+    end
+
+    version '12' do
+      self.release = '12.2.13'
+      self.base_url = 'https://v12.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::Since12
     end
 
     version '11' do


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]