1
0
Phil Scherer 5 жил өмнө
parent
commit
30fd37fc54

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

@@ -341,6 +341,11 @@ credits = [
     '2008-2012 Chris Davis<br>&copy; 2011-2016 The Graphite Project',
     'Apache',
     'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE'
+  ], [
+    'Groovy',
+    '2003-2020 The Apache Software Foundation',
+    'Apache',
+    'https://github.com/apache/groovy-website/blob/asf-site/LICENSE'
   ], [
     'Grunt',
     'GruntJS Team',

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -61,6 +61,7 @@
         'pages/github',
         'pages/go',
         'pages/graphite',
+        'pages/groovy',
         'pages/gnuplot',
         'pages/haproxy',
         'pages/haskell',

+ 13 - 0
assets/stylesheets/pages/_groovy.scss

@@ -0,0 +1,13 @@
+._groovy {
+  padding-left: 1rem;
+
+  h1, h2 { margin-left: -1rem; }
+  h2 { @extend %block-heading; }
+  h3 { @extend %block-label; }
+
+  .constructor { @extend %label-blue; }
+  .method { @extend %label-blue; }
+  .element { @extend %label-green; }
+  .field { @extend %label-green; }
+  .enum_constant { @extend %label-orange; }
+}

+ 93 - 0
lib/docs/filters/groovy/clean_html.rb

@@ -0,0 +1,93 @@
+module Docs
+  class Groovy
+    class CleanHtmlFilter < Filter
+      def new_node(content)
+        node = Nokogiri::XML::Node.new 'h1', doc
+        node.content = content
+        node
+      end
+
+      def call
+        title = at_css('.title').content
+        @doc = at_css('.contentContainer')
+        doc.child.before new_node(title)
+
+        if root_page?
+          css('tr > td > a').each do |node|
+            node.parent.content = node.content
+          end
+        end
+
+        css('.subNav', '.bottomNav').remove
+
+        css('hr + br', 'p + br', 'div + br', 'hr').remove
+
+        css('table').each do |node|
+          node.remove_attribute 'summary'
+          node.remove_attribute 'cellspacing'
+          node.remove_attribute 'cellpadding'
+          node.remove_attribute 'border'
+        end
+
+        # Move anchor name/id to heading tag
+        css('a[name] + h3').each do |node|
+          node['id'] = node.previous_element['name']
+        end
+
+        css('a[name] + ul.blockListLast').each do |node|
+          node.at_css('li > h4')['id'] = node.previous_element['name']
+        end
+
+        # Tag constructors, methods, and elements before removing context tags
+        css('#constructor_detail').each do |node|
+          node.parent.css('h4').each do |n|
+            n['class'] = 'constructor'
+          end
+        end
+
+        css('#method_detail').each do |node|
+          node.parent.css('h4').each do |n|
+            n['class'] = 'method'
+          end
+        end
+
+        css('#element_detail').each do |node|
+          node.parent.css('h4').each do |n|
+            n['class'] = 'element'
+          end
+        end
+
+        css('#field_detail').each do |node|
+          node.parent.css('h4').each do |n|
+            n['class'] = 'field'
+          end
+        end
+
+        css('#enum_constant_detail').each do |node|
+          node.parent.css('h4').each do |n|
+            n['class'] = 'enum_constant'
+          end
+        end
+
+        # Flatten and remove unnecessary intermediate tags
+        css('ul.blockList > li.blockList', 'ul.blockListLast > li.blockList').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('ul.blockList', 'ul.blockListLast').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('ul.blockList > table').each do |node|
+          node.parent.before(node).remove
+        end
+
+        css('h3', 'h4').each do |node|
+          node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 28 - 0
lib/docs/filters/groovy/entries.rb

@@ -0,0 +1,28 @@
+module Docs
+  class Groovy
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        slug.split('/').last
+      end
+
+      def get_type
+        slug.split('/')[0..-2].join('.')
+      end
+
+      def include_default_entry?
+        slug.split('/').last != 'package-summary'
+      end
+
+      def additional_entries
+        entries = []
+        css('.method, .element, .field, .enum_constant').each do |node|
+          entries << [@name + '.' + node['id'], node['id']]
+        end
+        css('.constructor').each do |node|
+          entries << [node['id'], node['id']]
+        end
+        entries
+      end
+    end
+  end
+end

+ 46 - 0
lib/docs/scrapers/groovy.rb

@@ -0,0 +1,46 @@
+module Docs
+  class Groovy < UrlScraper
+    self.type = 'groovy'
+    self.root_path = 'overview-summary.html'
+    self.links = {
+      home: 'https://groovy-lang.org/',
+      code: 'https://github.com/apache/groovy'
+    }
+
+    html_filters.push 'groovy/clean_html', 'groovy/entries'
+
+    options[:skip] = %w(
+      index-all.html
+      deprecated-list.html
+      help-doc.html
+    )
+    options[:skip_patterns] = [
+      /\Aindex.html/
+    ]
+
+    options[:attribution] = <<-HTML
+      &copy; 2003-2020 The Apache Software Foundation<br>
+      Licensed under the Apache license.
+    HTML
+
+    version '3.0' do
+      self.release = '3.0.7'
+      self.base_url = "https://docs.groovy-lang.org/#{self.release}/html/gapi/"
+    end
+
+    version '2.5' do
+      self.release = '2.5.14'
+      self.base_url = "https://docs.groovy-lang.org/#{self.release}/html/gapi/"
+    end
+
+    version '2.4' do
+      self.release = '2.4.21'
+      self.base_url = "https://docs.groovy-lang.org/#{self.release}/html/gapi/"
+    end
+
+    def get_latest_version(opts)
+      doc = fetch_doc('https://groovy.apache.org/download.html', opts)
+      doc.at_css('#big-download-button').content.split(' ').last
+    end
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://docs.groovy-lang.org/latest/html/gapi/groovy.ico