mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add Pig Documentation
This commit is contained in:
parent
90ebef1b6c
commit
1927f4e196
4 changed files with 99 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
|||
._markdown,
|
||||
._mocha,
|
||||
._mongoose,
|
||||
._pig,
|
||||
._sinon,
|
||||
._typescript,
|
||||
._webpack {
|
||||
|
|
26
lib/docs/filters/pig/clean_html.rb
Normal file
26
lib/docs/filters/pig/clean_html.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Docs
|
||||
class Pig
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('#content')
|
||||
|
||||
css('.pdflink').remove
|
||||
|
||||
css('a[name]').each do |node|
|
||||
node.next_element['id'] = node['name']
|
||||
end
|
||||
|
||||
css('h2', 'h3').each do |node|
|
||||
node.remove_attribute 'class'
|
||||
end
|
||||
|
||||
css('table').each do |node|
|
||||
node.remove_attribute 'cellspacing'
|
||||
node.remove_attribute 'cellpadding'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
33
lib/docs/filters/pig/entries.rb
Normal file
33
lib/docs/filters/pig/entries.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Docs
|
||||
class Pig
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
def include_default_entry?
|
||||
false
|
||||
end
|
||||
|
||||
def get_type
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
case slug
|
||||
when 'basic', 'cmds', 'func'
|
||||
nodes = css('h3')
|
||||
when 'cont'
|
||||
nodes = css('h2, #macros + div > h3')
|
||||
when 'test'
|
||||
nodes = css('h2, #diagnostic-ops + div > h3')
|
||||
when 'perf'
|
||||
nodes = css('h2, #optimization-rules + div > h3, #specialized-joins + div > h3')
|
||||
else
|
||||
nodes = css('h2')
|
||||
end
|
||||
|
||||
nodes.each_with_object [] do |node, entries|
|
||||
entries << [node.content, node['id'], get_type]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
39
lib/docs/scrapers/pig.rb
Normal file
39
lib/docs/scrapers/pig.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
module Docs
|
||||
class Pig < UrlScraper
|
||||
self.name = 'Pig'
|
||||
self.type = 'pig'
|
||||
self.links = {
|
||||
home: 'https://pig.apache.org/'
|
||||
}
|
||||
|
||||
html_filters.push 'pig/clean_html', 'pig/entries'
|
||||
|
||||
options[:skip] = %w( pig-index.html )
|
||||
|
||||
options[:skip_patterns] = [
|
||||
/\Aapi/,
|
||||
/\Ajdiff/
|
||||
]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2007–2016 Apache Software Foundation<br>
|
||||
Licensed under the Apache Software License version 2.0.
|
||||
HTML
|
||||
|
||||
version '0.15.0' do
|
||||
self.release = '0.15.0'
|
||||
self.base_url = "http://pig.apache.org/docs/r#{release}/"
|
||||
end
|
||||
|
||||
version '0.14.0' do
|
||||
self.release = '0.14.0'
|
||||
self.base_url = "http://pig.apache.org/docs/r#{release}/"
|
||||
end
|
||||
|
||||
version '0.13.0' do
|
||||
self.release = '0.13.0'
|
||||
self.base_url = "http://pig.apache.org/docs/r#{release}/"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue