Skip to content

Commit 1927f4e

Browse files
Phil SchererThibaut
authored andcommitted
Add Pig Documentation
1 parent 90ebef1 commit 1927f4e

4 files changed

Lines changed: 99 additions & 0 deletions

File tree

assets/stylesheets/pages/_simple.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
._markdown,
2828
._mocha,
2929
._mongoose,
30+
._pig,
3031
._sinon,
3132
._typescript,
3233
._webpack {

lib/docs/filters/pig/clean_html.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module Docs
2+
class Pig
3+
class CleanHtmlFilter < Filter
4+
def call
5+
@doc = at_css('#content')
6+
7+
css('.pdflink').remove
8+
9+
css('a[name]').each do |node|
10+
node.next_element['id'] = node['name']
11+
end
12+
13+
css('h2', 'h3').each do |node|
14+
node.remove_attribute 'class'
15+
end
16+
17+
css('table').each do |node|
18+
node.remove_attribute 'cellspacing'
19+
node.remove_attribute 'cellpadding'
20+
end
21+
22+
doc
23+
end
24+
end
25+
end
26+
end

lib/docs/filters/pig/entries.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Docs
2+
class Pig
3+
class EntriesFilter < Docs::EntriesFilter
4+
5+
def include_default_entry?
6+
false
7+
end
8+
9+
def get_type
10+
at_css('h1').content
11+
end
12+
13+
def additional_entries
14+
case slug
15+
when 'basic', 'cmds', 'func'
16+
nodes = css('h3')
17+
when 'cont'
18+
nodes = css('h2, #macros + div > h3')
19+
when 'test'
20+
nodes = css('h2, #diagnostic-ops + div > h3')
21+
when 'perf'
22+
nodes = css('h2, #optimization-rules + div > h3, #specialized-joins + div > h3')
23+
else
24+
nodes = css('h2')
25+
end
26+
27+
nodes.each_with_object [] do |node, entries|
28+
entries << [node.content, node['id'], get_type]
29+
end
30+
end
31+
end
32+
end
33+
end

lib/docs/scrapers/pig.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module Docs
2+
class Pig < UrlScraper
3+
self.name = 'Pig'
4+
self.type = 'pig'
5+
self.links = {
6+
home: 'https://pig.apache.org/'
7+
}
8+
9+
html_filters.push 'pig/clean_html', 'pig/entries'
10+
11+
options[:skip] = %w( pig-index.html )
12+
13+
options[:skip_patterns] = [
14+
/\Aapi/,
15+
/\Ajdiff/
16+
]
17+
18+
options[:attribution] = <<-HTML
19+
&copy; 2007&ndash;2016 Apache Software Foundation<br>
20+
Licensed under the Apache Software License version 2.0.
21+
HTML
22+
23+
version '0.15.0' do
24+
self.release = '0.15.0'
25+
self.base_url = "http://pig.apache.org/docs/r#{release}/"
26+
end
27+
28+
version '0.14.0' do
29+
self.release = '0.14.0'
30+
self.base_url = "http://pig.apache.org/docs/r#{release}/"
31+
end
32+
33+
version '0.13.0' do
34+
self.release = '0.13.0'
35+
self.base_url = "http://pig.apache.org/docs/r#{release}/"
36+
end
37+
38+
end
39+
end

0 commit comments

Comments
 (0)