History

Merge pull request #1400 from scherepn/groovy

Add Groovy documentation

Simon Legner committed 5 years ago

Commit 0dd1eef2 parents 37d5fd3 01e1c9810 files · +193 −-2Browse files

Unified · Split

10 files
  1. assets/javascripts/news.json +4 −0
  2. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  3. assets/stylesheets/application.css.scss +1 −0
  4. assets/stylesheets/pages/_groovy.scss +13 −0
  5. lib/docs/filters/groovy/clean_html.rb +97 −0
  6. lib/docs/filters/groovy/entries.rb +28 −0
  7. lib/docs/scrapers/groovy.rb +46 −0
  8. public/icons/docs/groovy/16.png +0 −0
  9. public/icons/docs/groovy/16@2x.png +0 −0
  10. public/icons/docs/groovy/SOURCE +1 −0
assets/javascripts/news.json+4−0
@@ -1,4 +1,8 @@
11 [
2+ [
3+ "2020-12-07",
4+ "New documentation: <a href=\"/groovy/\">Groovy</a>"
5+ ],
26 [
37 "2020-12-04",
48 "New documentation: <a href=\"/haproxy/\">HAProxy</a>"
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -341,6 +341,11 @@ credits = [ · 340 unmodified lines
341341 '2008-2012 Chris Davis<br>&copy; 2011-2016 The Graphite Project',
342342 'Apache',
343343 'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE'
344+ ], [
345+ 'Groovy',
346+ '2003-2020 The Apache Software Foundation',
347+ 'Apache',
348+ 'https://github.com/apache/groovy-website/blob/asf-site/LICENSE'
344349 ], [
345350 'Grunt',
346351 'GruntJS Team',
assets/stylesheets/application.css.scss+1−0
@@ -61,6 +61,7 @@ · 60 unmodified lines
6161 'pages/github',
6262 'pages/go',
6363 'pages/graphite',
64+ 'pages/groovy',
6465 'pages/gnuplot',
6566 'pages/haproxy',
6667 'pages/haskell',
assets/stylesheets/pages/_groovy.scss+13−0
@@ -0,0 +1,13 @@
1+._groovy {
2+ padding-left: 1rem;
3+
4+ h1, h2 { margin-left: -1rem; }
5+ h2 { @extend %block-heading; }
6+ h3 { @extend %block-label; }
7+
8+ .constructor { @extend %label-blue; }
9+ .method { @extend %label-blue; }
10+ .element { @extend %label-green; }
11+ .field { @extend %label-green; }
12+ .enum_constant { @extend %label-orange; }
13+}
lib/docs/filters/groovy/clean_html.rb+97−0
@@ -0,0 +1,97 @@
1+module Docs
2+ class Groovy
3+ class CleanHtmlFilter < Filter
4+ def new_node(content)
5+ node = Nokogiri::XML::Node.new 'h1', doc
6+ node.content = content
7+ node
8+ end
9+
10+ def call
11+ title = at_css('.title').content
12+ @doc = at_css('.contentContainer')
13+ doc.child.before new_node(title)
14+
15+ if root_page?
16+ css('tr > td > a').each do |node|
17+ node.parent.content = node.content
18+ end
19+ end
20+
21+ css('.subNav', '.bottomNav').remove
22+
23+ css('hr + br', 'p + br', 'div + br', 'hr').remove
24+
25+ css('table').each do |node|
26+ node.remove_attribute 'summary'
27+ node.remove_attribute 'cellspacing'
28+ node.remove_attribute 'cellpadding'
29+ node.remove_attribute 'border'
30+ end
31+
32+ # Move anchor name/id to heading tag
33+ css('a[name] + h3').each do |node|
34+ node['id'] = node.previous_element['name']
35+ end
36+
37+ css('a[name] + ul.blockListLast').each do |node|
38+ node.at_css('li > h4')['id'] = node.previous_element['name']
39+ end
40+
41+ # Tag constructors, methods, and elements before removing context tags
42+ css('#constructor_detail').each do |node|
43+ node.parent.css('h4').each do |n|
44+ n['class'] = 'constructor'
45+ end
46+ end
47+
48+ css('#method_detail').each do |node|
49+ node.parent.css('h4').each do |n|
50+ n['class'] = 'method'
51+ end
52+ end
53+
54+ css('#element_detail').each do |node|
55+ node.parent.css('h4').each do |n|
56+ n['class'] = 'element'
57+ end
58+ end
59+
60+ css('#field_detail').each do |node|
61+ node.parent.css('h4').each do |n|
62+ n['class'] = 'field'
63+ end
64+ end
65+
66+ css('#enum_constant_detail').each do |node|
67+ node.parent.css('h4').each do |n|
68+ n['class'] = 'enum_constant'
69+ end
70+ end
71+
72+ # Flatten and remove unnecessary intermediate tags
73+ css('ul.blockList > li.blockList', 'ul.blockListLast > li.blockList').each do |node|
74+ node.before(node.children).remove
75+ end
76+
77+ css('ul.blockList', 'ul.blockListLast').each do |node|
78+ node.before(node.children).remove
79+ end
80+
81+ css('ul.blockList > table').each do |node|
82+ node.parent.before(node).remove
83+ end
84+
85+ css('h3', 'h4').each do |node|
86+ node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
87+ end
88+
89+ css('pre').each do |node|
90+ node['data-language'] = 'groovy'
91+ end
92+
93+ doc
94+ end
95+ end
96+ end
97+end
lib/docs/filters/groovy/entries.rb+28−0
@@ -0,0 +1,28 @@
1+module Docs
2+ class Groovy
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ slug.split('/').last
6+ end
7+
8+ def get_type
9+ slug.split('/')[0..-2].join('.')
10+ end
11+
12+ def include_default_entry?
13+ slug.split('/').last != 'package-summary'
14+ end
15+
16+ def additional_entries
17+ entries = []
18+ css('.method, .element, .field, .enum_constant').each do |node|
19+ entries << [@name + '.' + node['id'], node['id']]
20+ end
21+ css('.constructor').each do |node|
22+ entries << [node['id'], node['id']]
23+ end
24+ entries
25+ end
26+ end
27+ end
28+end
lib/docs/scrapers/groovy.rb+46−0
@@ -0,0 +1,46 @@
1+module Docs
2+ class Groovy < UrlScraper
3+ self.type = 'groovy'
4+ self.root_path = 'overview-summary.html'
5+ self.links = {
6+ home: 'https://groovy-lang.org/',
7+ code: 'https://github.com/apache/groovy'
8+ }
9+
10+ html_filters.push 'groovy/clean_html', 'groovy/entries'
11+
12+ options[:skip] = %w(
13+ index-all.html
14+ deprecated-list.html
15+ help-doc.html
16+ )
17+ options[:skip_patterns] = [
18+ /\Aindex.html/
19+ ]
20+
21+ options[:attribution] = <<-HTML
22+ &copy; 2003-2020 The Apache Software Foundation<br>
23+ Licensed under the Apache license.
24+ HTML
25+
26+ version '3.0' do
27+ self.release = '3.0.7'
28+ self.base_url = "https://docs.groovy-lang.org/#{self.release}/html/gapi/"
29+ end
30+
31+ version '2.5' do
32+ self.release = '2.5.14'
33+ self.base_url = "https://docs.groovy-lang.org/#{self.release}/html/gapi/"
34+ end
35+
36+ version '2.4' do
37+ self.release = '2.4.21'
38+ self.base_url = "https://docs.groovy-lang.org/#{self.release}/html/gapi/"
39+ end
40+
41+ def get_latest_version(opts)
42+ doc = fetch_doc('https://groovy.apache.org/download.html', opts)
43+ doc.at_css('#big-download-button').content.split(' ').last
44+ end
45+ end
46+end
public/icons/docs/groovy/16.png+0−0

Binary file not shown.

public/icons/docs/groovy/16@2x.png+0−0

Binary file not shown.

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