Skip to content

Commit cb8e6d5

Browse files
committed
Add Groovy documentation
1 parent a525a79 commit cb8e6d5

9 files changed

Lines changed: 181 additions & 0 deletions

File tree

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ credits = [
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
'pages/github',
6262
'pages/go',
6363
'pages/graphite',
64+
'pages/groovy',
6465
'pages/gnuplot',
6566
'pages/haskell',
6667
'pages/jekyll',
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
css('.subNav', '.bottomNav').remove
16+
17+
css('hr + br', 'p + br', 'div + br', 'hr').remove
18+
19+
css('table').each do |node|
20+
node.remove_attribute 'summary'
21+
node.remove_attribute 'cellspacing'
22+
node.remove_attribute 'cellpadding'
23+
node.remove_attribute 'border'
24+
end
25+
26+
# Move anchor name/id to heading tag
27+
css('a[name] + h3').each do |node|
28+
node['id'] = node.previous_element['name']
29+
end
30+
31+
css('a[name] + ul.blockListLast').each do |node|
32+
node.at_css('li > h4')['id'] = node.previous_element['name']
33+
end
34+
35+
# Tag constructors, methods, and elements before removing context tags
36+
css('#constructor_detail').each do |node|
37+
node.parent.css('h4').each do |n|
38+
n['class'] = 'constructor'
39+
end
40+
end
41+
42+
css('#method_detail').each do |node|
43+
node.parent.css('h4').each do |n|
44+
n['class'] = 'method'
45+
end
46+
end
47+
48+
css('#element_detail').each do |node|
49+
node.parent.css('h4').each do |n|
50+
n['class'] = 'element'
51+
end
52+
end
53+
54+
css('#field_detail').each do |node|
55+
node.parent.css('h4').each do |n|
56+
n['class'] = 'field'
57+
end
58+
end
59+
60+
css('#enum_constant_detail').each do |node|
61+
node.parent.css('h4').each do |n|
62+
n['class'] = 'enum_constant'
63+
end
64+
end
65+
66+
# Flatten and remove unnecessary intermediate tags
67+
css('ul.blockList > li.blockList', 'ul.blockListLast > li.blockList').each do |node|
68+
node.before(node.children).remove
69+
end
70+
71+
css('ul.blockList', 'ul.blockListLast').each do |node|
72+
node.before(node.children).remove
73+
end
74+
75+
css('ul.blockList > table').each do |node|
76+
node.parent.before(node).remove
77+
end
78+
79+
css('h3', 'h4').each do |node|
80+
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
81+
end
82+
83+
doc
84+
end
85+
end
86+
end
87+
end

lib/docs/filters/groovy/entries.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1.83 KB
Loading
3.09 KB
Loading

public/icons/docs/groovy/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://docs.groovy-lang.org/latest/html/gapi/groovy.ico

0 commit comments

Comments
 (0)