1
0
Эх сурвалжийг харах

Merge pull request #1225 from ahosni/docs-spring-boot

Add documentation for Spring Boot
Simon Legner 5 жил өмнө
parent
commit
6956b9c3e0

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -826,5 +826,10 @@ credits = [
     '2008-2017 by Yii Software LLC',
     'BSD',
     'https://raw.githubusercontent.com/yiisoft/yii/master/LICENSE'
+  ], [
+    'Spring Boot',
+    '2002-2020 Pivotal, Inc. All Rights Reserved.',
+    'Apache License 2.0',
+    'https://raw.githubusercontent.com/spring-projects/spring-boot/master/LICENSE.txt'
   ]
 ]

+ 15 - 0
lib/docs/filters/spring_boot/clean_html.rb

@@ -0,0 +1,15 @@
+module Docs
+  class SpringBoot
+    class CleanHtmlFilter < Filter
+      def call
+             
+        css('pre').each do |node|
+          language =  node.children.first['data-lang']  if node.children.first.name == 'code'
+          node['data-language'] = language
+        end
+      
+        doc
+      end
+    end
+  end
+end

+ 21 - 0
lib/docs/filters/spring_boot/entries.rb

@@ -0,0 +1,21 @@
+module Docs
+  class SpringBoot
+    class EntriesFilter < Docs::EntriesFilter
+    
+      def get_type
+        slug.gsub('-', ' ').capitalize
+      end
+
+      def additional_entries
+        css('td a[href], li a[href]').each_with_object [] do |node, entries|
+          next if root_page?
+          next if node['href'].start_with?('http')
+          name = node.content.strip
+          id = node['href'].remove('#')
+          next if id.blank?
+          entries << [name, id, get_type]
+        end
+      end
+    end
+  end
+end

+ 30 - 0
lib/docs/scrapers/spring_boot.rb

@@ -0,0 +1,30 @@
+module Docs
+  class SpringBoot < UrlScraper
+    self.name = 'Spring Boot'
+    self.slug = 'spring_boot'
+    self.type = 'simple'
+    self.root_path = "index.html"
+    self.links = {
+      home: 'https://spring.io/',
+      code: 'https://github.com/spring-projects/spring-boot'
+    }
+
+    html_filters.push 'spring_boot/entries', 'spring_boot/clean_html'
+
+    options[:skip_patterns] = [/legal/]
+
+    options[:attribution] = <<-HTML
+    Copyright &copy; 2002–2020 Pivotal, Inc. All Rights Reserved.
+    HTML
+
+    version do
+      self.release = '2.4.0'
+      self.base_url = "https://docs.spring.io/spring-boot/docs/#{release}/reference/html/"
+    end
+
+    def get_latest_version(opts)
+      get_latest_github_release('spring-projects', 'spring-boot', opts)
+    end
+
+  end
+end

BIN
public/icons/docs/spring_boot/16.png


BIN
public/icons/docs/spring_boot/16@2x.png


+ 1 - 0
public/icons/docs/spring_boot/SOURCE

@@ -0,0 +1 @@
+https://spring.io/trademarks